var isHome = false;
// JavaScript Document
function WindowOnload(f) {
    var prev=window.onload;
    window.onload=function(){ if(prev)prev(); f(); }
}
function my_init() {
	//Enter path of images to be preloaded inside parenthesis. Extend list as desired.
preloadimages("../images/navOverBgDkBlue.gif","../images/navOverBgLtBlue.gif","../images/navOverBgLevel2.gif","../images/navOverBgLevel3.gif");
	miniImgObject = document.getElementById('smallImgRotate');
	miniLinkObject = document.getElementById('miniImgLink');
	if (isHome==true) {
		preloadImages();
		prevImg = document.getElementById('hiResBtn1');
	}
	preloadImages2();
	prevImg2 = document.getElementById('miniRotateBtn1');
	rotateImages();
	
	miniLinkObject.href = link1;
	miniLinkObject.target = link1target;
	
	if (link1Description!='') {
		miniImgObject.alt = link1Description;
	}
}
//preload hover images
var hoverImgs=new Array();
function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		hoverImgs[i]=new Image();
		hoverImgs[i].src=preloadimages.arguments[i];
	}
}

//for hi res 
function preloadImages() {
	if (document.images){
		var numImages = 4;
		preload_image_object = new Image();
		// set image url
		hiResImgs = new Array();
			//do not move the order or location of the next
			//4 hi res imagesthey use the showImg function
			hiResImgs[1] = "../images/hiRes1.jpg";
			hiResImgs[2] = "../images/hiRes2.jpg";
			hiResImgs[3] = "../images/hiRes3.jpg";
			hiResImgs[4] = "../images/hiRes4.jpg";
		var i = 0;
		for(i=0; i<=numImages; i++) {
			preload_image_object.src = hiResImgs[i];
		}
	}
}
//for mini rotate images
function preloadImages2() {
	if (document.images){
		var numImages2 = 4;
		preload_image_object2 = new Image();
		// set image url
		miniImages = new Array();
			//do not move the order or location of the next
			//4 mini images they use the showImg2 function
			miniImages[1] = "http://" + location.host + "/images/miniRotate1.jpg";
			miniImages[2] = "http://" + location.host + "/images/miniRotate2.jpg";
			miniImages[3] = "http://" + location.host + "/images/miniRotate3.jpg";
			miniImages[4] = "http://" + location.host + "/images/miniRotate4.jpg";
		var i = 0;
		for(i=0; i<=numImages2; i++) {
			preload_image_object2.src = miniImages[i];
		}
	}
}
function showImg(object, imageNum) {
	document.getElementById('hiResRotate').src = hiResImgs[imageNum];
	prevImg.style.backgroundImage = "url(/images/hiResBtnWhite.gif)";
	object.style.backgroundImage = "url(/images/hiResBtnBlue.gif)";
	prevImg = object;
}
function showImg2(object2, imageNum2) {
	miniImgObject.src = miniImages[imageNum2];
	if (imageNum2==1) {
		miniLinkObject.href = link1; 
		miniLinkObject.target = link1target;
		if (link1Description!='') {
			miniImgObject.alt = link1Description;
		}
	} else if (imageNum2==2) {
		miniLinkObject.href = link2; 
		miniLinkObject.target = link2target;
		if (link2Description!='') {
			miniImgObject.alt = link2Description;
		}
	} else if (imageNum2==3) {
		miniLinkObject.href = link3; 
		miniLinkObject.target = link3target;
		if (link3Description!='') {
			miniImgObject.alt = link3Description;
		}
	} else {
		miniLinkObject.href = link4; 
		miniLinkObject.target = link4target;
		if (link4Description!='') {
			miniImgObject.alt = link4Description;
		}
	}
	prevImg2.style.backgroundImage = "url(/images/miniRotateBtnWhite.gif)";
	object2.style.backgroundImage = "url(/images/miniRotateBtnBlue.gif)";
	prevImg2 = object2;
}
//rotate images
var nextImgNum = 2;
function rotateImages() {
	setInterval("changeCurImg()",7000);
}
function changeCurImg() {
	if (isHome==true) {
		var hiResBtn = 'hiResBtn'+nextImgNum;
		var btnObject1 = document.getElementById(hiResBtn);
		showImg(btnObject1,nextImgNum);
	}
	var miniRotateBtn = 'miniRotateBtn'+nextImgNum;
	var btnObject2 = document.getElementById(miniRotateBtn);
	showImg2(btnObject2,nextImgNum);
	if (nextImgNum==4) {
		nextImgNum = 1;
	} else {
		nextImgNum = nextImgNum+1;
	}
}
WindowOnload( my_init );


