/**************************************** JQUERY MODAL WITH COOKIE **********************************/
(function ($) {
    $.fn.centermodal = function (modalwdt, modalhgt, clslnk, bodycont) {
        return this.each(function () {
            var modalpop = $(this);
            var modalclose = $(clslnk); /** ie6 hack for select dropdowns **/
            if ($.browser.msie && $.browser.version == "6.0") {
                $("select").css({
                    visibility: "hidden"
                });
                $(bodycont).css({
                    display: "none"
                });
            }
            modalpop.css({
                width: modalwdt + 'px',
                height: modalhgt + 'px',
                position: 'absolute',
                top: ($(window).height() - modalhgt) / 4 + $(window).scrollTop() + "px",
                left: ($('body').width() / 2) - (modalwdt / 2) + "px"
            });
            modalpop.fadeIn("slow");
            modalclose.click(function () {
                modalpop.fadeOut('slow', function () {
                    modalpop.remove();
                    $(bodycont).remove(); 
                    /** ie6 hack for select dropdowns **/
                    if ($.browser.msie && $.browser.version == "6.0") {
                        $("select").css({
                            visibility: "visible"
                        });
                    }
                });
            })
            $(bodycont).click(function () {
                modalpop.fadeOut('slow', function () {
                    modalpop.remove();
                    $(bodycont).remove(); 
                    /** ie6 hack for select dropdowns **/
                    if ($.browser.msie && $.browser.version == "6.0") {
                        $("select").css({
                            visibility: "visible"
                        });
                    }
                });
            })
        });
    }
})(jQuery);

function getModalcookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return ""
}

function setModalcookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : "; expires=" + exdate.toUTCString());
}

function modalpop(wdt, hgt, targt, contdv, cookiename, cookievalue, cookielength, closebutton, bgclose, mainCont) {
    popup_efc_modal = getModalcookie(cookiename);
    if (popup_efc_modal != null && popup_efc_modal != "") {} else {
        var D = $(mainCont).height();
        var E = $(mainCont).width();
        $('body').append('<div class="overlaybg" style=" height:' + D + 'px;"></div>');
        $('body').append(contdv)
        $(targt).centermodal(wdt, hgt, closebutton, bgclose);
        setModalcookie(cookiename, cookievalue, cookielength);
    }
}

/****************************************************** HOW TO CALL **********************************
<script>
$(document).ready(function () {
modalpop(300, 300, '#modalemailpop', '<div id="modalemailpop"><h2 class="fauxh3">Important notice regarding signing in to your account</h2><span class="cls"></span><div class="modalcont">We have just made a change to the way you sign into eFinancialCareers.<hr/>From now on, you will need to sign in with your <span class="emladd">email address</span>, not with your username. <hr/>Usernames will no longer be in use. We hope that this will simplify your access to our network. <hr/>If you experience any problems signing into your online account, please <a href="http://www.test.efinancialcareers.com/contactus.htm" class="emladd">Contact Us</a><hr/><button class="efcButton cls"><span>Close</span></button></div></div>', 'popup_efc_modal', 'visit', 60000, ".cls", '.overlaybg', '#efcHolder');
}); 
</script>
*********************************************************** END CALL ******************************/




