
var gOriginalnav = "nav1"; //default
	
function handleOut(elname) {
// hides all popups, parameter is the div name
// function called on onmouseout of hyperlink parameter

var d = document.getElementById(elname) ;
d.style.left = "-2650px";
num = elname.substr(3,1);
ImgRestore('nav' + num);
var shim = document.getElementById("shim");
shim.style.display = "none";

setActiveT1Navigation();

}
function setLyr(obj1,lyr)
{
   	obj = document.getElementById (obj1) ;
	var newX = findPosX(obj);
	var newY = findPosY(obj);
	
	var x = document.getElementById(lyr);	
	
	var finy = 0;
	var finx = 0;	
	   finx = newX + 5;
	   finy = newY + 38;         	
    if (obj.parentNode.className !== "active")
    {
        //alert(obj.parentNode);
	    obj.parentNode.className = "active";	    
	}
	
	//set final position
	 x.style.top =  finy + 'px';
	 x.style.left = finx + 'px';

	var shim = document.getElementById("shim");
	shim.style.top = finy + 'px';
	shim.style.left = finx + 'px';
	
	try {
	shim.style.width = x.offsetWidth - 20 + "px";
	shim.style.height = x.offsetHeight  + "px" ;
	shim.style.display = "";
	}
	catch (ErrorObject)
	{ }
	
	

	
	 
}
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 ImgRestore(whichnav)
  {
  
      if (whichnav !== gOriginalnav)
      {
        el = document.getElementById(whichnav);
        el.parentNode.className = "";
      }
      
  }

  
  // Sets the active T1 based on the URL.
  // uses YAHOO DOM safe add class method, http://developer.yahoo.com/yui/dom/
  function setActiveT1Navigation() {

      url = location.pathname.toLowerCase();
      
      // need to use document.title for checking for 404 page because the URL still might match other page patterns.
      if (document.title.toLowerCase().indexOf("our apologies") > -1 || url.indexOf("unsubscribe.shtml") > -1 )
      {
        // no T1 highlighted - error page
      }
      // for all other matches, use URL to match a pattern for each T1
      else if ( url.indexOf("claims-service") > -1 )
      {
          YAHOO.util.Dom.addClass("nav3li", "active");
      }
      else if ( url.indexOf("online-service") > -1 )
      {
          YAHOO.util.Dom.addClass("nav4li", "active");
      }
      else if ( url.indexOf("about-us") > -1 )
      {
          YAHOO.util.Dom.addClass("nav5li", "active");
      }
      else if ( url.indexOf("sitemap") > -1 )
      {
        // no T1 highlighted 
      }
      else if ( url.indexOf("information") > -1 || url.indexOf("insurance-quote") > -1 )
      {
          YAHOO.util.Dom.addClass("nav2li", "active");
      }
      else if ( url == "/" || url == "" || url == "/index.shtml" )
      {
          YAHOO.util.Dom.addClass("nav1li", "active");
      }
  }

  
  // Sets the active T2 based on the URL.
  // uses YAHOO DOM safe add class method, http://developer.yahoo.com/yui/dom/
  function setActiveT2NavigationInsuranceProducts() {

      url = location.pathname.toLowerCase();
 
      if ( url.indexOf("home-insurance") > -1 || url.indexOf("homeowners-insurance") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2Home", "active_noSub");
      }
      else if ( url.indexOf("renters-insurance") > -1)
      {
          YAHOO.util.Dom.addClass("navt2Renters", "active_noSub");
      }
      else if ( url.indexOf("rv-insurance") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2Motorhome", "active_noSub");
      }
      else if ( url.indexOf("classic-car-insurance") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2Classic", "active_noSub");
      }
      else if ( url.indexOf("umbrella-insurance") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2Umbrella", "active_noSub");
      }
      else if ( (url.indexOf("auto-insurance") > -1 || url.indexOf("car-insurance") > -1) && url.indexOf("auto-insurance-quotes") < 0 )
      {
          
          if  ( (url.indexOf("-auto-insurance.shtml") > -1 ) && (url.indexOf("ways-to-save-on-auto-insurance.shtml") <= -1 ) )
	  {
          	YAHOO.util.Dom.addClass("navt2Auto", "active");
          	YAHOO.util.Dom.addClass("navt3StateAutoInsurance", "active_noSub");
		setStyle('navt2Autot3Container', 'block', false);
          }
          else 
          {
		YAHOO.util.Dom.addClass("navt2Auto", "activeOn");
		setStyle('navt2Autot3Container', 'block', false);
	            	          	
          }
      }
  }

  
  // Sets the active T2 based on the URL.
  // uses YAHOO DOM safe add class method, http://developer.yahoo.com/yui/dom/
  function setActiveT2NavigationAboutUs() {

      url = location.pathname.toLowerCase();
 
      if ( url.indexOf("community-involvement") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2CommunityInvolvement", "active_noSub");
      }

  }
  
  // Sets the active T2 based on the URL.
  // uses YAHOO DOM safe add class method, http://developer.yahoo.com/yui/dom/
  function setActiveT2NavigationOnlineService() {

      url = location.pathname.toLowerCase();
 
      if ( url.indexOf("contact-us") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2ContactUs", "active_noSub");
      }

  }
  
  // Sets the active T2 based on the URL.
  // uses YAHOO DOM safe add class method, http://developer.yahoo.com/yui/dom/
  function setActiveT2NavigationClaimsService() {

      url = location.pathname.toLowerCase();
 
 	var path = window.location.pathname;
 	var page = path.substring(path.lastIndexOf('/') + 1);

      if ( url.indexOf("auto-insurance-claims") > -1 )
      {
		setStyle('navt2AutoClaimsServicet3Container', 'block', false);
      
		if ( url.indexOf("auto-insurance-claims-services") > -1 )
		{
			YAHOO.util.Dom.addClass("navt2AutoClaimsService", "activeOn");
      		}
      		else
      		{
			YAHOO.util.Dom.addClass("navt2AutoClaimsService", "active");
			switch (page) 
			{
				case 'auto-after-accident.shtml' :
					YAHOO.util.Dom.addClass("navt3AutoAfterAccident", "active_noSub");
					break;
				case 'auto-claims-process.shtml' :
					YAHOO.util.Dom.addClass("navt3AutoClaimsProcess", "active_noSub");
					break;
				case 'auto-glass-claims.shtml' :
					YAHOO.util.Dom.addClass("navt3AutoGlassClaims", "active_noSub");
					break;
				case 'auto-rental-services.shtml' :
					YAHOO.util.Dom.addClass("navt3RentalServices", "active_noSub");
					break;
				case 'auto-repair-network.shtml' :
					YAHOO.util.Dom.addClass("navt3AutoRepairNetwork", "active_noSub");
					break;
				default : ;
			}      			
      			
      		}
      } 
      if ( url.indexOf("homeowners-insurance-claims-services") > -1 )
      {
          YAHOO.util.Dom.addClass("navt2HomeClaimsService", "active_noSub");
      }
      
  }
  
  
    // set display style to 'none' or 'block' or depending on whether want to show or hide div
    // or, will set visibility to 'hidden' or 'visible' if visibilityOnly is set to true
    function setStyle(id, disp, visibilityOnly) {
    
    	if ( visibilityOnly == undefined ) {
    	visibilityOnly = false;
    	}
    
    	if (visibilityOnly == true)
    	{
    		//safe function to hide an element with a specified id
    		if (document.getElementById) 
    		{ // DOM3 = IE5, NS6
    			document.getElementById(id).style.visibility = disp;
    		}
    		else 
    		{
    			if (document.layers) 
    			{ // Netscape 4
    				document.id.visibility = disp;
    			}
    			else 
    			{ // IE 4
    				document.all.id.style.visibility = disp;
    			}
    		}	
    		
    	}
    	else
    	{
    		//safe function to hide an element with a specified id
    		if (document.getElementById) 
    		{ // DOM3 = IE5, NS6
    			document.getElementById(id).style.display = disp;
    		}
    		else 
    		{
    			if (document.layers) 
    			{ // Netscape 4
    				document.id.display = disp;
    			}
    			else 
    			{ // IE 4
    				document.all.id.style.display = disp;
    			}
    		}
    	}
    }
