//var activeSub=0;
//var SubNum=0;

ItemWidth = 150;


Image1= new Image()
Image1.src = "img/bg_menu_item.gif"

Image2 = new Image()
Image2.src = "img/bg_menu_item_over.gif"

Image3 = new Image()
Image3.src = "img/bottom-left_s.gif";

Image4 = new Image()
Image4.src = "img/bottom-right_s.gif";

Image5 = new Image()
Image5.src = "img/bottom-bg_s.gif";


function reDo(){ window.location.reload() }
    window.onresize = reDo;


    //Define global variables

	    var timerID = null;
		var timerOn = false;
		var timecount = 1000;
		var what = null;
		var newbrowser = true;
		var check = false;

    	function init(){
    	//  alert ("Running Init");
          if (document.layers) {
                      //  alert ("Running Netscape 4");
                        layerRef="document.layers";
                        styleSwitch="";
                        visibleVar="show";
			screenSize = window.innerWidth;
			what ="ns4";


          }else if(document.all){
                      //  alert ("Running IE");
                        layerRef="document.all";
                        styleSwitch=".style";
                        visibleVar="visible";
			screenSize = document.body.clientWidth + 18;
			what ="ie";

		  }else if(document.getElementById){
                      //  alert ("Running Netscape 6");
                        layerRef="document.getElementByID";
                        styleSwitch=".style";
                        visibleVar="visible";
			what="moz";
		  
		  }else{
		  	//alert("Older than 4.0 browser.");
			what="none";
			newbrowser = false;
		  }
		  
 
		//window.status='status bar text to go here';
		check = true;
  	 	}

	// Turns the layers on and off
        function showLayer(layerName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
	        	else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="visible";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
                  }
		 }
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
		}

        function hideLayer(layerName){
        	if(check){
        		if (what =="none"){
        			return;
        			}
        		else if (what == "moz"){
        			document.getElementById(layerName).style.visibility="hidden";
        			}
        		else{
                  eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
				}
        
        	}
        	else {// alert ("Please wait for the page to finish loading.");
        		return;}
        }

		
		
		function hideAll(){
				for (i=1;i<=catagoryNum;i++) {
						hideLayer('layer'+i);
				}
		}


		function startTime() {
	        if (timerOn == false) {
                timerID=setTimeout( "hideAll()" , timecount);
                timerOn = true;

	        }

		}


		function stopTime() {
	        if (timerOn) {
    	        clearTimeout(timerID);
                timerID = null;
                timerOn = false;
	        }
		}

		function onLoad(){
			init();
			
			}
//Checking screen size
//opera Netscape 6 Netscape 4x Mozilla 

if (window.innerWidth || window.innerHeight){ 
docwidth = window.innerWidth; 
docheight = window.innerHeight; 
}
 
//IE Mozilla 
if (document.body.clientWidth || document.body.clientHeight){ 
docwidth = document.body.clientWidth; 
docheight = document.body.clientHeight; 
} 

// mouse-over effect
        function mouseAct(el){
			el.style.background= 'url(img/bg_menu_item_over.gif)';
		}
		
		function mouseDeAct(el){
			el.style.background= 'url(img/bg_menu_item.gif)';
		}
//set position
TotalWidth = (catagoryNum*ItemWidth)+12;

//div open tag
document.write("<div id='CSmenu' style='position: absolute; width:  " + TotalWidth + "px; z-index: 10;'>");



document.write("<div style='width: " + TotalWidth + "px; height: 17px;'>");
		
			

//document.write("<DIV STYLE='float: left; width: 6px;'><IMG src='img/bottom-left.gif'></div>");
		  
//Catagory labels		  	 
for (i=0; i<catagoryNum; i++){
	catagoryname = eval("catagory_" + i);
	document.write("<DIV onMouseOver=\"hideAll(); showLayer('layer" + (i+1) +"'); stopTime()\" onMouseOut=\"startTime();\" STYLE='float: left; width:  " + ItemWidth + "px; height: 18px; text-align: center; background: url(img/bottom-bg.gif) repeat-x;'>");
	document.write("<a href='#' style=\"font-family : Verdana; color : #232323; font-size: 10px; text-decoration : none;\">" + catagoryname + "</a>");
	document.write("</div>");
}
		

document.write("<DIV STYLE='float: left; width: 6px;'><IMG src='img/bottom-right.gif'></div>");

document.write("</div>");


document.write("<DIV STYLE='clear: both; margin-top: -1px; width: " + (TotalWidth-6) + "px;'>");

for (k=0; k<catagoryNum; k++) {
	
	document.write("<div id='layer" + (k+1) +"' style='float: left; visibility: hidden; width: " + ItemWidth + "px;'>");
	
	navNum = eval("catagory_"+k+"_items");

	
	for (j=0; j<=(navNum-1); j++) {
 
		label = eval("catagory_" + k + "_label"+j);
		linkStr = eval("catagory_" + k + "_link"+j);
		ItemName = "ItemName_" + k + j;
		

		document.write("<a href='");
		document.write(linkStr);
		document.write("' style='font-family : Verdana; color : #232323; font-size: 10px; text-decoration : none;'>");
		document.write("<div id='" + ItemName +"' style='padding-left: 10px; clear: both; height: 20px; background-image : url(img/bg_menu_item.gif);' onMouseOver='mouseAct(this);stopTime();' onMouseOut='mouseDeAct(this);startTime();'>");

		document.write("<a href='");
		document.write(linkStr);
		document.write("' style='font-family : Verdana; color : #232323; font-size: 10px; text-decoration : none;'>");
		document.write(label);
		document.write("</a>");
		document.write("</div>");
		document.write("</a>");
	}
		document.write("<DIV STYLE='height: 10px; margin: 0px;'>");
			//document.write("<div style='float: left; height: 10px; width: 6px; background: url(img/bottom-left_s.gif) no-repeat;'></div>");
			document.write("<div style='float: left; height: 10px; width: 144px; background: url(img/bottom-bg_s.gif) repeat-x;'></div>");
			document.write("<div style='float: left; height: 10px; width: 6px; background: url(img/bottom-right_s.gif) no-repeat;'></div>");
		document.write("</div>");
		
	
	document.write("</div>");
	
}
	document.write("</div>");
document.write("</div>");
