// start: setup basic env vars
var isHTTPS = (("https:" == document.location.protocol) ? true : false);
// end: setup basic env vars

$(document).ready(function() {
    $(".liAcc").click(function(){
        $(".liAcc").find("ul").hide();
        $(".liAcc").removeClass("liAccDown");
        $(this).find("ul").show();
        $(this).addClass("liAccDown");
    });

    if (!isHTTPS) {
        // we load these after the document is ready to avoid a slow loading page.
      // $.getScript("http://js-kit.com/ratings.js");
        $.getScript("http://js-kit.com/comments.js");
    }

    // make sure the input field for the nav searc doesn't submit the page.
    $('#navSearchInput').keypress(function(e) {
        if (e.which == 13) {
            window.location.href='/Search.aspx?k=' + escape($('#navSearchInput').val());
            return false;
        }
    });
});

function obMail(recip,dmn,ext,sbjct) {
    window.location.href = "mailto:" + recip + "@" + dmn + "." + ext +"?Subject=" + sbjct;
}

function popUpWin(url,windowName, windowOptions) {
    windowName = window.open(url,windowName,windowOptions);
    windowName.focus();
}

function buyProduct(qField, pField) {
    showExitPopup = false;
    var q = $('#' + qField).val() || 1;
    var p = $('#' + pField).val() || 0;
    window.location.href = "/BuyProduct.ashx?p=" + p + "&q=" + q;
}

function hasPOBox(str) {
    var poBox = /.*[p]{1}[. ]*[o]{1}[. ]*[ ]*[b]{1}[o]{1}[x]{1}.*/ig;
    return poBox.test(str);
}

// start: basic cookie methods
function _set_cookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function _get_cookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return '';
}

function _delete_cookie(name) {
    _set_cookie(name, "", -1);
}
// end: basic cookie methods