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

//loading popup with jQuery magic!
function loadPopupEmployment(){
	//loads popup only if it is disabled
	if(popupStatusEmployment==0){
		$(".backgroundPopupEmployment").css({
			"opacity": "0.8"
		});
		$(".backgroundPopupEmployment").fadeIn("slow");
		$("#popupEmployment").fadeIn("slow");
		popupStatusEmployment = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopupEmployment(){
	//disables popup only if it is enabled
	if(popupStatusEmployment==1){
		$(".backgroundPopupEmployment").fadeOut("slow");
		$("#popupEmployment").fadeOut("slow");
		popupStatusEmployment = 0;
	}
}

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


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$(".buttonEmployment").click(function(){
		//centering with css
		centerPopupEmployment();
		//load popup
		loadPopupEmployment();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$(".popupEmploymentClose").click(function(){
		disablePopupEmployment();
	});
	//Click out event!
	$(".backgroundPopupEmployment").click(function(){
		disablePopupEmployment();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusEmployment==1){
			disablePopupEmployment();
		}
	});

});