//Moved from quicklinksSearch.html by Michael Carlson 9-30-09, Modified 10-20-09
function DynamicChange() {
var list = document.quickLinkForm.quickLinks;
var listValue = list.options[list.selectedIndex].value;
   if (listValue.substr(0, 7) == "http://" ){
		//window.open(listValue,'NewWin');
		OpenWin(listValue, "NewWin");
   }else{
		window.location.href = listValue;
   }
}
//Moved from quicklinksSearch.html by Michael Carlson 9-30-09






//Added by Michael Carlson 8-13-09

var str = "";
var grp_open = false;
function DocLinkListToOption(main_container, label, opt1_text){
	if (!document.getElementById) return;
	var container = document.getElementById(main_container);
    if (container){
		str = "<form name='formNavigation' action=''><label>" + label + "<br /><select name='formNavigation2' size=1 id='opt_menu'>";
		str = str + "<option value='' title='" + opt1_text + "'>" + opt1_text + "</option>";
		LoopContainer(container);
		str = str + "</select><br /></label><input type='button' value='Get Form' title='Get Form' onclick='GetDoc();' /></form>";
    	container.innerHTML = str;	
	}
}
function LoopContainer(container){
	if (!document.getElementById) return;
    if (container){
    	var cnodes = container.childNodes;
    	if (cnodes){
       		for (var i = 0; i < cnodes.length; ++i){
          		if (cnodes[i].tagName){
        			if (cnodes[i].tagName == "SPAN"){
        				if (grp_open == true){
							grp_open = false;
							str = str + "</optgroup>";
						}else{
							grp_open = true;
						}
						str = str + "<optgroup label='" + cnodes[i].innerHTML + "'>";
					}
        			if (cnodes[i].tagName == "A"){
						str = str + "<option value='" + cnodes[i].href + "' title='" + cnodes[i].title + "'>" + cnodes[i].innerHTML + "</option>";
					}					
					LoopContainer(cnodes[i]);
          		}
       		}  
    	}
	}
}
function GetDoc(){
	if (!document.getElementById) return;
	var opt_menu = document.getElementById("opt_menu");
    if (opt_menu.options[opt_menu.selectedIndex].value.length > 0 ){
       window.open(opt_menu.options[opt_menu.selectedIndex].value,"Doc","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");		
	}
}

//Added by Michael Carlson 8-13-09




//Added by Michael Carlson 8-20-09

var start = false;
function DoTargetsNewWins(main_container, show_options, width, height){

	if (!document.getElementById) return;

    var container = ""
	
    if (start == false){
        start = true;
        container = document.getElementById(main_container);
    }else{
        container = main_container;
    }

   var cnodes = container.childNodes
   if (cnodes){
      for (var i = 0; i < cnodes.length; ++i){
         if (cnodes[i].tagName){
             if (cnodes[i].tagName == "A"){
                if (cnodes[i].target == "_blank"){
                
                    var cur_href = cnodes[i].href;
                    var cur_win = cnodes[i].title;
			
		            cnodes[i].href = "javascript:OpenWin('" + cur_href + "','" + cur_win + "'," + show_options + "," + width + "," + height + ");";
	            	//cnodes[i].href = "javascript:Void();";
 		            cnodes[i].target = "";		
    	            //cnodes[i].onclick = function(){return OpenWin(cur_href, cur_win, c_width, c_height);};
    	            
                }
             }
             DoTargetsNewWins(cnodes[i],show_options,width,height);
         }
      }   
   }
   
}

