﻿/***************************/
//@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("slow");
    $("#popupContact").fadeIn("slow");
    popupStatus = 1;
  }
}
function loadPopup_b(){
  //loads popup only if it is disabled
  if(popupStatus==0){
    $("#backgroundPopup_b").css({
      "opacity": "0.7"
    });
    $("#backgroundPopup_b").fadeIn("slow");
    $("#popupContact_b").fadeIn("slow");
    popupStatus = 1;
  }
}
function loadPopup_c(){
  //loads popup only if it is disabled
  if(popupStatus==0){
    $("#backgroundPopup_c").css({
      "opacity": "0.7"
    });
    $("#backgroundPopup_c").fadeIn("slow");
    $("#popupContact_c").fadeIn("slow");
    popupStatus = 1;
  }
}
function loadPopup_d(){
  //loads popup only if it is disabled
  if(popupStatus==0){
    $("#backgroundPopup_d").css({
      "opacity": "0.7"
    });
    $("#backgroundPopup_d").fadeIn("slow");
    $("#popupContact_d").fadeIn("slow");
    popupStatus = 1;
  }
}
function loadPopup_e(){
  //loads popup only if it is disabled
  if(popupStatus==0){
    $("#backgroundPopup_e").css({
      "opacity": "0.7"
    });
    $("#backgroundPopup_e").fadeIn("slow");
    $("#popupContact_e").fadeIn("slow");
    popupStatus = 1;
  }
}
function loadPopup_f(){
  //loads popup only if it is disabled
  if(popupStatus==0){
    $("#backgroundPopup_f").css({
      "opacity": "0.7"
    });
    $("#backgroundPopup_f").fadeIn("slow");
    $("#popupContact_f").fadeIn("slow");
    popupStatus = 1;
  }
}
function loadPopup_m(){
	  //loads popup only if it is disabled
	  if(popupStatus==0){
	    $("#backgroundMail").css({
	      "opacity": "0.7"
	    });
	    $("#backgroundMail").fadeIn("slow");
	    $("#popupMail").fadeIn("slow");
	    popupStatus = 1;
	  }
	}
function loadPopup_brochures(){
	  //loads popup only if it is disabled
	  if(popupStatus==0){
	    $("#backgroundBrochures").css({
	      "opacity": "0.7"
	    });
	    $("#backgroundBrochures").fadeIn("slow");
	    $("#popupBrochures").fadeIn("slow");
	    popupStatus = 1;
	  }
	}
function loadPopup_address(){
	  //loads popup only if it is disabled
	  if(popupStatus==0){
	    $("#backgroundAddress").css({
	      "opacity": "0.7"
	    });
	    $("#backgroundAddress").fadeIn("slow");
	    $("#popupAddress").fadeIn("slow");
	    popupStatus = 1;
	  }
	}
//disabling popup with jQuery magic!
function disablePopup(){
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup").fadeOut("slow");
    $("#popupContact").fadeOut("slow");
    popupStatus = 0;
  }
}
function disablePopup_b(){
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup_b").fadeOut("slow");
    $("#popupContact_b").fadeOut("slow");
    popupStatus = 0;
  }
}
function disablePopup_c(){
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup_c").fadeOut("slow");
    $("#popupContact_c").fadeOut("slow");
    popupStatus = 0;
  }
}
function disablePopup_d(){
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup_d").fadeOut("slow");
    $("#popupContact_d").fadeOut("slow");
    popupStatus = 0;
  }
}
function disablePopup_e(){
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup_e").fadeOut("slow");
    $("#popupContact_e").fadeOut("slow");
    popupStatus = 0;
  }
}
function disablePopup_f(){
  //disables popup only if it is enabled
  if(popupStatus==1){
    $("#backgroundPopup_f").fadeOut("slow");
    $("#popupContact_f").fadeOut("slow");
    popupStatus = 0;
  }
}
function disablePopup_m(){
	  //disables popup only if it is enabled
	  if(popupStatus==1){
	    $("#backgroundMail").fadeOut("slow");
	    $("#popupMail").fadeOut("slow");
	    popupStatus = 0;
	  }
	}
function disablePopup_brochures(){
	  //disables popup only if it is enabled
	  if(popupStatus==1){
	    $("#backgroundBrochures").fadeOut("slow");
	    $("#popupBrochures").fadeOut("slow");
	    popupStatus = 0;
	  }
	}
function disablePopup_address(){
	  //disables popup only if it is enabled
	  if(popupStatus==1){
	    $("#backgroundAddress").fadeOut("slow");
	    $("#popupAddress").fadeOut("slow");
	    popupStatus = 0;
	  }
	}
