function pageLoad()
{
    // The code behind sets this boolean in cases where we need to prompt for a zip code.
    if(('undefined' != typeof(zipPrompt)) && zipPrompt)
    {
        PromptForZip();
    }
}

function PromptForZip()
{
    zipPromptVar.Open("", ZipPromptOnSearch, "", ZipPromptOnCancel);
}

function ZipPromptOnSearch(sZip)
{
    navigateTo(window.location.href + "_zip_" + sZip);
}

function ZipPromptOnCancel()
{
    navigateTo(homepage);
}

function setListItemHeights()
{
    //ADVERTISEMENTS:  
    //Upon finishing this function, call the function to load Ads
    
    //THIS FUNCTION:
    //different length model names can affect the way the list items
    //wrap onto new lines.  This function should fix this issue by 
    //making all list items the same height.
    //Style rules by default make the list items a little too tall to prevent 
    //major display issues from being seen before this function runs.
    //The first part of this function over-writes the default heights,
    //then new heights are found and added.
    
    var itemCount = 0;
    
    for (i=1; i<1000; i++)
    {
        if ($get('modelListItem' + i))
        {
            itemCount = itemCount + 1;
        }
        else
        {
            break;
        }
    }
    
    var itemArray = new Array(itemCount);
    for (i=0; i<itemCount; i++)
    {
        itemArray[i] = $get('modelListItem' + (i + 1));
    }
    
    //reset heights
    for (i=0; i<itemCount; i++)
    {
        if ($get('hiddenIE6'))
        {
            itemArray[i].style.height = "1px";
        }
        else
        {
            itemArray[i].style.minHeight = "1px";
        }
    }
    
    //find max height
    var maxHeight = 0;
    for (i=0; i<itemCount; i++)
    {
        if (maxHeight < itemArray[i].offsetHeight)
        {
            maxHeight = itemArray[i].offsetHeight;
        }
    }
    
    //adjust for padding
    maxHeight = maxHeight - 19;
    
    //set new heights
    for (i=0; i<itemCount; i++)
    {
        if ($get('hiddenIE6'))
        {
            itemArray[i].style.height = maxHeight + "px";
        }
        else
        {
            itemArray[i].style.minHeight = maxHeight + "px";
        }
    }
    
    fixIEHeight();
    LoadAds();
}

function LoadAds()
{
    var adHeights = [ad1, ad2, ad3];
    var adDisplay = [false, false, false];
    
    if ($get("landingOuter"))
    {
        var elLeft = $get("landingLeft").offsetHeight + 239;
        var elOuter = $get("landingOuter").offsetHeight;
        var showAd = false;
        var verticle = false;
        
        for (var i = 0; i<3; i++)
        {
            if (adHeights[i] > 0)
            {
                if (elOuter >= (elLeft + adHeights[i]))
                {
                    elLeft = elLeft + adHeights[i];
                    adDisplay[i] = true;
                    verticle = true;
                }
                showAd = true;
            }
        }
        
        if (showAd && !verticle)
        {
            //Ads need to show, but no room vertically
            //Pass back all three ads as visible
            for (var j = 0; j<3; j++)
            {
                adDisplay[j] = true;
            }
        }
        
        if (verticle)
        {
            Reynolds.CL.Web.WebServices.VehicleFunctions.GetLandingAds(adDisplay[0], adDisplay[1], adDisplay[2], "verticle", WSKey, LoadVertAdsSuccess, LoadAdsFailure, this);
        }
        else if (showAd)
        {
            Reynolds.CL.Web.WebServices.VehicleFunctions.GetLandingAds(adDisplay[0], adDisplay[1], adDisplay[2], "horizontal", WSKey, LoadHorzAdsSuccess, LoadAdsFailure, this);
        }
        else
        {
            hideDIV("adSideDiv");
            hideDIV("adHorzDiv");
        }
    }
}

function LoadVertAdsSuccess(result, context)
{
    if (0 < result.length)
    {
        var elAds = $get("adSideDiv");
        hideDIV("adHorzDiv");
        showDIV("adSideDiv");
        elAds.innerHTML = result;
        fixIEHeight();
    }
    else
    {
        hideDIV("adSideDiv");
        hideDIV("adHorzDiv");
    }
}

function LoadHorzAdsSuccess(result, context)
{
    if (0 < result.length)
    {
        var elAds = $get("adHorzDiv");
        hideDIV("adSideDiv");
        showDIV("adHorzDiv");
        elAds.innerHTML = result;
        fixIEHeight();
    }
    else
    {
        hideDIV("adSideDiv");
        hideDIV("adHorzDiv");
    }
}

function LoadAdsFailure(err, context)
{
    hideDIV("adSideDiv");
    hideDIV("adHorzDiv");
}
