WhyLifeboatAr= new Array("For Resellers","content.aspx?name=whyforresellers","For Vendors","content.aspx?name=whyforvendors","News","content.aspx?name=newsandevents","Subscriptions","secure/subscribe.aspx","Feedback","content.aspx?name=feedback")
InternationalAr= new Array("Become a Reseller Partner","content.aspx?name=intresellerpartner","Become a Vendor Partner","content.aspx?name=intbecomevendorpartner","Int'l Line Card","content.aspx?name=intlinecards","Worldwide Marketing","content.aspx?name=intworldwidemarketing","Sales/Contact Info","content.aspx?name=intsalesinfo","Payment/Ordering Info","content.aspx?name=intpaymentorderinginfo")
DomesticAr= new Array("Become a Reseller Partner","content.aspx?name=domesticresellerpartner","Become a Vendor Partner","content.aspx?name=domesticvendorpartner","Line Card","content/images_lbus/2007_files/LineCard.pdf","Sales/Contact Info","content.aspx?name=domesticsalesinfo","Marketing Info","content.aspx?name=domesticmarketing","Payment/Ordering Info","content.aspx?name=domesticpaymentorderinginfo")
HowToBuyAr= new Array("Ordering Products","content.aspx?name=orderingproducts")
ContactUsAr= new Array("Contact Info","HelpDesk.aspx?name=contact","Need Help?","HelpDesk.aspx?name=default","Business Hours","HelpDesk.aspx?name=hours","Office Directions","about.aspx?name=directions","Mailing List/Catalog","subscriptions/preferences.aspx")
var menuAr = new Array("WhyLifeboat",WhyLifeboatAr,"International",InternationalAr,"Domestic",DomesticAr,"HowToBuy",HowToBuyAr,"ContactUs",ContactUsAr)
var noMenuAr = new Array()
var MainMenu = new Array();
var Timer = null;
var Root = "http://www.lifeboatdistribution.com/";

// Build Main Menu from Array
for (var i=0;i<menuAr.length;i+=2)
{
     MainMenu[menuAr[i]] = menuAr[i+1];
} 

function BuildSubMenu(MenuName)
{
    MenuItems =  new Array();
    MenuItems = MainMenu[MenuName];
    
    BuildTableHeader();
    for (var i=0;i<MenuItems.length;i+=2)
    {
       BuildTableLineItem(MenuItems[i],Root+MenuItems[i+1]);
    }
    BuildTableFooter();
}

function BuildTableHeader()
{
    document.write("<table cellpadding=\"0\" cellspacing=\"0\" class=\"SubMenuTable\" >");
}

function BuildTableLineItem(ItemName, ItemLink)
{
    document.write("<tr><td><div align=\"left\" class=\"SubMenuCell\" OnMouseOver=\"ChangeStyle(this,'SubMenuCellHover')\" OnMouseOut=\"ChangeStyle(this,'SubMenuCell')\" OnClick=\"GoToUrl('"+ItemLink+"')\">");
    document.write("<a class=\"SubMenuLink\" href=\""+ItemLink+"\">"+ItemName+"</a></div></td></tr>");
}
function BuildTableFooter()
{
    document.write("</table>");
}

function ChangeStyle(Container,StyleName)
{
    Container.className=StyleName;
}

function GoToUrl(URL)
{
    window.location.href=URL;
}

function ShowSubMenu(MenuItem, Container)
{
    HideAllSubMenus();
    ChangeStyle(Container,"MainMenuHover");
    if(document.getElementById != null)
    {
        ObjectToShow = document.getElementById(MenuItem);
        if (ObjectToShow != null)      
        {
            SetSubMenuPosition(Container, MenuItem);
            BrowserStyleObject(MenuItem).visibility="visible";
        }   
       ActivateMenu();       
    }
}