//centering popup
function centerPopup(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#popupContact").height();
  var popupWidth = $("#popupContact").width();
  //centering
  $("#popupContact").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6
  
  $("#backgroundPopup").css({
    "height": windowHeight
  });
}
function centerPopup_b(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#popupContact_b").height();
  var popupWidth = $("#popupContact_b").width();
  //centering
  $("#popupContact_b").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6
  
  $("#backgroundPopup_b").css({
    "height": windowHeight
  });
}
function centerPopup_c(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#popupContact_c").height();
  var popupWidth = $("#popupContact_c").width();
  //centering
  $("#popupContact_c").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6
  
  $("#backgroundPopup_c").css({
    "height": windowHeight
  });
}
function centerPopup_d(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#popupContact_d").height();
  var popupWidth = $("#popupContact_d").width();
  //centering
  $("#popupContact_d").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6
  
  $("#backgroundPopup_d").css({
    "height": windowHeight
  });
}
function centerPopup_e(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#popupContact_e").height();
  var popupWidth = $("#popupContact_e").width();
  //centering
  $("#popupContact_e").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6
  
  $("#backgroundPopup_e").css({
    "height": windowHeight
  });
}
function centerPopup_f(){
  //request data for centering
  var windowWidth = document.documentElement.clientWidth;
  var windowHeight = document.documentElement.clientHeight;
  var popupHeight = $("#popupContact_f").height();
  var popupWidth = $("#popupContact_f").width();
  //centering
  $("#popupContact_f").css({
    "position": "absolute",
    "top": windowHeight/2-popupHeight/2,
    "left": windowWidth/2-popupWidth/2
  });
  //only need force for IE6
  
  $("#backgroundPopup_f").css({
    "height": windowHeight
  });
}
function centerPopup_m(){
	  //request data for centering
	  var windowWidth = document.documentElement.clientWidth;
	  var windowHeight = document.documentElement.clientHeight;
	  var popupHeight = $("#popupMail").height();
	  var popupWidth = $("#popupMail").width();
	  //centering
	  $("#popupMail").css({
	    "position": "absolute",
	    "top": windowHeight/2-popupHeight/2,
	    "left": windowWidth/2-popupWidth/2
	  });
	  //only need force for IE6
	  
	  $("#backgroundMail").css({
	    "height": windowHeight
	  });
	}
function centerPopup_brochures(){
	  //request data for centering
	  var windowWidth = document.documentElement.clientWidth;
	  var windowHeight = document.documentElement.clientHeight;
	  var popupHeight = $("#popupBrochures").height();
	  var popupWidth = $("#popupBrochures").width();
	  //centering
	  $("#popupBrochures").css({
	    "position": "absolute",
	    "top": windowHeight/2-popupHeight/2,
	    "left": windowWidth/2-popupWidth/2
	  });
	  //only need force for IE6
	  
	  $("#backgroundBrochures").css({
	    "height": windowHeight
	  });
	}
function centerPopup_address(){
	  //request data for centering
	  var windowWidth = document.documentElement.clientWidth;
	  var windowHeight = document.documentElement.clientHeight;
	  var popupHeight = $("#popupAddress").height();
	  var popupWidth = $("#popupAddress").width();
	  //centering
	  $("#popupAddress").css({
	    "position": "absolute",
	    "top": windowHeight/2-popupHeight/2,
	    "left": windowWidth/2-popupWidth/2
	  });
	  //only need force for IE6
	  
	  $("#backgroundAddress").css({
	    "height": windowHeight
	  });
	}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
  
  //LOADING POPUP
  $("#register_a").click(function(){
    //centering with css
    centerPopup();
    //load popup
    loadPopup();
  });
  
  $("#register_b").click(function(){
    //centering with css
    centerPopup_b();
    //load popup
    loadPopup_b();
  });
  
  $("#login").click(function(){
    //centering with css
    centerPopup_c();
    //load popup
    loadPopup_c();
  });
  
  $("#steps").click(function(){
    //centering with css
    centerPopup_d();
    //load popup
    loadPopup_d();
  });
  
  $("#bring").click(function(){
    //centering with css
    centerPopup_e();
    //load popup
    loadPopup_e();
  });
  
  $("#paypal").click(function(){
    //centering with css
    centerPopup_f();
    //load popup
    loadPopup_f();
  });
  $("#mail").click(function(){
	    //centering with css
	    centerPopup_m();
	    //load popup
	    loadPopup_m();
	  });
  $("#brochures").click(function(){
	    //centering with css
	    centerPopup_brochures();
	    //load popup
	    loadPopup_brochures();
	  });
  $("#address").click(function(){
	    //centering with css
	    centerPopup_address();
	    //load popup
	    loadPopup_address();
	  });
  //CLOSING POPUP
  $("#popupContactClose").click(function(){
    disablePopup();
  });
  $("#popupContactClose_b").click(function(){
    disablePopup_b();
  });
  $("#popupContactClose_c").click(function(){
    disablePopup_c();
  });
  $("#popupContactClose_d").click(function(){
    disablePopup_d();
  });
  $("#popupContactClose_e").click(function(){
    disablePopup_e();
  });
  $("#popupContactClose_f").click(function(){
    disablePopup_f();
  });
  $("#popupMailClose").click(function(){
	    disablePopup_m();
	  });
  $("#popupBrochuresClose").click(function(){
	    disablePopup_brochures();
	  });
  $("#popupAddressClose").click(function(){
	    disablePopup_address();
	  });
  //Click out event!
  $("#backgroundPopup").click(function(){
    disablePopup();
  });
  $("#backgroundPopup_b").click(function(){
    disablePopup_b();
  });
  $("#backgroundPopup_c").click(function(){
    disablePopup_c();
  });
  $("#backgroundPopup_d").click(function(){
    disablePopup_d();
  });
  $("#backgroundPopup_e").click(function(){
    disablePopup_e();
  });
  $("#backgroundPopup_f").click(function(){
    disablePopup_f();
  });
  $("#backgroundMail").click(function(){
	    disablePopup_m();
	  });
  $("#backgroundBrochures").click(function(){
	    disablePopup_brochures();
	  });
  $("#backgroundAddress").click(function(){
	    disablePopup_address();
	  });
  //Press Escape event!
  $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
      disablePopup();
    }
  });
  $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
      disablePopup_b();
    }
  });
  $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
      disablePopup_c();
    }
  });
  $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
      disablePopup_d();
    }
  });
  $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
      disablePopup_e();
    }
  });
  $(document).keypress(function(e){
    if(e.keyCode==27 && popupStatus==1){
      disablePopup_f();
    }
  });
  
});