/* Show and Hide a Menu */   
var current_menu = "";
var current_sub_menu = "";
var mstatus = "";
var sub_mstatus = "";
var mstatus_checker = "";
var sub_mstatus_checker = "";


function getRef(theID,oDoc) {
  if( document.getElementById ) {
    return document.getElementById(theID); }
  if( document.all ) {
    return document.all[theID]; }
  if( !oDoc ) { oDoc = document; }
  if( document.layers ) {
    if( oDoc.layers[theID] ) { return oDoc.layers[theID]; } else {
      //repeatedly run through all child layers
      for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
        //on success, return that layer, else return nothing
        y = getRef(theID,oDoc.layers[x].document); }
    return y; } }
  return false;
}



function check_mstatus(menuID){
	if(mstatus=="off"){
	
			//get a reference as above ...
 			 myReference = getRef(menuID);
  			if( !myReference ) {
  	 		 //window.alert('Nothing works in this browser, used for testing');
  	 			 return; //don't go any further
  			}
  			//now we have a reference to it
  			if( myReference.style ) {
   			 //DOM & proprietary DOM
   			 myReference.style.visibility = 'hidden';
 			 } else {
   			 //layers syntax
   			 myReference.visibility = 'hide';
 			 }
			clearInterval(mstatus_checker);
		}
	}



function change_mstatus(value){
	mstatus = value;
}


/* Show a menu */
function showMenu(menuID) {
	// first clear the interval, then set menu status
	clearInterval(window.mstatus_checker);
	change_mstatus("on");
	// check to see if there is a menu open already
	if(current_menu!="" && getRef(current_menu)){
		 myReference.style.visibility = "hidden";
	}
	// set var for new open menu
	current_menu = menuID;
	
  	//get a reference as above ...
 	myReference = getRef(menuID);
  	if( !myReference ) {
    //window.alert('Nothing works in this browser, used for testing');
    return; //don't go any further
 	}
 	 //now we have a reference to it
 	 if( myReference.style ) {
    //DOM & proprietary DOM
    myReference.style.visibility = 'visible';
 	 } else {
    //layers syntax
    myReference.visibility = 'show';
  }
}


/* Hide a menu */
function hideMenu(menuID) {
	// set menu status, then call check_mstatus after 1 second
	mstatus = "off";
	mstatus_checker = window.setInterval("check_mstatus('"+menuID+"')",500);

}


/****************SUB MENUS**********************/


function check_sub_mstatus(menuID){
	if(sub_mstatus=="off"){
	
			//get a reference as above ...
 			 myReference = getRef(menuID);
  			if( !myReference ) {
  	 		 //window.alert('Nothing works in this browser, used for testing');
  	 			 return; //don't go any further
  			}
  			//now we have a reference to it
  			if( myReference.style ) {
   			 //DOM & proprietary DOM
   			 myReference.style.visibility = 'hidden';
 			 } else {
   			 //layers syntax
   			 myReference.visibility = 'hide';
 			 }
			clearInterval(sub_mstatus_checker);
		}
	}



function change_sub_mstatus(value){
	sub_mstatus = value;
}

/* Show a sub menu */
function showSubMenu(menuID) {
	// first clear the interval, then set menu status
	clearInterval(window.sub_mstatus_checker);
	change_sub_mstatus("on");
	// check to see if there is a menu open already
	if(current_sub_menu!="" && getRef(current_sub_menu)){
		 myReference.style.visibility = "hidden";
	}
	// set var for new open menu
	current_sub_menu = menuID;
	
  	//get a reference as above ...
 	myReference = getRef(menuID);
  	if( !myReference ) {
    //window.alert('Nothing works in this browser, used for testing');
    return; //don't go any further
 	}
 	 //now we have a reference to it
 	 if( myReference.style ) {
    //DOM & proprietary DOM
    myReference.style.visibility = 'visible';
 	 } else {
    //layers syntax
    myReference.visibility = 'show';
  }
}

/* Hide a sub menu */
function hideSubMenu(menuID) {
	// set menu status, then call check_mstatus after 1 second
	sub_mstatus = "off";
	sub_mstatus_checker = window.setInterval("check_sub_mstatus('"+menuID+"')",500);

}