function ShowHidePageControls(ShowHide, cPosX)
{
  PageControl=document.getElementById("ctl00$MainContent$PublisherFilterDropDownList");
	if (PageControl != null)
	{
		// page contains one control
		_xPos = PageControl.offsetLeft+GetContainerPositionX(PageControl.offsetParent)+ BrowserDeltaPosition("x");
		if (cPosX>=_xPos-5 && cPosX<(_xPos+150))
			BrowserStyleObject("ctl00$MainContent$PublisherFilterDropDownList").visibility=ShowHide;
		else
			BrowserStyleObject("ctl00$MainContent$PublisherFilterDropDownList").visibility='visible';
	}
   	
  PageControl2=document.getElementById("ctl00$MainContent$CategoryFilterDropDownList");
	if (PageControl2 != null)
	{
		// page contain a second control show/hide this control		
		_xPos = PageControl2.offsetLeft+GetContainerPositionX(PageControl2.offsetParent)+ BrowserDeltaPosition("x");
		if (cPosX>=_xPos-5 && cPosX<(_xPos+150))
			BrowserStyleObject("ctl00$MainContent$CategoryFilterDropDownList").visibility=ShowHide;		
		else
			BrowserStyleObject("ctl00$MainContent$CategoryFilterDropDownList").visibility='visible';		
	}
  
  
}

function ShowNoMenu(MenuItem, Container)
{
    HideAllSubMenus();
    ChangeStyle(Container,"MainMenuHover");
    ActivateMenu();
}

function ActivateMenu()
{
    if(!document.getElementById) 
		return;
		
	clearTimeout(Timer)
	Timer = null;	
}

function HideWithDelay()
{
    if(document.getElementById) 
	{
        if(Timer == null)
	    	Timer = setTimeout("HideAllSubMenus()", 400);
	}
}

function HideAllSubMenus()
{
    if(document.getElementById != null)
    {
		ShowHidePageControls("visible",0);
        for(var i=0;i<menuAr.length;i+=2)
        {
            ObjectToHide = document.getElementById(menuAr[i]);
            ObjectToUnhover = document.getElementById("M_"+menuAr[i]);
            if (ObjectToHide != null)      
            {
                BrowserStyleObject(menuAr[i]).visibility='hidden';
                ChangeStyle(ObjectToUnhover,"MainMenu");
            }   
        }
        
        for(var r=0;r<noMenuAr.length;r++)
        {
			ObjectToUnhover = document.getElementById("M_"+noMenuAr[r]);
            if (ObjectToUnhover != null)      
            {
                ChangeStyle(ObjectToUnhover,"MainMenu");
            }  
        }
    }
}

function SetSubMenuPosition(MenuContainer, MenuObject)
{
    xPos=MenuContainer.offsetLeft+GetContainerPositionX(MenuContainer.offsetParent)+ BrowserDeltaPosition("x");
    yPos=MenuContainer.offsetTop+GetContainerPositionY(MenuContainer.offsetParent)+ BrowserDeltaPosition("y");
    
   //window.alert("X-pos: "+xPos+"\nY-pos: "+yPos);
   ShowHidePageControls("hidden",xPos);
    
	BrowserStyleObject(MenuObject).left =xPos+"px";
    BrowserStyleObject(MenuObject).top = yPos+"px";
}

function GetContainerPositionX(Container)
{
    if(Container.offsetParent != null)
		return(Container.offsetLeft + GetContainerPositionX(Container.offsetParent));
	else
		return(0);
}

function GetContainerPositionY(Container)
{
    if(Container.offsetParent != null)
		return(Container.offsetTop + GetContainerPositionY(Container.offsetParent));
	else
		return(0);
}

function BrowserStyleObject(MenuItem) 
{
    // cross-browser style object
    if(document.getElementById && document.getElementById(MenuItem)) 
    {
		return document.getElementById(MenuItem).style; // Default: W3C
    } 
    else if (document.all && document.all(MenuItem)) 
    {
		return document.all(MenuItem).style;  // IE4 
    } 
    else if (document.layers && document.layers[MenuItem]) 
    {
		return document.layers[MenuItem]; // NS4  
    } 
    else 
    {
		return false;
    }
}

function BrowserDeltaPosition(pos)
{
    var dX, dY
    if(navigator.userAgent.indexOf("Firefox") != -1)
    {
       dX=0;
       dY=26
    }
    else if(navigator.userAgent.indexOf("MSIE") != -1)
    {
       dX=0;
       dY=26
    }
    else if(navigator.userAgent.indexOf("Netscape") != -1)
    {
       dX=0;
       dY=26
    }
    else
    {
       dX=0;
       dY=26
    }
    
    if (pos=="x")
        return dX;
    else
        return dY;
}

function CheckSearchField(SearchField)
{
  if (SearchField.value == "Product, Brand or Part Number")
  {
	document.forms[0].ctl00_txtSearchPhrase.value = "";
  }
}
