﻿/* Calls the closebar() function if clicked on an element with
 * class or id ending with _submit_form_btn.
 * If the jQuery version is greater than 1.7 and this stops working,
 * switch .bind with .on
 * Added on 6.1.2012 by Peter Trobec
*/

/* Date 9.1.2012 - Added the function createCookie in case it isn't 
 * already included.
*/

$(window).load(function () {
    var disablePop = readCookie("disablePopUpAlways");

    $('[id$="_submit_form_btn"]').bind("click", function () {
        createCookie("disablePopUpAlways", 100, 365);
        closebar();
    });
    $('[class$="_submit_form_btn"]').bind("click", function () {
        createCookie("disablePopUpAlways", 100, 365);
        closebar();
    });

    if (!window.createCookie) {
        function createCookie(name, value, days) {
            if (days > 0) {
                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=/";
        }
    };

    if (disablePop == 100) {
        $("#PopUpDiv").hide();
    }
});


