sfHover = function() {
	var sfEls = document.getElementById("navigation").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			sel = document.getElementsByTagName("select");
			// hide select boxes in IE before 7 so menu doesn't go behind them
			if(is_oldie) {
				for (var i=0; i<sel.length; i++) {
					sel[i].style.visibility = 'hidden';
				}
			}
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			sel = document.getElementsByTagName("select");
			// show select boxes in IE after being hidden
			if(is_oldie) {
				for (var i=0; i<sel.length; i++) {
					sel[i].style.visibility = 'visible';
				}
			}
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
//******************************************************//
//  Code to execute here                                //
//******************************************************//
if (window.attachEvent) window.attachEvent("onload", sfHover);
var tmp = new Image();
tmp.src = "/images/search_button_hover.gif"; // preload search hover image
var agt=navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie7 = (navigator.appVersion.search(/MSIE 7./) != -1);
var is_ie8 = (navigator.appVersion.search(/MSIE 8./) != -1);
var is_oldie = (is_ie && !is_ie7 && !is_ie8);

//******************************************************//
//  Add Load Event to enable additional onload actions  //
//******************************************************//
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

//******************************************************//
//  Check they entered something to search for          //
//******************************************************//
function chkSearch (form) {
	if (form.q.value == "Search...") {
		alert("Please enter the text to search for");
		return false;
	}
}

//***************************************************//
//         Text sizing version .9 from cdc.gov       //
//***************************************************//

var sizesArray = new Array("80%", "85%", "90%", "95%", "100%", "105%", "110%", "115%", "120%")
var sizePointer
var ruleCounter
// ruleCounter is used for Mozilla due to the necessity to write the new CSS rule in the last position so that it is applied.

if (getCookie("sizePref") != "") {
	sizePointer = Number(getCookie("sizePref"))
	// now apply the font
	if (document.styleSheets[0].cssRules) {
		ruleCounter = document.styleSheets[0].cssRules.length
	// Mozilla
	document.styleSheets[0].insertRule("#container {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter)
		//ruleCounter = ruleCounter + 1
	}
	else {
	//IE
	document.styleSheets[0].addRule("#container", "{font-size: " + sizesArray[sizePointer] + ";}")
	}
}
else {
	sizePointer = 4
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return ""
}

function largerFont () {
	
	if (document.styleSheets[0].cssRules) {
	// Mozilla
		if (document.styleSheets[0].cssRules[0]) {
			if (sizePointer != 8) {
				ruleCounter = document.styleSheets[0].cssRules.length
				sizePointer = sizePointer + 1
				document.styleSheets[0].insertRule("#container {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter)
//				document.cookie = 'sizePref='+ sizePointer + '; path=/; domain=' + document.domain;
				document.cookie = 'sizePref='+ sizePointer + '; path=/;';
			}
		}	
	}
	
	else if (document.styleSheets[0].rules) {
	// IE
		if (sizePointer < 8) {
			sizePointer = sizePointer + 1
			document.cookie = 'sizePref='+ sizePointer + '; path=/;';
			document.styleSheets[0].addRule("#container", "{font-size: " + sizesArray[sizePointer] + ";}")
			}
		}
	}

function smallerFont () {
	
	if (document.styleSheets[0].cssRules) {
	// Mozilla
		if (document.styleSheets[0].cssRules[0]) {	
			if (sizePointer != 0) {
				sizePointer = sizePointer - 1;
				ruleCounter = document.styleSheets[0].cssRules.length;
				document.styleSheets[0].insertRule("#container {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter);
				document.cookie = 'sizePref='+ sizePointer + '; path=/;';
			}
		}	
	}
	
	else if (document.styleSheets[0].rules) {
	// IE
		if (sizePointer > 0) {
			sizePointer = sizePointer - 1
			document.cookie = 'sizePref='+ sizePointer + '; path=/;';
			document.styleSheets[0].addRule("#container", "{font-size: " + sizesArray[sizePointer] + ";}")
		}
	}
}