﻿//check to see if pfd base oject is not null
if (typeof (pfd) == 'undefined') {
    pfd = function () { };
}
//add ajax for oject orientation
pfd.common = function () { };

pfd.common.captureEnterKey = function (inputId, enterButtonId) {
    $("#" + inputId).keypress(function (event) {
        if (event.which == 13) {
            if (inputId == "inEmail") {
                var inaddress = document.getElementById('inEmail');
                var inemail = $('#inEmail').val();


                pfd.ajax.persistCustomerEmail(inemail, 'PFD Gas Card', 'emailSuccess');
                var obj = document.getElementById('emailSuccess');
                obj.style.visibility = "visible";
                obj.style.display = "block";

                pfd.display.HidePopup('gasCard');
                return false;
            }
            else { $('#' + enterButtonId).click(); }
        }
    });
};

pfd.common.removeEnterKey = function (inputId) {

    $('#' + inputId).unbind();
};

pfd.common.isValidEmail = function (content) {
    if (content == null) return false;
    var c = $.trim(content);
    var emailReg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return emailReg.test(c);
};

function catchEnter(e, button) {
    var keynum;
    var keychar;
    var numcheck;

    if (window.event) // IE
    {
        keynum = e.keyCode;
    }
    else if (e.which) // Netscape/Firefox/Opera
    {
        keynum = e.which;
    }

    keychar = String.fromCharCode(keynum);
    numcheck = /\d/;

    //return !numcheck.test(keychar);
    if (keynum == 13) {
        $('.' + button).click();
        return false;
    }
}
function showProgress() {
    $('#left').hide();
    $('#Div1').hide();
    $('#AllContent').hide();
    $('#ProgressBar').show();
}

$(function () {
    $.cookie('addtobasket', null, { path: '/' });
    $('.DontWaitBtn').click(function () { showProgress() });
    $('.AddToCart').click(function () { $.cookie('addtobasket', '1', { path: '/' }); });
    $('#addtocart').click(function () { $.cookie('addtobasket', '1', { path: '/' }); });
    $('a[id^=addToCart_]').click(function () { $.cookie('addtobasket', '1', { path: '/' }); });
});

