

// List of IDs of DIVs
var SubMenusList = new Array("","academics","admin","about","calender", "direct", "education", "campus", "search", "supp","tech","wonder","hebwonder");
var SubSubMenusList = new Array("", "acbiol", "acbiochem", "acchem", "acphys", "acmath", "acfein");

var last_open_subsubmenu = 100;
var last_open_submenu = 100;

var versx = navigator.appVersion;
versx = versx.substring(0,1);

var browser_name;
if(navigator.appName=="Netscape" && versx!="4")
  browser_name = "N6";
else if(navigator.appName=="Netscape" && versx=="4")
  browser_name = "N4";
else if(navigator.appName=="Microsoft Internet Explorer")
  browser_name = "IE";
else
  browser_name = "OTHER";


function NS4layers()
{
	for(i=1; i<11;i++)
	{
		document.layers[SubMenusList[i]].width = 380;
		document.layers[SubMenusList[i]].height = 300;
		document.layers[SubMenusList[i]].bgColor = '#006699';
		document.layers[SubMenusList[i]].zIndex = 0;
	}
	for(i=1; i<7;i++)
	{		
		document.layers[SubSubMenusList[i]].width = 350;
		document.layers[SubSubMenusList[i]].height = 277;
		document.layers[SubSubMenusList[i]].bgColor = '#006699';
		document.layers[SubSubMenusList[i]].zIndex = 1;
	}

}


function getClassObj(divName)
{	
  var vers = navigator.appVersion;
  vers = vers.substring(0,1);

  if (navigator.appName=="Netscape" && vers!="4") //(document.getElementById)
        this.style = document.getElementById(divName).className;
  else if (navigator.appName=="Microsoft Internet Explorer") // (document.all)
        this.style = document.all [divName].className;
  else if (navigator.appName=="Netscape" && vers=="4") //(document.layers)
        this.style = document.layers[divName];
  else
	{
	}
 
  return this.style;
}

function getObj(divName)
{	
  var vers = navigator.appVersion;
  vers = vers.substring(0,1);

  if (navigator.appName=="Netscape" && vers!="4") //(document.getElementById)
        this.style = document.getElementById(divName).style;
  else if (navigator.appName=="Microsoft Internet Explorer") // (document.all)
        this.style = document.all [divName].style;
  else if (navigator.appName=="Netscape" && vers=="4") //(document.layers)
        this.style = document.layers[divName];
  else
	{
	}

  return this.style;
}

function visObj(divName, change)
{
  if(change=="hidden")
  {
  	getObj(divName).visibility = change;
  }
  else
  {
    var vers = navigator.appVersion;
    vers = vers.substring(0,1);

    if(navigator.appName=="Netscape" && vers=="4")
    {
 
	getObj(divName).visibility = 'show';
    }
    else	
        getObj(divName).visibility = 'visible';
  }
}

function get_number_by_name(name)
{
//	N6Test();
	
	for(i=0; i<SubMenusList.length; i++)
		if(SubMenusList[i]==name)
			return i;
	return (-1);
	
}

function subsubmenu_get_number_by_name(name)
{
	for(i=0; i<SubSubMenusList.length; i++)
		if(SubSubMenusList[i]==name)
			return i;
	return (-1);
	
}
function submenu_on(my_id)
{
  var n = get_number_by_name(my_id);
  last_open_submenu = n;

  document [barArray[n].imgBarName].src = barArray[n].onImgSrc;   

  visObj(my_id, "visible");	
}
function submenu_off(my_id)
{
  if(last_open_submenu==1 && last_open_subsubmenu>0 && last_open_subsubmenu<7)
  {

  }
  else
  {
  	var n = get_number_by_name(my_id);
  	document [barArray[n].imgBarName].src = barArray[n].offImgSrc;
		
  	visObj(my_id, "hidden");
  }
}

function all_submenu_off()
{
//showImage();	
//alert('all off');
  var i=0;
  for(i=1; i<SubMenusList.length; i++)  
    submenu_off(SubMenusList[i]);	
  last_open_submenu = 0;
}

