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 LoadAds(ad1, ad2, ad3)
{
    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");
}
