// JScript File
/// <reference path="../jquery/jquery.js"/>
var bPopOffer = true;
var iSubmitCount = 0;
var AccuracyValidationPassed = true;

$(document).ready(function () {
    BindCallCenterAlertEvents()

    if ($(".HilightInaccurateField").length > 0) {
        AccuracyValidationPassed = false;
    }

    if ($(".ShowSessionTimeOutWarning").val() == "1") {
        alert("You seem to have been inactive for some time, please verify the information you entered. You may be asked to re-enter sensitive information.");
    }

    if ($(".FireValidatorsOnReady").val() == "1") {
        Page_ClientValidate();
    }
});


function BindCallCenterAlertEvents() {
    var $CallCenterAlertTrigger;
    var $CallCenterAlert;
    var CallCenterTrackingPixelSrc;

    $CallCenterAlert = $("div[id$='CallCenterAlert']")
    $CallCenterAlertTrigger = $("#CallCenterAlertTrigger")

    if ($CallCenterAlert.length > 0 && $CallCenterAlertTrigger.length > 0) {
        $CallCenterAlertTrigger.mouseover(function () {
            openJqModal2(600, 702, $CallCenterAlert.attr("id"), '', true);
            //Set the src attribute of the tracking pixel to cause the browser to GET the tracking pixel.
            $("#CallCenterTrackingPixel").attr("src", $("#CallCenterTrackingPixelSrc").val());
            //Only show the popup once. Remove the event binding.
            $CallCenterAlertTrigger.unbind("mouseover");
        });
    }
}

function SetCancelPops() 
{ 
    var anchors = document.getElementsByTagName("A");
    for(var i=0; i<anchors.length; i++)
    {  if (anchors[i].onclick == null){  anchors[i].onclick =  function() {CancelPop(true);} }  }
    anchors = document.getElementsByTagName("MAP"); //do the same for maps
    for(var i=0; i<anchors.length; i++)
    { if (anchors[i].onclick == null) { anchors[i].onclick = function() { CancelPop(true); } } }
    ResetPop();
} 

//this is for the offers pop up

function CancelPop(bReset)
{
	bPopOffer = false;
	if (bReset == true) window.setTimeout('ResetPop()', 3000);
}
function ResetPop()
{
	bPopOffer = true;
}
function PopOffer(sOffer)
{
    if (!bPopOffer) return; //exit
    bPopOffer = false;
    var ctl = $("body");
    var oldColor = ctl.css('background-color');
    ctl.html('<center><iframe src="' + sOffer + '" scrolling="no" frameborder="0" allowtransparency="true" marginheight="0" marginwidth="0" id="iframe1" height="1650" width="974" style="margin:0 auto"></iframe></center>');
    ctl.css('background', oldColor);
    alert("Don't Leave! We have more options for you!\n\nJust click \'CANCEL\' on the next window!");
    return "\nPress 'CANCEL' to view options!\n";
}
function addFrameie6bug(x, y, w, h)
{
    $("<iframe id='blankie6frame' src='/blank.htm'></iframe>").css({left:x + 'px',top:y + 'px', width: w, height: h}).appendTo('body');
}
function removeFrameie6bug()
{
    $('#blankie6frame').remove();
}




