var selectboxes = null;
var selectboxTimerID = null;
var selectboxTimerRunning = false;


var agt=navigator.userAgent.toLowerCase(); 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);

var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
                && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));

var is_nav6up = (is_nav && (is_major >= 5));

var is_opera = (agt.indexOf("opera") != -1);
var is_opera2 = (agt.indexOf("opera 2") != -1 || agt.indexOf("opera/2") != -1);
var is_opera3 = (agt.indexOf("opera 3") != -1 || agt.indexOf("opera/3") != -1);
var is_opera4 = (agt.indexOf("opera 4") != -1 || agt.indexOf("opera/4") != -1);
var is_opera5 = (agt.indexOf("opera 5") != -1 || agt.indexOf("opera/5") != -1);
var is_opera5up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4);
var is_opera6 = (agt.indexOf("opera 6") != -1 || agt.indexOf("opera/6") != -1);
var is_opera6up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5);
var is_opera7 = (agt.indexOf("opera 7") != -1 || agt.indexOf("opera/7") != -1);
var is_opera7up = (is_opera && !is_opera2 && !is_opera3 && !is_opera4 && !is_opera5&& !is_opera6);

//var is_mac    = (agt.indexOf("mac")!=-1); 

var is_mac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;

window.onload = init;
window.onunload = hidePop;

//a fix for the select-box having infinite z-index in IE.
//TN- updated - fix no longer necessary, commented out the IfrRef references.
function DivSetVisible(state, id)
  {
			
   var DivRef = document.getElementById('quicklinkBox');
  // var IfrRef = document.getElementById('DivShim');
   
   if(state)
   {
   //tried to set these properties to those identical to DivRef,
   //but for some reason I could not get at these values of DivRef.
   //so some of these are static.
  //  IfrRef.style.width = DivRef.offsetWidth;
  //  IfrRef.style.height = DivRef.offsetHeight-40;
  //  IfrRef.style.top = 110;
  //  IfrRef.style.right = 0;
  //  IfrRef.style.zIndex = 1;
	//  IfrRef.style.display = "block";
	
   }
   else
   {
    // IfrRef.style.display = "none";
   }
   
  } 

//if it's IE 5.5 and higher, use an IFRAME behind the quicklinks popup
//if it's navigator 6 or opera 7 or higher do nothing since these browsers
// support layered elements on top of select box
//otherwise, disappear the select box.
function hideSelectBoxes() {
 if (!is_mac){
 	
 if (is_ie5_5up){
	DivSetVisible(true, this.boxName);
 }
	
  else if (!is_nav6up && !is_opera7up) {
	//setIdProperty('SelectMode', 'visibility', 'hidden');
	
	if (document.getElementById && selectboxes != null) {
     for (x = 0; x < selectboxes.length; x++) {
         selectboxes[x].style.visibility="hidden";
     }
    }
 	}
	}
}

function showSelectBoxes() {
  if (!is_mac){
	
  if (is_ie5_5up){ 	
	 DivSetVisible(false, this.boxName);
  }
 
  else if (!is_nav6up && !is_opera7up) {
  	
	  //setIdProperty('SelectMode', 'visibility', 'visible');
	  if (document.getElementById && selectboxes != null) {
        for (x = 0; x < selectboxes.length; x++) {
          selectboxes[x].style.visibility="visible";
        }
     }
	 
  }
}
}






//this part is the same as popupmenu.js

function init() { // Start-up
  setBrowser();  // Initiate DHTML set
  
// Get select boxes so we can hide them while showing pop-up menus
  if (document.getElementById) {
    selectboxes = document.getElementsByTagName("select");
  }
  
}

// Pop-up menu display

function popupMenu(nameToUse) {
  this.boxName = nameToUse;
  this.timerID = null;
  this.timerRunning = false;
  this.show = showPop;
  this.hide = hidePop;
  return this;
}

quicklinks = new popupMenu("quicklinkBox");
toolslinks = new popupMenu("toolslinkBox");

function showPop() {
  if (isNav4) return;
  if (this.timerRunning) {
    clearTimeout(this.timerID);
    timerRunning = false;
  }
  
  // Clear timer to re-show select boxes and then hide them
  if (selectboxTimerRunning) {
    clearTimeout(selectboxTimerID);
    selectboxTimerRunning = false;
  }

  hideSelectBoxes();
  
  setIdProperty(this.boxName, "visibility", "visible");
  
  return true;
}

function hidePop() {
  if (isNav4) return;
  
  if (this.timerRunning) {
    clearTimeout(this.timerID);
  }
  
  if (selectboxTimerRunning) {
    clearTimeout(selectboxTimerID);
  }

  this.timerID = window.setTimeout("setIdProperty('" + this.boxName + "', 'visibility', 'hidden')", 300);
  selectboxTimerID = window.setTimeout("showSelectBoxes()", 300);

  this.timerRunning = true;
  selectboxTimerRunning = true;
  return true;
}
 
	



