

var xmlhttp;
var divId;
function loadXMLDoc(url, divId1)
{
xmlhttp=null;
divId = divId1;
if (window.XMLHttpRequest)
  {// code for all new browsers
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5 and IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,false);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change()
{
if (xmlhttp.readyState==4)
  {// 4 = "loaded"
  if (xmlhttp.status==200)
    {// 200 = OK
    //document.getElementById(divId).innerHTML = xmlhttp.responseText;	
    }
  else
    {
    alert("Problem retrieving XML data");
    }
  }
}

function SetPage(section)
{
	//this will set the header, footer and quicklinks
	loadXMLDoc('header.html', 'banner');		
	document.getElementById(divId).innerHTML = xmlhttp.responseText;
		
	loadXMLDoc('footer.html', 'footer');
	document.getElementById(divId).innerHTML = xmlhttp.responseText;
		
	//if QL is passed then load the following pages else do not	
	switch (section)
	{
	case 'News':		
		loadXMLDoc('newsSideBar.html', 'NewsltCol');
		document.getElementById(divId).innerHTML = xmlhttp.responseText;
	
		SetNewsSize();
		break;
		
	case 'QL':	
		loadXMLDoc('quicklinks.html', 'rtCol');	
		document.getElementById(divId).innerHTML = xmlhttp.responseText;
			
		loadXMLDoc('links.html', 'rtBottomCol');
		document.getElementById(divId).innerHTML = xmlhttp.responseText;
				
		SetSize();
		break;
	}	
}

function LoadSection(urlTag, divIdName)
{		
	loadXMLDoc(urlTag, divIdName);
	document.getElementById(divId).innerHTML = xmlhttp.responseText;
	
	SetSize();
}

function SetCustomerServiceSize()
{
	//mozzila & ie
	//this makes sure the bottom columns are the same height
	//must set the left and right heights equal to auto before resizing them		
	document.getElementById('ltCol').style.height='auto';
	document.getElementById('rtCol').style.height='auto';	
	document.getElementById('rtBottomCol').style.height='auto';	
	document.getElementById('ltNarrowCol').style.height='auto';
	document.getElementById('rtNarrowCol').style.height='auto';							
		
	var ltTopHeight = document.getElementById('ltCol').clientHeight;
	var rtTopHeight = document.getElementById('rtCol').clientHeight;		
	var rtTopCol = document.getElementById('rtCol');
	var ltTopCol = document.getElementById('ltCol');
	
	var rtBottomHeight = document.getElementById('rtBottomCol').clientHeight;	
	var rtBottomCol =  document.getElementById('rtBottomCol');	
		
	var ltNarrowHeight = document.getElementById('ltNarrowCol').clientHeight;	
	var rtNarrowHeight = document.getElementById('rtNarrowCol').clientHeight;	
	var rtNarrowCol =  document.getElementById('rtNarrowCol');	
	var ltNarrowCol =  document.getElementById('ltNarrowCol');
	//top row
	if (ltTopHeight >= rtTopHeight) 
	{			
		rtTopCol.style.height = (ltTopHeight - 10) + 'px';	
		//alert('rtTop ' + rtTopCol.style.height);		
	} 
	else
	{		
		ltTopCol.style.height = (rtTopHeight - 10) + 'px';
		//alert('ltTop ' + ltTopCol.style.height);		
	}	
	//narrow row 3 col
	if (rtNarrowHeight >= rtBottomHeight) 
	{			
		if (rtNarrowHeight >= ltNarrowHeight)
		{			
			ltNarrowCol.style.height = (rtNarrowHeight - 10) + 'px';
			rtBottomCol.style.height = (rtNarrowHeight - 10) + 'px';			
		}
	} 
	else
	{		
		if (rtBottomHeight >= ltNarrowHeight)
		{	
			ltNarrowCol.style.height = (rtBottomHeight - 10) + 'px';
			rtNarrowCol.style.height = (rtBottomHeight - 10) + 'px';
		}
	}	
}

function SetSize()
{
	//mozzila & ie
	//this makes sure the bottom columns are the same height
	//must set the left and right heights equal to auto before resizing them	
	document.getElementById('ltBottomCol').style.height='auto';
	document.getElementById('rtBottomCol').style.height='auto';
	document.getElementById('ltCol').style.height='auto';
	document.getElementById('rtCol').style.height='auto';
		
	var ltTopHeight = document.getElementById('ltCol').clientHeight;
	var rtTopHeight = document.getElementById('rtCol').clientHeight;		
	var rtTopCol = document.getElementById('rtCol');
	var ltTopCol = document.getElementById('ltCol');
	
	var ltBottomHeight = document.getElementById('ltBottomCol').clientHeight;	
	var rtBottomHeight = document.getElementById('rtBottomCol').clientHeight;	
	var rtBottomCol =  document.getElementById('rtBottomCol');	
	var ltBottomCol =  document.getElementById('ltBottomCol');	
	//bottom row
	if (ltBottomHeight >= rtBottomHeight) 
	{			
		rtBottomCol.style.height = (ltBottomHeight - 10) + 'px';
	} 
	else
	{
		ltBottomCol.style.height = (rtBottomHeight - 10) + 'px';
	}
	//top row
	if (ltTopHeight >= rtTopHeight) 
	{			
		rtTopCol.style.height = (ltTopHeight - 10) + 'px';	
		//alert('rtTop ' + rtTopCol.style.height);		
	} 
	else
	{		
		ltTopCol.style.height = (rtTopHeight - 10) + 'px';
		//alert('ltTop ' + ltTopCol.style.height);		
	}
}

function SetNewsSize()
{	
	//mozzila & ie
	//this makes sure the columns are the same height
	//must set the left and right heights equal to auto before resizing them
	document.getElementById('NewsltCol').style.height="auto";
	document.getElementById('NewsrtCol').style.height="auto";
			
	var ltHeight = document.getElementById('NewsltCol').clientHeight;
	var rtHeight = document.getElementById('NewsrtCol').clientHeight;	
		
	var rtCol =  document.getElementById('NewsrtCol');	
	var ltCol =  document.getElementById('NewsltCol');	
	
	
	//one of the rows must be at least 500px
	if (ltHeight < 500 && rtHeight < 500)
	{
		
		rtCol.style.height = '510px';
		ltCol.style.height = '500px';
	}
	else
	{
		//top row
		if (ltHeight >= rtHeight) 
		{		
			//rtCol.style.height = (ltHeight - 10) + 'px';		
			rtCol.style.height = (ltHeight) + 'px';		
		} 
		else
		{			
			//ltCol.style.height = (rtHeight - 10) + 'px';
			ltCol.style.height = (rtHeight) + 'px';
		}
	}
}

function SetGuideSize()
{	
	//mozzila & ie
	//this makes sure the columns are the same height
	//must set the left and right heights equal to auto before resizing them
	document.getElementById('guideltCol').style.height="auto";
	document.getElementById('guidertCol').style.height="auto";
	
	var bottomHeight;
	var bottomCol;
	var totalHeight;
	var ltHeight = document.getElementById('guideltCol').clientHeight;
	var rtHeight = document.getElementById('guidertCol').clientHeight;	
		
	var rtCol =  document.getElementById('guidertCol');	
	var ltCol =  document.getElementById('guideltCol');	
		
	//first check to see if there is a bottom column
	if (document.getElementById('guidertBottomCol')) 
	{	
		document.getElementById('guidertBottomCol').style.height="auto";
		//alert('rtHeight: ' + rtHeight);
		//alert('ltHeight: ' + ltHeight);
		document.getElementById('guidertBottomCol');
		bottomHeight = document.getElementById('guidertBottomCol').clientHeight;
		bottomCol = document.getElementById('guidertBottomCol')
		//this will add both right columns for a total height
		totalHeight = bottomHeight + rtHeight;	
		//alert('bottomHeight: ' + bottomHeight);
		//alert('totalHeight: ' + totalHeight);
	}
	else
	{
		totalHeight = rtHeight;
	}
		
	//top row
	if (ltHeight >= rtHeight) 
	{			
		//alert('left greater');		
		rtCol.style.height = (ltHeight - 10) + 'px';
	} 
	else
	{					
		//alert('right greater');
		if (document.getElementById('guidertBottomCol'))
		{
			ltCol.style.height = ((totalHeight - bottomHeight) - 10) + 'px';
		}
		else
		{
			ltCol.style.height = (totalHeight - 10) + 'px';
		}
	}	
}


//remove the word "search" from the search bar when the user selects the textbox
function clearSearch() {
	var box = document.getElementById("text_search");
	if (box.value == "search" || box.value == undefined) {
		box.value = "";
	}
}

//populate the search box with "search" for IE
function setSearch() {
	var box = document.getElementById("text_search");
	box.value = "search";
}
