// set minumum height for IE and Safari.

function onloadFunctions(){ 

//strech columns

	var columnMain=document.getElementById('columnMain');

	if (document.getElementById('columnSidebar')) {
		
		var columnSidebar=document.getElementById('columnSidebar');
		//alert(columnSidebar.offsetHeight);
		//alert(columnMain.offsetHeight);
		
		//compare sidebar with main div - if less then adjust columns
		if (columnSidebar.offsetHeight - 20 <= columnMain.offsetHeight) {
	
			//IE 6 and less does not recognize min-height, therefore adjust height
		
			if (navigator.userAgent.indexOf('MSIE 6.0')!=-1 || navigator.userAgent.indexOf('MSIE 5.5')!=-1 && navigator.userAgent.indexOf('Opera')==-1) {
				columnSidebar.style.height=(columnMain.offsetHeight + 110) + 'px';
			}else{
				columnSidebar.style.minHeight=(columnMain.offsetHeight + 110) + 'px';
			}
			
		
			
			//if there is an extra div adjust those dimensions
			if (document.getElementById('columnExtra')) {				
				var columnExtra=document.getElementById('columnExtra');				
					if (navigator.userAgent.indexOf('MSIE 6.0')!=-1 || navigator.userAgent.indexOf('MSIE 5.5')!=-1 && navigator.userAgent.indexOf('Opera')==-1) {
						columnExtra.style.height=(columnMain.offsetHeight + 60) + 'px';
					}else{
						columnExtra.style.minHeight=(columnMain.offsetHeight + 45) + 'px';
					}
			
	    	}
		
		}else {
			//if sidebar is longer then main, but columnExtra still short
			if (document.getElementById('columnExtra')) {
			
				var columnExtra=document.getElementById('columnExtra');
					if (navigator.userAgent.indexOf('MSIE 6.0')!=-1 || navigator.userAgent.indexOf('MSIE 5.5')!=-1 && navigator.userAgent.indexOf('Opera')==-1) {
						columnExtra.style.height=(columnSidebar.offsetHeight-40) + 'px';
					}else{
						columnExtra.style.minHeight=(columnSidebar.offsetHeight-40) + 'px';
					}
		
			}
			
		}
	
	}
	
	
	
		

		
/* ****************************************
	Below: Adapted from http://www.brucelawson.co.uk/index.php/2005/opening-links-in-new-windows-in-xhtml-strict/#comment-376
**************************************** */
if (!document.getElementsByTagName) return; 
	var anchors = document.getElementsByTagName("A");
	/* hide PDF note by default */
	
	if (document.getElementById('pdfNote')) {
	document.getElementById('pdfNote').className="hide"; 
		for (var i=0; i<anchors.length; i++) {
			var docLink = anchors[i];
			if (docLink.className=='externalDocument') {
				docLink.target = "_blank";
				docLink.innerHTML = docLink.innerHTML + "&nbsp;(opens in new window)";
				document.getElementById('pdfNote').className="show"; 
				}
			if (docLink.className=='externalDocumentNoNote') {
				docLink.target = "_blank";
			}	
			if (docLink.className=='externalHTML') {
				docLink.target = "_blank";
				docLink.innerHTML = docLink.innerHTML + "&nbsp;(opens in new window)";
			}
		}	
	}
/* ****************************************
 Above: Adapted from http://www.brucelawson.co.uk/index.php/2005/opening-links-in-new-windows-in-xhtml-strict/#comment-376
**************************************** */		

 

var searchText='<div id="searchJS">';

searchText+= '<form action="#" id="searchChoices">';
searchText+= '<fieldset id="radioSearch">';
searchText+= '<legend accesskey="4">Choose type of search</legend>';
searchText+= '<input type="radio" name="searchType" id="stories" value="stories" onclick="toggleSearch(\'stories\');" checked="checked" />';
searchText+= '<label for="stories" class="inline">News</label>';
searchText+= '<input type="radio" name="searchType" id="site" value="site" onclick="toggleSearch(\'site\');" />';
searchText+= '<label for="site" class="inline">Site</label>';

searchText+= '</fieldset> ';
searchText+= '</form>';




searchText+='<form action="/news/results.php" id="searchStory" method="get">';
searchText+= '<fieldset>';
searchText+= '<legend>Search Stories</legend>';
searchText+= '<label for="keyword_search">Stories</label>';
searchText+= '<input type="text" name="keyword_search" id="keyword_search" value=""/>';
searchText+= '<input type="hidden" name="keyword_action" value="all_words"/>';
searchText+= '<input type="submit" name="stories"  value="Search" />';
searchText+= '</fieldset>';
searchText+= '</form>';

searchText+= '<form action="/yahoo_results.php" id="searchSite" method="get">';
searchText+= '<fieldset>';
searchText+= '<legend>Search Site</legend>';
searchText+= '<label for="sitebox2">Site</label>';
searchText+= '<input type="text" name="query" id="sitebox2" /><?php $_REQUEST[\'type\'] = \'web\'; ?>';
searchText+= '<input type="submit" value="Search" />';

searchText+= '</fieldset>';
searchText+= '</form>';



searchText+= '</div>';


document.getElementById('searchbar').innerHTML = searchText;
document.getElementById('searchSite').style.display = "none";


// set up defaults for story page if JS turned on 

if (document.getElementById('tab_story')) {
	document.getElementById('tab_story').className="positioned";
}

if (document.getElementById('content_video') && document.getElementById('tab_video')) {
	document.getElementById('tab_video').className="positioned inactive";
	document.getElementById('content_video').className="hide_content";
	
}



if (document.getElementById('content_audio') && document.getElementById('tab_audio')) {
	
	if (document.getElementById('tab_video')) {
		document.getElementById('tab_audio').className="positioned inactive";
	}else {
		document.getElementById('tab_audio').className="positioned positioned2 inactive";
	}
	document.getElementById('content_audio').className="hide_content";
}





/* END function */
}


