function pageLoad()
{
    // Add handlers to map the enter key in the autoCheck Box.
    $addHandler($get('divAutoCheck'), 'keypress', AutoCheckKey);
}

function OpenAutoCheck()
{
    url = acUrl.replace("xVINx", $get(txtVINId).value);
    window.open(url,"AutoCheck",
        "width=800,height=650,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no,left=0,top=100,screenX=0,screenY=100,modal=yes");
}

function AutoCheckKey(evt)
{
    // evt is a Sys.UI.DomEvent object
 
    if (mapKeyToAction(evt))
    { 
        OpenAutoCheck();
        setFixValidation();
        return false;
    }
}

function LoadAds(ad1, ad2, ad3, ad4)
{
    var adHeights = [ad1, ad2, ad3, ad4];
    var adDisplay = [false, false, false, false];
    
    if ($get("rContentLeft"))
    {
        var elLeft = $get("rContentLeft").offsetHeight;
        var elRight = $get("rContentRight").offsetHeight;
        var showAd = false;
        
        for (var i = 0; i<4; i++)
        {
            if (adHeights[i] > 0)
            {
                if (elLeft >= (elRight + adHeights[i]))
                {
                    elRight = elRight + adHeights[i];
                    adDisplay[i] = true;
                    showAd = true;
                }
            }
        }
        
        if (showAd)
        {
            Reynolds.CL.Web.WebServices.VehicleFunctions.GetResearchAds(adDisplay[0], adDisplay[1], adDisplay[2], adDisplay[3], WSKey, LoadAdsSuccess, LoadAdsFailure, this);
        }
        else
        {
            hideDIV("adsSpot");
        }
    }
}

function LoadAdsSuccess(result, context)
{
    if (0 < result.length)
    {
        var elAds = $get("adsSpot");
        elAds.innerHTML = result;
        fixIEHeight();
    }
    else
    {
        hideDIV("adsSpot");
    }
}

function LoadAdsFailure(err, context)
{
    hideDIV("adsSpot");
}
