// CAL-41 - AutoPrint & Exit Disclaimer on coupon redemption page
$(document).ready(function(){
    if (document.location.href.indexOf('/coupon/redeem') >= 0) {
        //CAL-41 Hide Header and Top Nav
        $("div#header").hide();
        $("div.nav").hide();
        
        // CAL-41 - Initiate page print on load; wait a second first
        //setTimeout(function() {window.print();}, 1000);

        // CAL-41 - Exit Disclaimer on coupon redemption page
        $("body.not-front a").click(function() {
            var href=$(this).attr("href");
            if (href.indexOf("javascript:")>=0) {
                return true;
            }
            var messageHtml = "<div class=\"exitPopup\">";
            messageHtml += "<p>Thank you for viewing the Caldesene Coupon.</p>";
            messageHtml += "<p>By clicking 'Continue', you will be taken to another page on the site. Please note, once leaving this page you will no longer be able to access the coupon.</p>";
            messageHtml += "<p><a href=\"" + href + "\" target=\"_blank\" onclick=\"closePopup();\">Continue</a>";
            messageHtml += " &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ";
            messageHtml += "<a href=\"javascript:closePopup();\">Cancel</a></p>";
            messageHtml += "</div>";

            jQuery.blockUI({
                message: messageHtml,

                css: {
                  width:          '590px',
                  padding:        '10px',
                  margin:         0,
                  color:          '#333',
                  textAlign:      'left',
                  border:         '1px solid #999',
                  backgroundColor:'#fff',
                  cursor:         'wait'
                },

                // styles for the overlay
                overlayCSS:  {
                  backgroundColor:'#000',
                  opacity:        '0.1'
                }
            });
            return false;
        });
    }
});
function closePopup() {
    jQuery.unblockUI();
}
