// JavaScript Document
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupEntireStatus=0;


//loading popup with jQuery magic!
function loadPopup1(){
	//loads popup only if it is disabled
	if(popupEntireStatus==0){
		$("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup1").fadeIn("slow");
		$("#popupContact").fadeIn("slow");
		popupEntireStatus = 1;
	}
		

}

//disabling popup with jQuery magic!
function disablePopup1(){
	//disables popup only if it is enabled
	if(popupEntireStatus==1){
		$("#backgroundPopup1").fadeOut("slow");
		$("#popupContact").fadeOut("slow");
		popupEntireStatus = 0;
	}
		
}

//centering popup
function centerPopup1(){
	//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
	$("#backgroundPopup1").css({
		"height": windowHeight
	});
		$("#backgroundPopup1").css({
		"height": windowHeight
	});
	
}

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupCallBackStatus=0;


//loading popup with jQuery magic!
function loadPopup2(){
	//loads popup only if it is disabled
	if(popupCallBackStatus==0){
		$("#backgroundPopup2").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup2").fadeIn("slow");
		$("#popupCallBack").fadeIn("slow");
		popupCallBackStatus = 1;
	}
		

}

//disabling popup with jQuery magic!
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupCallBackStatus==1){
		$("#backgroundPopup2").fadeOut("slow");
		$("#popupCallBack").fadeOut("slow");
		popupCallBackStatus = 0;
	}
		
}

//centering popup
function centerPopup2(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupCallBack").height();
	var popupWidth = $("#popupCallBack").width();
	//centering
	$("#popupCallBack").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopup2").css({
		"height": windowHeight
	});
		$("#backgroundPopup2").css({
		"height": windowHeight
	});
	
}

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupGeneralStatus=0;


//loading popup with jQuery magic!
function loadPopup5(){
	//loads popup only if it is disabled
	if(popupGeneralStatus==0){
		$("#backgroundPopup5").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup5").fadeIn("slow");
		$("#popupGeneral").fadeIn("slow");
		popupGeneralStatus = 1;
	}
		

}

//disabling popup with jQuery magic!
function disablePopup5(){
	//disables popup only if it is enabled
	if(popupGeneralStatus==1){
		$("#backgroundPopup5").fadeOut("slow");
		$("#popupGeneral").fadeOut("slow");
		popupGeneralStatus = 0;
	}
		
}

//centering popup
function centerPopup5(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupGeneral").height();
	var popupWidth = $("#popupGeneral").width();
	//centering
	$("#popupGeneral").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$("#backgroundPopup5").css({
		"height": windowHeight
	});
		$("#backgroundPopup5").css({
		"height": windowHeight
	});
	
}

$(document).ready(function(){

	//LOADING POPUP
	//Click the button event!
	$("#enquire").click(function(){
						
		//centering with css
		centerPopup1();
		//load popup
		loadPopup1("#popupContact");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactClose").click(function(){
		disablePopup1();
	});
	//Click out event!
	$("#backgroundPopup1").click(function(){
		disablePopup1();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupEntireStatus==1 ){
			disablePopup1();
		}
	});
	
	//LOADING POPUP
	//Click the button event!
	$("#callBack").click(function(){
						
		//centering with css
		centerPopup2();
		//load popup
		loadPopup2("#popupCallBack");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupCallBackClose").click(function(){
		disablePopup2();
	});
	//Click out event!
	$("#backgroundPopup2").click(function(){
		disablePopup2();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupCallBackStatus==1 ){
			disablePopup2();
		}
	});
	
	
	//LOADING POPUP
	//Click the button event!
	$("#general").click(function(){
						
		//centering with css
		centerPopup5();
		//load popup
		loadPopup5("#popupGeneral");
	});
		
	//CLOSING POPUP
	//Click the x event!
	$("#popupGeneralClose").click(function(){
		disablePopup5();
	});
	//Click out event!
	$("#backgroundPopup5").click(function(){
		disablePopup5();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupGeneralStatus==1 ){
			disablePopup5();
		}
	});
	
	
	});
