// JavaScript Document
/*window popup*/
function openPopup (theURL, winName, features) { //v2.0
    var RegExp_Width = new RegExp("width=[0-9]*", "g");
    var RegExp_Height = new RegExp("height=[0-9]*", "g");
    var width = features.match(RegExp_Width).toString().match(/[0-9]+/);
    var height = features.match(RegExp_Height).toString().match(/[0-9]+/);
    features = features + " , top=" + getTopPos(height) + ", left=" + getLeftPos(width);
    window.open(theURL, winName, features);
}
function getLeftPos (width) {
    var screenWidth = screen.availWidth;
    return Math.round( (screenWidth - width)/2 );
}
function getTopPos (height) {
    var screenHeight = screen.availHeight;
    return Math.round( (screenHeight - height)/2 );
}

/*benefit flyerbox*/
$(document).bind("ready", function () {
    $(".CallBenefitFlyerBox").each(function (index) { //CLICK INTO BOX
        var handler = $(this);
        handler.bind("click", function (evt) {
            showBenefit(handler.attr("rel"));
            return false;
        });
    });
    $(".CloseFlyerBoxBtn").each(function () {
        var handler = $(this);
        handler.bind("click", function (evt) {
            hideBenefit(true);
            return false;
        });
    });
    $(".OpenBenefitPopupBtn").each(function (index) {
        var handler = $(this);
        handler.bind("click", function (evt) {
            openPopup("popin-long-a.html#"+handler.attr("rel"), "", "width=715, height=600, scrollbars=yes");
            return false;
        });
    });
});

