﻿var lyrTimer;
function handleOut(elname) {
// hides all popups, parameter is the div name
// function called on onmouseout of hyperlink parameter

window.clearInterval(lyrTimer); //Disable the show timer, if active
d = document.getElementById(elname) ;
d.style.left = "-1000px";
}
function doSetLyr(obj1, lyr)
{
    lyrTimer = window.setTimeout ("setLyr('" + obj1 + "','" + lyr + "');",200);
    
}
//function doHandleOut (elname)
//{
//    window.setTimeout ("handleOut('" + elname + "');",1000);
//}
function setLyr(obj1,lyr)
{
    // control the blue popups
    /*
    parameters:
    obj1 - the element to reference location from, generally the hyperlink
    lyr - the DIV to position - the divs are positioned off the page to start, the html is at the top of each page for each div
    help - a flag for the help div
    
    requires the browser.js script for browser detection
    as well as findPosX and findPosY, which find the referenced object's position
     
     function is called on the on mouse over of the hyperlink element
    */
    
	obj = document.getElementById (obj1) ;
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	
	var x = document.getElementById(lyr);
	// variables for final resting place
    var finY ;
    var finX ;
    // change final resting places based on whether working with the top popup or bottom (help) popup
    
	
	// Safari section
	if (BrowserDetect.browser == "Safari")
	{
	  finY = newY + 38;
	  finX = newX ; 	  
        
	}
	else // ie, firefox
	{
	   
	  finY = newY + 38;
	  finX = newX  ; 	    
	  
	}
	
	// Firefox 3 fix
	
	if(BrowserDetect.browser == "Firefox" && BrowserDetect.version == "3")
	{
		finY = newY + 38;
	  finX = newX + 30;
	  }
	//set final position
	 x.style.top =  finY + 'px';
	 x.style.left = finX + 'px';
	 
}
function findPosX(obj)
  { //recursively searches through dom to get x postion
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
  }

  function findPosY(obj)
  {//recursively searches through dom to get y postion
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
  }
