function lib_bwcheck(){ 
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6
  this.mac=this.agent.indexOf("Mac")>-1
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
  return this
}
bw=new lib_bwcheck() //Browsercheck object

function lib_message(txt){alert(txt); return false}

//Lib objects  ********************
function lib_obj(obj,nest){ 
  if(!bw.bw) return lib_message('Old browser')
  nest=(!nest) ? "":'document.'+nest+'.'
  this.evnt=bw.dom? document.getElementById(obj):
    bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;	
  if(!this.evnt) return lib_message('The layer does not exist ('+obj+')' 
    +'- \nIf your using Netscape please check the nesting of your tags!')
  this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; 
  this.ref=bw.dom||bw.ie4?document:this.css.document;
  this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
  this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0
  this.w=this.evnt.offsetWidth||this.css.clip.width||
    this.ref.width||this.css.pixelWidth||0; 
  this.h=this.evnt.offsetHeight||this.css.clip.height||
    this.ref.height||this.css.pixelHeight||0
  this.c=0 //Clip values
  if((bw.dom || bw.ie4) && this.css.clip) {
  this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1); 
  this.c=this.c.split(' ');
  for(var i=0;i<4;i++){this.c[i]=parseInt(this.c[i])}
  }
  this.ct=this.css.clip.top||this.c[0]||0; 
  this.cr=this.css.clip.right||this.c[1]||this.w||0
  this.cb=this.css.clip.bottom||this.c[2]||this.h||0; 
  this.cl=this.css.clip.left||this.c[3]||0
  this.obj = obj + "Object"; eval(this.obj + "=this")
  return this
}


var popTimer = 0;

var menus=new Array();
var indexi=0;

/*
* Show or hide an object or a set of objects having
* a given ID
*/

function switchVisible(ID, v, x, y)
{
  var objArray = new Array();
  var theObj = (bw.ie5||bw.ie6)?document.all[ID]:bw.dom?document.getElementById(ID):bw.ie4?document.all[ID]:bw.ns4?eval(nest+'document.'+ID):0;

  if (theObj != null)  {
 	if (theObj.tagName != null)	{
		objArray[0] = theObj;
	}
	else {
		objArray = theObj;
	}

	for (i=0;  i<objArray.length;i++)
	{
	  if (v == 'visible')
	  {
		  if (x!=null) objArray[i].style.top=y;
		  if (y!=null) objArray[i].style.left=x;
	  }
	  objArray[i].style.visibility=v;
	  objArray[i].style.zIndex=10;
	  // It is enough to force the display
	  // to 'inline' once but we do it every time anyway
	  objArray[i].style.display='inline';
	}

  }

}

/*
* Hide all objects except for those 
* with the given id
*/

function hideAllBut(name)
{
	var cpt=0;
	for (cpt=0; cpt < indexi ;  cpt++)
	{
		if (menus[cpt] != name)
			switchVisible(menus[cpt],'hidden');
	}
	switchVisible ("headSelect", 'visible');	

}

/*
* Shows a menu
*/

function showMenu(n, layerId)
{
	clearTimeout (popTimer);
	var X = parseInt( 110*n - 100 + 10)+'px'; 
	var Y = "116px";
	switchVisible (layerId, 'visible',X,Y);
	hideAllBut(layerId);
	switchVisible ("headSelect", 'hidden');	
}

/*
* When hiding a menu, in fact sets a timer
* to hide ALL menus. If another menu is hovered upon
* the timer will be canceled
*/

function hideMenu()
{
	popTimer = setTimeout('hideAllBut(\'\')', 200);
}