var all_window = new Array();
function OpenWin(cur_href, cur_win, show_options, width, height){
   
    if (!document.getElementById) return;
   
	cur_win = cur_win.replace(/ /g,'_');
		
    var w_str = "";
    var c_width = 0;
    if( !width ) {

    	if( typeof( window.innerWidth ) == 'number' ) {
        	//Non-IE
        	c_width = window.innerWidth;
    	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        	//IE 6+ in 'standards compliant mode'
        	c_width = document.documentElement.clientWidth;
    	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        	//IE 4 compatible
        	c_width = document.body.clientWidth;
    	}
    	c_width = c_width - 100;
		w_str = ",width=" + c_width;
    }else{
		c_width = width;
		w_str = ",width=" + c_width;
	}
	
	
    var h_str = "";
	var c_height = 0;
    if( !height ) {

    	if( typeof( window.innerWidth ) == 'number' ) {
        	//Non-IE
        	c_height = window.innerHeight;
    	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        	//IE 6+ in 'standards compliant mode'
        	c_height = document.documentElement.clientHeight;
    	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        	//IE 4 compatible
        	c_height = document.body.clientHeight;
    	}
    	c_height = c_height - 100;
		h_str = ",height=" + c_height;
    }else{
		c_height = height;
		h_str = ",height=" + c_height;
	}
    
	
    if (!all_window[cur_win] || all_window[cur_win].closed){
		
		var win_opt = "";
		
		if (show_options == false){
        	win_opt = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes" + w_str + h_str;
		}else{
        	win_opt = "toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes" + w_str + h_str;
		}

        all_window[cur_win] = window.open(cur_href,cur_win,win_opt);
    }else{
        all_window[cur_win].focus();
    }
 
}
function CloseWin(cur_win){
   if (!document.getElementById) return;
   window.close(cur_win);
}
//Added by Michael Carlson 8-20-09




//Added by Michael Carlson 9-30-09
var orig_act = "";
function InitGoogleSearch(){
    if (!document.getElementById) return;
		
    var gs_form = document.getElementById("google_search");
    if (gs_form){
		
		var str = "";	
		
        if (orig_act.length == 0){
			orig_act = gs_form.action;
		}
		
		gs_form.action = "javascript:void(0)"
		gs_form.target = ""
		
    	var gs_btn = document.getElementById("sub_btn");
    	var src_box = document.getElementById("search");
		
		var cnodes = gs_form.childNodes
    	if (cnodes){
       		for (var i = 0; i < cnodes.length; ++i){
           		if (cnodes[i].type == "hidden"){
					str = str + cnodes[i].name + "=" + cnodes[i].value + "&";		
          		}
       		}   
    	}		

		gs_btn.onclick = function(){return OpenWin(orig_act + src_box.name + "=" + src_box.value + "&" + str, "Google", false, 830);};
	
	}
}
//Added by Michael Carlson 9-30-09


//Added by Michael Carlson 10-21-09
function EnterKeyActions(evt){
	
	var evt = (evt) ? evt : ((event) ? event : null);
	var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
	if (evt.keyCode == 13){
	   
		switch (node.id){
			case "search":
   
				var str = "";	
   				var gs_form = document.getElementById("google_search");
   				if (gs_form){
		
        			if (orig_act.length == 0){
						orig_act = gs_form.action;
					}
		
					var cnodes = gs_form.childNodes
    				if (cnodes){
       					for (var i = 0; i < cnodes.length; ++i){
           					if (cnodes[i].type == "hidden"){
								str = str + cnodes[i].name + "=" + cnodes[i].value + "&";		
          					}
       					}   
    				}		

					OpenWin(orig_act + node.name + "=" + node.value + "&" + str, "Google", false, 830);	   
		 		}
   
				break;
            case "quickLinks":
        
				DynamicChange();
		
				break;
		}
	 
	}
}
document.onkeypress = EnterKeyActions;
//Added by Michael Carlson 10-21-09