/*
function hideImage(){
  if (document.layers){
  	
	document.Layer1.visibility="hide"

  }
  else if(document.all||document.getElementById){
  	//alert("here");
	(document.getElementById)?
	nct=document.getElementById("Layer1")
	: nct=document.all.docimage
	nct.style.visibility="hidden";

  }
}

function showImage(){
	
  if (document.layers){
  	
	document.Layer1.visibility="show"

  }
  else if(document.all||document.getElementById){
  	//alert("here");
	(document.getElementById)?
	nct=document.getElementById("Layer1")
	: nct=document.all.docimage
	nct.style.visibility="visible";

  }
  
}
*/
function reshowImage(){
  if (document.layers){
  	
	document.Layer1.visibility="show"

  }
  else if(document.all||document.getElementById){
  	//alert("here");
	(document.getElementById)?
	nct=document.getElementById("Layer1")
	: nct=document.all.docimage
	nct.style.visibility="visible";

  }
}
/*
function moveObjLeft(name, offset)
{
  var o = getObj(name+"space");
  var slen = o.left.length;
  if(browser_name == "IE" || browser_name == "N6")
  {
    var tmp = o.left.substr(0,slen-2);
    tmp = eval(tmp);
    o.left = tmp - offset;
  }
  else
  {
    o.height = o.height - offset;
  }
}

function moveObjUp(name, offset)
{
  if(browser_name == "IE" || browser_name == "N6")
  {
    document.images[name+"space"].height = document.images[name+"space"].height - offset;
  }
  else
  {
alert(document.layers[name].document.images[name+"space"].height-offset);
    document.layers[name].document.images[name+"space"].height = document.layers[name].document.images[name+"space"].height - offset;
  }
}
*/
var moved_once = 0;


function barActOn( bar_num, submenu) 
{	
  visObj("searchform", "visible");
  document [barArray[bar_num].imgBarName].src = barArray[bar_num].onImgSrc;   
 
   if((last_open_submenu>0)&&(last_open_submenu<numOfBars+1))
   {
	document [barArray[last_open_submenu].imgBarName].src = barArray[last_open_submenu].offImgSrc;
   	getObj(SubMenusList[last_open_submenu]).visibility = "hidden";
	
   }
   if((last_open_subsubmenu>0)&&(last_open_subsubmenu<7))
   {
   	getObj(SubSubMenusList[last_open_subsubmenu]).visibility = "hidden";
	SetElClass('l'+SubSubMenusList[last_open_subsubmenu],'menu');
   	last_open_subsubmenu = 100;
   }
   	
   last_open_sub_menu = bar_num;

   visObj(SubMenusList[bar_num], "visible");  
}

function barActOff(bar_num, submenu) {   
   if(browser_name=="N4") 
   {
	document.images[barArray[bar_num].imgBarName].src = barArray[bar_num].offImgSrc;
   }
   else
   {
	   document [barArray[bar_num].imgBarName].src = barArray[bar_num].offImgSrc;
   }
   last_open_submenu = bar_num;
   // document.all [SubMenusList[bar_num]].style.visibility = 'hidden';
   
}

function SetElClass(id, cname)
{
	if(browser_name=="N6")
	{
		document.getElementById(id).className=cname;
	}
	else if(browser_name=="IE")
	{ 
		document.all [id].className=cname;
  	}        
	else if(browser_name=="N4")
	{
		//document.layers[id].className=cname;
	} 
}

function OpenSubSubMenu(name)	
{
//	hideImage();
        visObj("searchform", "hidden");

	submenu_on("academics");
	if(last_open_subsubmenu>0 && last_open_subsubmenu<7)
	{
		getObj(SubSubMenusList[last_open_subsubmenu]).visibility = "hidden";
		SetElClass('l'+SubSubMenusList[last_open_subsubmenu],'menu');
                }
	var num = subsubmenu_get_number_by_name(name);
	last_open_subsubmenu = num;
	//visObj(name, "visible");

	SetElClass('l'+name,'menuo');
	visObj(name, "visible");
}

function CloseSubSubMenu(name)	
{
  visObj("searchform", "visible");
}
	
//----------------  Bar Class -------------------------------------	

function BarClass(num,offSrc,onSrc,/*liveSrc,*/refFile,altTag) {
  // parameters:
  // following lines are of use - if we would want to build ourselves  x3 image source file names 
  this.barNum=num; 
  this.offImgSrc= offSrc;
  this.onImgSrc=onSrc;
  //this.liveImgSrc=liveSrc; 
  this.ref= refFile; 
  this.alt = altTag;			  	   	   		  
  this.imgBarName="bar"+ num; 	//e.g. "bar2"	  
 //methods:
  this.setLive = setLive;						  
  this.display= display;  
  this.submenu = altTag;
}

