	var prevcolor;
	var previmage;

	currentsub=0;
	currentreal=0;
	currentsubsub=1;
	currentmain='main0';
	subsub=false;


	function showsub(whichsub){
		mainnum=whichsub;
		if (whichsub==2) {
			mainnum=2;
			subsub=true;
		}
		if (whichsub==10) {
			mainnum=1;
			subsub=true;
		}
		if (whichsub==11) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==12) {
			mainnum=4;
			subsub=true;
		}
		if (whichsub==13) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==14) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==15) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==16) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==17) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==66) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==18) {
			mainnum=3;
			subsub=true;
		}
		if (whichsub==19) {
			mainnum=4;
			subsub=true;
		}
		if (whichsub==20) {
			mainnum=1;
			subsub=true;
		}
		if (whichsub==21) {
			mainnum=1;
			subsub=true;
		}
		if (whichsub==22) {
			mainnum=1;
			subsub=true;
		}
		if (whichsub==23) {
			mainnum=1;
			subsub=true;
		}

		if (whichsub==24) {
			mainnum=4;
			subsub=true;
		}
		if (whichsub==25) {
			mainnum=4;
			subsub=true;
		}
		if (whichsub==26) {
			mainnum=4;
			subsub=true;
		}
		if (whichsub==27) {
			mainnum=4;
			subsub=true;
		}
		if (whichsub==28) {
			mainnum=4;
			subsub=true;
		}
		
		if (whichsub==71) {
			mainnum=3;
			subsub=true;
		}

		if (whichsub==78) {
			mainnum=3;
			subsub=true;
		}
		whichmain="main"+mainnum;
		tempsub="sub"+whichsub;
		currentguy="sub"+currentreal;
		if(document.getElementById(currentguy) != null)
			document.getElementById(currentguy).style.display="none";
		//document.getElementById(currentguy).style.top=-100;
		if(document.getElementById(tempsub) != null)
		{
			document.getElementById(tempsub).style.display="block";
			document.getElementById(tempsub).style.top=18;
		}
		if (currentmain!='main0') document.getElementById(currentmain).style.backgroundColor='#E5ECF9';
		if (whichmain!='main0')document.getElementById(whichmain).style.backgroundColor='#FFFFFF';
		currentmain=whichmain;
		
		//if(document.getElementById(currentguy) == null && document.getElementById(tempsub) == null)
		//	return;

		//clear old images

		if (currentsub<=1){
			document.getElementById('leftend').src="images/tab_left_end_off.gif";
			document.getElementById('tab1').src="images/tab_main_off.gif";
		} else if (currentsub !=8){
			tempimage="tab"+currentsub;
			document.getElementById(tempimage).src="images/tab_main_off.gif";
			templeft="tab"+(currentsub-1);
			document.getElementById(templeft).src="images/tab_main_off.gif";
		} else {
			document.getElementById('rightend').src="images/tab_right_end_off.gif";
			document.getElementById('tab7').src="images/tab_main_off.gif";
		}
	
		//This will menu to blank menu
		if(whichmain!='main0')
		{	
			//set new images

			if (mainnum==1){
				document.getElementById('leftend').src="images/tab_left_end_on.gif";
				whichimage="tab"+mainnum;
				document.getElementById(whichimage).src="images/tab_main_right_on.gif";
			} else if (mainnum!=8){
				templeft="tab"+(mainnum-1);
				document.getElementById(templeft).src="images/tab_main_left_on.gif";
				whichimage="tab"+mainnum;
				document.getElementById(whichimage).src="images/tab_main_right_on.gif";
			} else {
				templeft="tab"+(mainnum-1);
				document.getElementById(templeft).src="images/tab_main_left_on.gif";
				document.getElementById('rightend').src="images/tab_right_end_on.gif";
			
			}
			if (currentsub!=0 && currentsubsub != 0){
				temp="sub"+currentreal+"_"+currentsubsub;
				//alert (temp);		
				document.getElementById(temp).style.color="#778CC6";
				document.getElementById(temp).style.backgroundImage="url(images/bullet_arrow_off.gif)";		
			}
			currentsub=mainnum;
			currentreal=whichsub;
			currentsubsub=0;
			setselmenu(whichsub);
			//changesub(1);
		}
		else
		{
			currentsub=0;
			currentreal=0;
			currentsubsub=1;
			//currentmain='main0';
			subsub=false;	
			resetMenu();
		}
		// saves selected menu to cookie
		
	}


	function changesub(whichsub){
		if (currentsubsub!=0){
			//turn off old submenu if we just came from a submenu, not a main menu
			temp="sub"+currentreal+"_"+currentsubsub;
			document.getElementById(temp).style.color="#778CC6";
			document.getElementById(temp).style.backgroundImage="url(images/bullet_arrow_off.gif)";
		}

		//turn on new submenu
		if(whichsub != 0)
		{
			temp="sub"+currentreal+"_"+whichsub;
			document.getElementById(temp).style.color="#022873";
			document.getElementById(temp).style.backgroundImage="url(images/bullet_arrow_on.gif)";
			prevcolor=document.getElementById(temp).style.color;
			previmage=document.getElementById(temp).style.backgroundImage;
		}	
		currentsubsub=whichsub;
		if (whichsub>8) subsub=true;

		//saves selected submenu to cookie
		setselsubmenu(whichsub);
	}

	function subover(whichsub){
		temp="sub"+currentreal+"_"+whichsub;
		//alert (temp);
		prevcolor=document.getElementById(temp).style.color;
		previmage=document.getElementById(temp).style.backgroundImage;
		document.getElementById(temp).style.color="#022873";
		document.getElementById(temp).style.backgroundImage="url(images/bullet_arrow_on.gif)";	
	}

	function subout(whichsub){
		temp="sub"+currentreal+"_"+whichsub;
		if ((temp=="sub10_2")&&(subsub)){ 
			temp="sub1_2";
			document.getElementById(temp).style.color="#778CC6";
			document.getElementById(temp).style.backgroundImage="url(images/bullet_arrow_off.gif)";		
		} else {
			if (document.getElementById(temp)) {
				document.getElementById(temp).style.color=prevcolor;
				document.getElementById(temp).style.backgroundImage=previmage;
			}
		}

	}
	
	function resetMenu(){
		setselmenu(0);
		setselsubmenu(0);
	}
	
	function initHelp(){
		sethelp("");
	}

	function sethelp(url){
		document.cookie = "gishelp=" + url;	
	}
	
	function gethelp(){
		return get_cookie("gishelp");
	}

	function setselmenu(menu){
		document.cookie = "gismainmenu=" + menu;
	}
	
	function setselsubmenu(submenu){
		document.cookie = "gissubmenu=" + submenu;
	}

	function getselmenu(){
		return get_cookie("gismainmenu");		
	}
	
	function getselsubmenu(){
		return get_cookie("gissubmenu");
	}

	// These handle saving the state of the menu to session cookies
	function get_cookie(Name) {
		var search = Name + "=";
		var returnvalue = "";
		if (document.cookie.length > 0){
			offset = document.cookie.indexOf(search)// if cookie exists
			if (offset != -1){
				offset += search.length // set index of beginning of value
				end = document.cookie.indexOf(";", offset);// set index of end of cookie value
				if (end == -1) 
					end = document.cookie.length;
				returnvalue = unescape(document.cookie.substring(offset, end))
			}
		}
		return returnvalue;
	}

	function initmenus(){
		var selmenu = getselmenu();
		
		if(selmenu != "" && selmenu!=0){
			var menu = selmenu;
			showsub(menu);
	
			var selsubmenu = getselsubmenu();
			
			if(selsubmenu != "" && selsubmenu != 0){
				var submenu = selsubmenu;
				changesub(submenu);
			}
		}
	}