//		This code for DHTML/javascript Menu was written by Srinivas Chillappa (srinivas.chillappa@ttu.edu).
//		Copyright 2003 by Srinivas Chillappa.
//		If you want to use this code, you must include this notice in the header of the webpage, 
//		where you intend using this code.

//Define global variables
var crossFadeDuration = .6;
var transnum = 10;
var transnumend = 10;
var allMenus = new Array('div1', 'div2', 'div3', 'div4');
var menID = "";
var menAllID = '';
var iMax = false;
var timerID = null;
var timerOn = false;
var timecount = 1;
var what = null;
var newbrowser = true;
var check = false;
var loadwin = false;
var activeSub=0;
var SubNum=0;

function reDo(){ window.location.reload() }
    window.onresize = reDo;

function menuon(cellid){
	cellid.style.backgroundColor = '#9B7272';
}
function menuout(cellid){
	cellid.style.backgroundColor = '#A90000';
}

function openlink(url,targetlocation){
	if (targetlocation == 0){
		window.location.href = url;
	}
	else if (targetlocation == 1){
		window.open(url);
	}
	
}
    	function init(){
    	  if (document.layers) {
                      //  Netscape 4
                        layerRef="document.layers";
                        styleSwitch="";
                        visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";
			//alert('Net4');
          }else if(document.all){
                      //  IE
                        layerRef="document.all";
                        styleSwitch=".style";
                        visibleVar="visible";
			screenSize = document.body.clientWidth + 18;
			what ="ie";
			//alert('IE');
		  }else if(document.getElementById){
                      // Netscape 6
                        layerRef="document.getElementByID";
                        styleSwitch=".style";
                        visibleVar="visible";
			what="moz";
			//alert('Moz');		  
		  }else{
		  	//Older than 4.0 browser
			what="none";
			newbrowser = false;
			//alert('None');
		  } 
		window.status='Texas Tech University - Payroll';
		check = true;
  	 	}

	// Turns the layers on and off
	//showHideLayer('div1',1,this);
	function showHideLayer(divName, cellRef){
		//maintain the order of the functions below:
		hideDiv(divName); //call this first
		showLayer(divName); //call this second
		stopTime(); //call this third
		menuon(cellRef); //call this fourth
	}
	      function showLayer(layerName){
        	if(check){
        			if (what == "ie" && !loadwin) {
        				document.getElementById(layerName).filters[0].transition = transnum;
        				document.getElementById(layerName).filters[0].Apply();
        				document.getElementById(layerName).style.visibility="visible";        			
						document.getElementById(layerName).filters[0].Play();
						loadwin = true;        										
					}
					else if (what == "moz"){
                  document.getElementById(layerName).style.visibility="visible";
                  //loadwin= true;
                 }
                 else {
                 	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
                  	//loadwin= true;
                 }        			 
		 }
        	else {
        		return;}
		}
        function hideLayer(layerName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "ie" && loadwin){        			
        			document.getElementById(layerName).filters[0].transition = transnumend;
        			document.getElementById(layerName).filters[0].Apply(); 
        			document.getElementById(layerName).style.visibility="hidden";       			        			     			
					document.getElementById(layerName).filters[0].Play();
						if (iMax){					
        					loadwin = false;
        					iMax = false;
        				}
        			}
        		else if (what == "moz"){
                  document.getElementById(layerName).style.visibility="hidden";
                  //loadwin= false;
                 }
                 else {
                 	eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
                  	//loadwin= false;
                 }
        
        	}
        	else {
        		return;}
        }        
        function hideDivLayer(lrName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "ie" && loadwin){        			
        			document.getElementById(lrName).filters[0].transition = transnumend;
        			document.getElementById(lrName).filters[0].Apply();   
        			document.getElementById(lrName).style.visibility="hidden";     			        			        			     			
					document.getElementById(lrName).filters[0].Play();										        			        			
        			}
        		else if (what == "moz"){        			
                  document.getElementById(lrName).style.visibility="hidden";                  
                 }
                 else {
                 	eval(layerRef+'["'+lrName+'"]'+styleSwitch+'.visibility="hidden"');
                 }        
        	}
        	else {
        		return;}
        }        
        function hideDiv(divID){
        	for (i=0;i<allMenus.length;i++){
        		if (allMenus[i] != divID){        			     			      			
        			hideDivLayer(allMenus[i]);        			
        		}
        	}
        }
		function hideAll(){
			{
				for (i=0;i<allMenus.length;i++){					
					if (i == allMenus.length-1){
						iMax = true;
					}
					hideLayer(allMenus[i]);					
				}				
			}
		}
		function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , timecount); 
                timerOn = true;
	        }
		}
		function stopTime() {
	        if (timerOn) {
    	        clearTimeout(timerID); 
                timerID = null;
                timerOn = false;
	        }
		}

window.onload = function (){
init();
}	


		
			