function setLive()  { // Method of BarClass 
    // set img-src for the entered categoryNum
  this.offImgSrc= this.liveImgSrc;
  this.onImgSrc=this.liveImgSrc;
}

function setNormal() { //Method of BarClass (not in use!) opposite of set live 
  this.offImgSrc= this.srcBaseName + "1" + imgExt;
  this.onImgSrc = this.srcBaseName + "2" + imgExt; 
}

/** Method of BarClass - display the bar with all its features  
 the bar-instance  is displayed with it's according link and according 
 ActOn/Off function (e.g. mouse on/out) in the future may extend 
 to support alt-status. assumes being displayed within table-td already
**/


/*
function display() {
 // have to create act On/off call with the actual barNum
 var actOnCall="barActOn("+ this.barNum + "," + this.submenu + ")" ;   // = barActOn(j)
 var actOffCall="barActOff("+ this.barNum + "," + this.submenu + ")" ; // = barActOff(j)
	  document.write('<a href='); 
	  document.write(this.ref); 
	  document.write(' OnMouseOver=');
 	  document.write(actOnCall); 
	  document.write(' OnMouseOut=');
 	  document.write(actOffCall);  
	  document.write(' >');
  	  document.write(' <img src="');
	  document.write(this.offImgSrc);        //e.g."images/contact1.jpg" ;
	  document.write('" border="0" name= ');
	  document.write(this.imgBarName);
	  document.write(' alt="');
          document.write(this.alt);
          document.write('">');
	  document.write("</a>");
}
*/



function display() {
 // have to create act On/off call with the actual barNum
 var actOnCall="barActOn("+ this.barNum + ",'" + this.submenu + "')" ;   // = barActOn(j)
 var actOffCall="barActOff("+ this.barNum + ",'" + this.submenu + "')" ; // = barActOff(j)
 //alert(this.alt);
//the items in the nav bar that are directly clickable get special treatment
 if( (this.barNum==numOfBars)||(this.barNum==5)||(this.barNum==numOfBars-1) )
 {
	document.write('<a href='); 
	document.write(this.ref); 
	document.write(' OnMouseOver="');
 	document.write(actOnCall); 
	document.write('" OnMouseOut="');	  
 	document.write(actOffCall);   	  
	document.write('" >');
  	document.write(' <img src="');
	document.write(this.offImgSrc);        //e.g."images/contact1.jpg" ;
	document.write('" border="0" name= ');	  
	document.write(this.imgBarName);
	document.write(' alt="');	  
        document.write(this.alt);
        document.write('">');
	document.write("</a>");

 }
else
 {
 	if(browser_name=="N4")
 	{
		document.write('<a href='); 
		document.write(this.ref); 
		document.write(' OnMouseOver="');
 		document.write(actOnCall); 
		document.write('" OnMouseOut="');	  
 		document.write(actOffCall);   	  
		document.write('" >');
  		document.write(' <img src="');
		document.write(this.offImgSrc);        //e.g."images/contact1.jpg" ;
		document.write('" border="0" name= ');	  
		document.write(this.imgBarName);
		document.write(' alt="');	
        	document.write(this.alt);
        	document.write('">');
		document.write("</a>");	
 	}
 	else
 	{
 		var s = '<img src="'+this.offImgSrc+'"  border="0" name="'+this.imgBarName+'" OnMouseOver="'+actOnCall+'" OnMouseOut="'+actOffCall+'" >';
 		document.write(s);              //for check use : alert(s);
 	}
 }
}

function ImgChange(imgNum,imgSrc) 
{
  if(browser_name=="N4")
  {
  }
  else if(browser_name=="IE")
	  document.images[imgNum].src = imgSrc;
  else if(browser_name=="N6")
	document.images[imgNum].src = imgSrc;
  else
	  document.images[imgNum].src = imgSrc;
}

//--------------- Nav Class ---------------------------------------

function NavClass(len) { // NavClass Class declaration
	 this.navLen=len;
	 //methods:
	 this.setBarArray=setBarArray; // bar: barArray[j]=new BarClass(); 
	 this.displayNav=displayNav;   //puts the navagation table frame 
		 		    //and loops over all bar display each
}

function displayNav(categoryNum) { 
// NavClass Method - display navigator in a table
// activate display method for each bar
  var k;
	  for (k=1 ; k <= this.navLen  ; k++)
	  {
	   
	   barArray[k].display();
	   document.write('<br>');
	  
	 }
  
}




















