ResellersAr= new Array("Our Solutions","content.aspx?name=Solutions-World-View-Overview","Our ISV Partners","content.aspx?name=ourisvpartners","Vendor Index","PartnerCenter/VendorIndex.aspx","International Line Card","content.aspx?name=intlinecards","Reseller Testimonials","content.aspx?name=testimonials_resellers","Become a Reseller","content.aspx?name=becomereseller","Service Desk","HelpDesk.aspx?name=default")
SoftwareVendorsAr= new Array("Why a Channel?","content.aspx?name=WhyChannel","Our Reseller Network","content.aspx?name=ourspnetwork","Our Solutions","content.aspx?name=Solutions-World-View-Overview","Vendor Testimonials","content.aspx?name=testimonials_vendors","Become Vendor Partner","content.aspx?name=becomevendorpartner","Our Channel Services","content.aspx?name=ChannelServices")
SolutionsAr= new Array("Application Lifecycle","content.aspx?name=ALM-World-View-Products","Network Infrastructure","content.aspx?name=Network-World-View-Products","Virtualization","content.aspx?name=Virtualization-World-View-Products","Security","content.aspx?name=Security-World-View-Products")
AboutLifeboatAr= new Array("News & Events","content.aspx?name=newsandevents","Careers","content.aspx?name=careers","Contact Us","HelpDesk.aspx?name=contact","Directions","HelpDesk.aspx?name=directions")
var menuAr = new Array("Resellers",ResellersAr,"SoftwareVendors",SoftwareVendorsAr,"Solutions",SolutionsAr,"AboutLifeboat",AboutLifeboatAr)
var noMenuAr = new Array("ServiceDesk")
var MainMenu = new Array();
var Timer = null;
var Root = "http://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 = "";
  }
}