function toggleSearch(button) {
	if(button=="stories") {
		document.getElementById('searchStory').style.display = "block";
		document.getElementById('searchSite').style.display = "none";
	}
		if(button=="site") {	
		document.getElementById('searchSite').style.display = "block";
		document.getElementById('searchStory').style.display = "none";
	}
}


function showHideElement(ID) {
	
	var divs = document.getElementById('tab_container').getElementsByTagName('DIV');
	var h2s = document.getElementById('tab_container').getElementsByTagName('H2');

    for (var ia=0; ia<divs.length; ia++) {
		if (divs[ia].id.indexOf('content_')!=-1) {
			divs[ia].className='hide_content'
		}
	}
	for (var ib=0; ib<h2s.length; ib++) {
		
		if (h2s[ib].id.indexOf('tab_')!=-1) {
			h2s[ib].className="positioned inactive"
		}
		
		if (h2s[ib].id.indexOf('tab_audio')!=-1 && !document.getElementById('tab_video')) {
			h2s[ib].className="positioned positioned2 inactive"
		}
	}
	document.getElementById("content_" + ID).className='display_content'; 
	document.getElementById("tab_" + ID).className='positioned';

	//JM: if there is a pdf, the plug-in note will show when user first comes to story page. It will not show if they toggle thru video and/or audio
	//and then back to story. If left visible, in this case, it would display over absolutely positioned story, video, and audio containers
	document.getElementById("pdfNote").style.display='none';	
	if (ID=="audio" && !document.getElementById('tab_video')) {
		document.getElementById("tab_" + ID).className="positioned positioned2"
	}

}


function stretchColumns() {
//apply a minimum height to the 'main' div when it is shorter then the 'sidebar' div

	var columnMain=document.getElementById('columnMain');
	
	
	if (document.getElementById('columnSidebar')) {
		
		var columnSidebar=document.getElementById('columnSidebar');
		//alert(columnSidebar.offsetHeight);
		//alert(columnMain.offsetHeight);
		
		if (columnSidebar.offsetHeight <= columnMain.offsetHeight) {

			//IE 6 and less does not reconize min-height, therefore adjust height

			if (navigator.userAgent.indexOf('MSIE 6.0')!=-1 || navigator.userAgent.indexOf('MSIE 5.5')!=-1 && navigator.userAgent.indexOf('Opera')==-1) {

				columnSidebar.style.height=(columnMain.offsetHeight + 45) + 'px';

			}else{

				columnSidebar.style.minHeight=(columnMain.offsetHeight + 45) + 'px';

			}
		
		}
		//alert(columnSidebar.offsetHeight);
	}
		
		
	if (document.getElementById('columnExtra')) {
		var columnExtra=document.getElementById('columnExtra');

		//alert(columnExtra.offsetHeight);
		//alert(columnMain.offsetHeight);
		if (columnExtra.offsetHeight <= columnMain.offsetHeight) {

			//IE 6 and less does not reconize min-height, therefore adjust height

			if (navigator.userAgent.indexOf('MSIE 6.0')!=-1 || navigator.userAgent.indexOf('MSIE 5.5')!=-1 && navigator.userAgent.indexOf('Opera')==-1) {

				columnExtra.style.height=(columnMain.offsetHeight) + 'px';

			}else{

				columnExtra.style.minHeight=(columnMain.offsetHeight) + 'px';

			}

		}
		//alert(columnExtra.offsetHeight);
	}




}



	