//browser id code
window.onerror = null;
var bName = navigator.appName;
var bVer = parseInt(navigator.appVersion);
var NS4 = (bName == "Netscape" && bVer >= 4);
var IE4 = (bName == "Microsoft Internet Explorer" && bVer >= 4);
var NS3 = (bName == "Netscape" && bVer < 4);
var IE3 = (bName == "Microsoft Internet Explorer" && bVer < 4);
var menuActive = 0;
var menuOn = 0;
var onLayer;
var timeOn = null;
var navImage = null;

//variables
var galButton = null;
var menuDiv = null;

//functions

/**
 * Add the events to the gallery div and gallery button.
 *
 */
function start() {
   //set the variables
	 galButton = document.getElementById('top_nav_04');
	 menuDiv = document.getElementById('galleries');

   //attach event listeners to the gallery picture
	 if(IE4) {
	    //add topNav button events
	    galButton.attachEvent('onmouseover',menuShow);
			galButton.attachEvent('onmouseout',menuHide);
			//add menu button events
			menuDiv.attachEvent('onmouseover',menuShow);
			menuDiv.attachEvent('onmouseout',menuHide);
	 }
	 if(NS4) {
	    //add topNav button events
	    galButton.addEventListener('mouseover',menuShow,true);
			galButton.addEventListener('mouseout',menuHide,true);
			//add menu button events
			menuDiv.addEventListener('mouseover',menuShow,true);
			menuDiv.addEventListener('mouseout',menuHide,true);
	 }
}
menuClear = '';
/**
 * Show the gallery div.
 * 
 * @param event  The event object that was generated.
 */
function menuShow(event) {
   //set the postion of the menu to the position of the button
	 if(menuClear != '' && menuDiv.style.visibility == 'visible') {
  	 clearTimeout(menuClear);
		 menuClear = '';
	 }
	 else {
	    if(IE4 || NS4) {
  	    //x = parseInt(galButton.offsetLeft) + 20;
  		  //y = parseInt(galButton.offsetTop) + 17;
  			menuDiv.style.top = '85px';
  			menuDiv.style.left = '350px';
  			menuDiv.style.visibility = 'visible';
  	 }
	 }
}

/**
 * Hide the gallery Div.
 *
 * @param  event  The event object that was generated.
 */
function menuHide(event) {
   //set the postion of the menu to the position of the button
	 if(IE4 || NS4) {
	    //x = parseInt(galButton.offsetLeft) + 20;
		  //y = parseInt(galButton.offsetTop) + 17;
			//menuDiv.style.top = y+'px';
			//menuDiv.style.left = x+'px';
			menuClear = setTimeout("menuDiv.style.visibility = 'hidden'",500);
	 }
}
