<!--
//
// popup divs
//   
   
// Turn it on   
function PopupDivOn()
{
   if (this.timerID != 0)
   {
      clearTimeout(this.timerID);
      this.timerID = 0;
   }

   if (this.isBkg)
   	  layer = 2;
   else 
      layer = 5;
   
   this.onCount++;
   
   div = GetElementById(this.divName);
   if (div)
   {
     div.style.visibility = "visible";  
     div.style.zIndex = layer;  	 
   }
   
   // Turn on the "parent button"
   btn = GetElementById(this.btnName);
   if (btn)
   {
      if (!btn.className.match(/-hvr/))
      {
  	  	 this.oldBtnClassName = btn.className;
         btn.className = btn.className.replace(new RegExp("^(\\w+?)\\b"), "$1 $1-hvr");
		// alert(btn.className); 	  
      }
   }   
   
}

// Turn it on, but other popupdivs should go in front
function PopupDivBkg()
{
   this.isBkg = 1;
   this.On();
}

// turn it off
function PopupDivForceOff()
{
   this.onCount = 0;
   div = GetElementById(this.divName);   
   div.style.visibility = "hidden";  
   
   // Turn off the "parent button"
   btn = GetElementById(this.btnName);
   if (btn)
   {
      if (btn.className.match(/-hvr/))
      {
         btn.className = this.oldBtnClassName;
      }
   }      
   
   
}

function PopupDivCloseCB(popupDiv)
{	
   popupDiv.ForceOff();
}

function PopupDivScheduleClose()
{
   if (this.timerID != 0)
   {
      clearTimeout(this.timerID);
      this.timerID = 0;
   }
   
   if (this.onCount > 0)
   {
      this.onCount--;
   }
   
   if (this.onCount == 0)
   {   
      this.timerID = setTimeout("PopupDivCloseCB("+this.name+")", 50);//thousandths of a sec	
	
      div = GetElementById(this.divName);
      div.style.zIndex = "3";  	 // so new ones pop up in front of this
   }   
}

function PopupDiv(popupName, divName, btnName)
{
   this.name = popupName;
   this.divName = divName;
   this.btnName = btnName;
   this.timerID = 0;
   this.onCount = 0;
   this.isBkg = 0;
   this.ForceOff = PopupDivForceOff;   
   
   // API
   this.On = PopupDivOn;
   this.Off = PopupDivScheduleClose;
   this.OnAsBkg = PopupDivBkg;

}

// -->