﻿/***************************/
//@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 popupStatus11 = 0;

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

//disabling popup with jQuery magic!
function disablePopup11(){
	//disables popup only if it is enabled
	if(popupStatus11==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupContact11").fadeOut("slow");
		popupStatus11 = 0;
	}
}

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


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button11").click(function(){
		//centering with css
		centerPopup11();
		//load popup
		loadPopup11();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose11").click(function(){
		disablePopup11();
	});
	//Click out event!
	$("#backgroundPopup").click(function(){
		disablePopup11();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus11==1){
			disablePopup11();
		}
	});

});