﻿/***************************/
//@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;
var popupStatusService = 0;
var popupStatusSearch = 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");
		$("#popup_industry").fadeIn("slow");
		popupStatus = 1;
	}
}

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

//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup_industry").height();
	var popupWidth = $("#popup_industry").width();
	//centering
	$("#popup_industry").css({
		"position": "absolute",
/*		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2 */
		"top": "42px",
		"right": "49px"
	});
	//only need force for IE6
	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#button").click(function(){
		if (popupStatusService==1){
			disablePopupService();
			$("#services").removeClass("active");
		}
if (popupStatusSearch==1){
			disablePopupSearch();
			$("#search1").removeClass("active");
		}	
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});				
	
	//Click out event!
	$("#backgroundPopup").click(function(){		
		disablePopup();
		$("#button").removeClass("active");
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27){
			if (popupStatus==1){
				disablePopup();
				$("#button").removeClass("active");
			}
			
			if (popupStatusService==1){
				disablePopupService();
				$("#services").removeClass("active");
			}
if (popupStatusSearch==1){
				disablePopupSearch();
				$("#search1").removeClass("active");
			}
		}
	});
	
	
	//LOADING POPUP
	//Click the button event!
	$("#services").click(function(){
		if (popupStatus==1){
			disablePopup();
			$("#button").removeClass("active");
		}
if (popupStatusSearch==1){
			disablePopupSearch();
			$("#search1").removeClass("active");
		}
			
		//centering with css
		centerPopupService();
		//load popup
		loadPopupService();
	});
	
	//Click out event!
	$("#backgroundPopupService").click(function(){		
		disablePopupService();
		$("#services").removeClass("active");
	});

$("#search1").click(function(){
		if (popupStatus==1){
			disablePopup();
			$("#button").removeClass("active");
		}
		if (popupStatusService==1){
			disablePopupService();
			$("#services").removeClass("active");
		}	
		//centering with css
		centerPopupSearch();
		//load popup
		loadPopupSearch();
	});
	
	//Click out event!
	$("#backgroundPopupSearch").click(function(){		
		disablePopupSearch();
		$("#search1").removeClass("active");
	});
});

/////////////////////////////////////////////////////////////////////////////
// Popup for Services
/////////////////////////////////////////////////////////////////////////////

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

//disabling popup with jQuery magic!
function disablePopupService(){
	//disables popup only if it is enabled
	if(popupStatusService==1){
		$("#backgroundPopupService").fadeOut("slow");
		$("#popup_services").fadeOut("slow");
		popupStatusService = 0;
	}
}

//centering popup
function centerPopupService(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup_services").height();
	var popupWidth = $("#popup_services").width();
	//centering
	$("#popup_services").css({
		"position": "absolute",
/*		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2 */
		"top": "42px",
		"right": "49px"
	});
	//only need force for IE6
	
	$("#backgroundPopupService").css({
		"height": windowHeight
	});
	
}
/////////////////////////////
// Search popup
////////////////////////////

function loadPopupSearch(){
	//loads popup only if it is disabled
	if(popupStatusSearch==0){
		$("#backgroundPopupSearch").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupSearch").fadeIn("slow");
		$("#popup_search").fadeIn("slow");
		popupStatusSearch = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopupSearch(){
	//disables popup only if it is enabled
	if(popupStatusSearch==1){
		$("#backgroundPopupSearch").fadeOut("slow");
		$("#popup_search").fadeOut("slow");
		popupStatusSearch = 0;
	}
}

//centering popup
function centerPopupSearch(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup_search").height();
	var popupWidth = $("#popup_search").width();
	//centering
	$("#popup_search").css({
		"position": "absolute",
/*		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2 */
		"top": "42px",
		"right": "49px"
	});
	//only need force for IE6
	
	$("#backgroundPopupSearch").css({
		"height": windowHeight
	});
	
}
//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	

});


