﻿/***************************/
//@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 popup_Status = 0;
//loading popup with jQuery magic!
function load_Popup(){
	//loads popup only if it is disabled
	if(popup_Status==0){
		$("#background_Popup").css({
			"opacity": "0.7"
		});
		$("#background_Popup").fadeIn("slow");
		$("#popup_Contact").fadeIn("slow");
		popup_Status = 1;
	}
}

//disabling popup with jQuery magic!
function disable_Popup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#background_Popup").fadeOut("slow");
		$("#popup_Contact").fadeOut("slow");
		popupStatus = 0;
	}
}

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


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	
		//load popup
		
		
		//load popup
		setTimeout("center_Popup()",1000);	
	
		//load popup
		setTimeout("load_Popup()",1000);
	
	//CLOSING POPUP
	//Click the x event!
	$("#popup_Contact_Close").click(function(){
		disable_Popup();
	});
	//Click out event!
	$("#background_Popup").click(function(){
		disable_Popup();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popup_Status==1){
			disable_Popup();
		}
	});

});
