/***************************/
//@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){
        	jQuery("#backgroundPopup").css({
                        "opacity": "0.5"
                });
        	jQuery("#backgroundPopup").fadeIn("fast");
        	jQuery("#popupWindow").fadeIn("fast");
                popupStatus = 1;
        }
}

//disabling popup with jQuery magic!
function disablePopup(){
        //disables popup only if it is enabled
        if(popupStatus==1){
        	jQuery("#backgroundPopup").fadeOut("fast");
        	jQuery("#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 = jQuery("#popupWindow").height();
        var popupWidth = jQuery("#popupWindow").width();
        //centering
        jQuery("#popupWindow").css({
                "position": "absolute",
                "top": windowHeight/2-popupHeight/2,
                "left": windowWidth/2-popupWidth/2
        });
        //only need force for IE6

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

}

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

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

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

});


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

var popupStatus1 = 0;

//loading popup with jQuery magic!
function loadPopup1(){
      //loads popup only if it is disabled
      if(popupStatus1==0){
    	  jQuery("#backgroundPopup1").css({
                      "opacity": "0.5"
              });
    	  jQuery("#backgroundPopup1").fadeIn("fast");
    	  jQuery("#popupWindow1").fadeIn("fast");
              popupStatus1 = 1;
      }
}

//disabling popup with jQuery magic!
function disablePopup1(){
      //disables popup only if it is enabled
      if(popupStatus1==1){
    	  jQuery("#backgroundPopup1").fadeOut("fast");
    	  jQuery("#popupWindow1").fadeOut("fast");
              popupStatus1 = 0;
      }
}

//centering popup
function centerPopup1(){
      //request data for centering
      var windowWidth1 = document.documentElement.clientWidth;
      var windowHeight1 = document.documentElement.clientHeight;
      var popupHeight1 = jQuery("#popupWindow1").height();
      var popupWidth1 = jQuery("#popupWindow1").width();
      //centering
      jQuery("#popupWindow1").css({
              "position": "absolute",
              "top": windowHeight1/2-popupHeight1/2,
              "left": windowWidth1/2-popupWidth1/2
      });
      //only need force for IE6

      jQuery("#backgroundPopup1").css({
              "height": windowHeight1
      });

}

//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){
	
  
    
      //CLOSING POPUP
      //Click the x event!
      jQuery("#popupWindowClose1").click(function(){
              disablePopup1();
      });
      jQuery(".popupWindowClose1").click(function(){
          disablePopup1();
      });      
      //Click out event!
      jQuery("#backgroundPopup1").click(function(){
              disablePopup1();
      });
      //Press Escape event!
      jQuery(document).keypress(function(e){
              if(e.keyCode==27 && popupStatus1==1){
                      disablePopup1();
              }
      });

});

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

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();
                }
        });

});



