/***************************/
//@Author: Adrian "yEnS" Mato Gondelle
//@website: www.yensdesign.com
//@email: yensamg@gmail.com
//@license: Feel free to use it, but keep this credits please!
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;

var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
        //loads popup only if it is disabled
        if(popupStatus==0){
                $("#backgroundPopup").css({
                        "opacity": "0.7"
                });
                $("#backgroundPopup").fadeIn("fast");
                $("#popupWindow").fadeIn("fast");
                popupStatus = 1;
        }
}

//disabling popup with jQuery magic!
function disablePopup(){
        //disables popup only if it is enabled
        if(popupStatus==1){
                $("#backgroundPopup").fadeOut("fast");
                $("#popupWindow").fadeOut("fast");
                popupStatus = 0;
        }
}

//centering popup
function centerPopup(){
        //request data for centering
        var windowWidth = document.documentElement.clientWidth;
        var windowHeight = document.documentElement.clientHeight;
        var popupHeight = $("#popupWindow").height();
        var popupWidth = $("#popupWindow").width();
        //centering
        $("#popupWindow").css({
                "position": "absolute",
                "top": windowHeight/2-popupHeight/2,
                "left": windowWidth/2-popupWidth/2
        });
        //only need force for IE6

        $("#backgroundPopup").css({
                "height": windowHeight
        });

}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){

        //LOADING POPUP
        //Click the button event!
        $("#popupTrigger").click(function(){
                //centering with css
                centerPopup();
                //load popup
                loadPopup();
        });

        //CLOSING POPUP
        //Click the x event!
        $("#popupWindowClose").click(function(){
                disablePopup();
        });
        //Click out event!
        $("#backgroundPopup").click(function(){
                disablePopup();
        });
        //Press Escape event!
        $(document).keypress(function(e){
                if(e.keyCode==27 && popupStatus==1){
                        disablePopup();
                }
        });

});

/*************************************************************/

var popupStatus2 = 0;
//loading popup with jQuery magic!
function loadPopup2(){
        //loads popup only if it is disabled
        if(popupStatus2==0){
                jQuery("#backgroundPopup2").css({
                        "opacity": "0.7"
                });
                jQuery("#backgroundPopup2").fadeIn("fast");
                jQuery("#popupSubscribe").fadeIn("fast");
                popupStatus2 = 1;
        }
}

//disabling popup with jQuery magic!
function disablePopup2(){
        //disables popup only if it is enabled
        if(popupStatus2==1){
                jQuery("#backgroundPopup2").fadeOut("fast");
                jQuery("#popupSubscribe").fadeOut("fast");
                popupStatus2 = 0;
        }
}

//centering popup
function centerPopup2(){
        //request data for centering
        var windowWidth2 = document.documentElement.clientWidth;
        var windowHeight2 = document.documentElement.clientHeight;
        var popupHeight2 = jQuery("#popupSubscribe").height();
        var popupWidth2 = jQuery("#popupSubscribe").width();
        //centering
        jQuery("#popupSubscribe").css({
                "position": "fixed",
                "top": windowHeight2/2-popupHeight2/2,
                "left": windowWidth2/2-popupWidth2/2
        });
        //only need force for IE6

        jQuery("#backgroundPopup2").css({
                "height": windowHeight2
        });

}

//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){

        //LOADING POPUP
        //Click the button event!
        jQuery(".button-trigger").click(function(){
                //centering with css
                centerPopup2();
                //load popup
                loadPopup2();
        });

        //CLOSING POPUP
        //Click the x event!
        jQuery("#popupSubscribeClose").click(function(){
                disablePopup2();
        });
        //Click out event!
        jQuery("#backgroundPopup2").click(function(){
                disablePopup2();
        });
        //Press Escape event!
        jQuery(document).keypress(function(e){
                if(e.keyCode==27 && popupStatus2==1){
                        disablePopup2();
                }
        });

});


/*************************************************************/

var popupStatus3 = 0;
//loading popup with jQuery magic!
function loadPopup3(){
        //loads popup only if it is disabled
        if(popupStatus3==0){
                jQuery("#backgroundPopup3").css({
                        "opacity": "0.3"
                });
                jQuery("#backgroundPopup3").fadeIn("fast");
                jQuery("#popupCart").fadeIn("fast");
                popupStatus3 = 1;
        }
}

//disabling popup with jQuery magic!
function disablePopup3(){
        //disables popup only if it is enabled
        if(popupStatus3==1){
                jQuery("#backgroundPopup3").fadeOut("fast");
                jQuery("#popupCart").fadeOut("fast");
                popupStatus3 = 0;
        }
}

//centering popup
function centerPopup3(){
        //request data for centering
        var windowWidth3 = document.documentElement.clientWidth;
        var windowHeight3 = document.documentElement.clientHeight;
        var popupHeight3 = jQuery("#popupCart").height();
        var popupWidth3 = jQuery("#popupCart").width();
        //centering
        jQuery("#popupCart").css({
                "position": "fixed",
                "top": windowHeight3/2-popupHeight3/2,
                "left": windowWidth3/2-popupWidth3/2
        });
        //only need force for IE6

        jQuery("#backgroundPopup3").css({
                "height": windowHeight3
        });

}

//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){

        //LOADING POPUP
        //Click the button event!
        jQuery(".addtocart").click(function(){
                //centering with css
                centerPopup3();
                //load popup
                loadPopup3();
        });

        //CLOSING POPUP
        //Click the x event!
        jQuery(".popupCartClose").click(function(){
                disablePopup3();
        });
        //Click out event!
        jQuery("#backgroundPopup3").click(function(){
                disablePopup3();
        });
        //Press Escape event!
        jQuery(document).keypress(function(e){
                if(e.keyCode==27 && popupStatus3==1){
                        disablePopup3();
                }
        });

});



