﻿function handleOut(elname) {
// hides all popups, parameter is the div name
// function called on onmouseout of hyperlink parameter

d = document.getElementById(elname) ;
d.style.left = "-650px";
}
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);
	
	
	tool = x.getElementsByTagName("div");
    temp = tool[0].className;        
    tool[0].className = temp.replace("_flip","");
	
	
	// get the width of the screen
	var winWidth = (typeof(window.innerWidth) != 'undefined') ? window.innerWidth + self.pageXOffset - 20 : document.documentElement.clientWidth + document.documentElement.scrollLeft;
	// get the top
	var winTop =  document.documentElement.scrollTop;
    
    // 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
    finY = (newY - 73) ;    
	// set the default x
	
	if (lyr == 'popup2')
	{
	    finY = (newY - 209);
	}
	
	finX = (newX - 62) ;
	if ((lyr == 'popup4') || (lyr == 'popup5'))
	{
	    finX = finX - 54;
	}
	
	// Safari section
	if (BrowserDetect.browser == "Safari")
	{
	    //safari uses the below property for getting the distance to the top of the page
	   winTop = self.pageYOffset ;
	   
	 
		if (winWidth < 475) // if the window is sized this size
	    {
        finX = (newX -125);	    // move the object to the left
	    }				
		   
        if (winTop > 200)   // flip it over if at bottom of page
        {       
        finY = (newY + 30) ; 
        }       
        
	}
	else // ie, firefox
	{
	    
	    if (winWidth < 375) // flip to the other side
	    {
        finX = (newX -125);	    
	    }
	    
	  //alert(winTop);
       if (winTop > 200) // flip over if near top of page
       {       
       finY = (newY + 30) ;       
        tool = x.getElementsByTagName("div");
        temp = tool[0].className;        
        tool[0].className = temp + "_flip";
        
       }
      	    
	  
	}
	
	// Firefox 3 fix
	
	if(BrowserDetect.browser == "Firefox" && BrowserDetect.version == "3")
		finY+=170;
	
	//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;
  }
  function getPage()
   {

       var spath = window.location.href ;
       var sdomain = document.domain ;
       spath = spath.replace(sdomain,"");
       spath = spath.replace("http://","");
	   return spath;

    }

