/***************************/
//@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;

//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$j("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup").fadeIn("slow");
		$j("#popupContact").fadeIn("slow");
		
		popupStatus = 1;
	}
}
var popupStatus1 = 0;
function loadPopup1(){
	//loads popup only if it is disabled
	if(popupStatus1==0){
		$j("#backgroundPopup1").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup1").fadeIn("slow");
		
		$j("#popupContact1").fadeIn("slow");
	
		popupStatus1 = 1;
	}
}
var popupStatus2 = 0;
function loadPopup2(){
	//loads popup only if it is disabled
	if(popupStatus2==0){
		$j("#backgroundPopup2").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup2").fadeIn("slow");
		
		$j("#popupContact2").fadeIn("slow");
		popupStatus2 = 1;
	}
}
var popupStatus3 = 0;
function loadPopup3(){
	//loads popup only if it is disabled
	if(popupStatus3==0){
		$j("#backgroundPopup3").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup3").fadeIn("slow");
		
		$j("#popupContact3").fadeIn("slow");
		popupStatus3 = 1;
	}
}
var popupStatus4 = 0;
function loadPopup4(){
	//loads popup only if it is disabled
	if(popupStatus4==0){
		$j("#backgroundPopup4").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup4").fadeIn("slow");
		
		$j("#popupContact4").fadeIn("slow");
		popupStatus4 = 1;
	}
}
var popupStatus5 = 0;
function loadPopup5(){
	//loads popup only if it is disabled
	if(popupStatus5==0){
		$j("#backgroundPopup5").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup5").fadeIn("slow");
		
		$j("#popupContact5").fadeIn("slow");
		popupStatus5 = 1;
	}
}
var popupStatus6 = 0;
function loadPopup6(){
	//loads popup only if it is disabled
	if(popupStatus6==0){
		$j("#backgroundPopup6").css({
			"opacity": "0.7"
		});
		$j("#backgroundPopup6").fadeIn("slow");
		
		$j("#popupContact6").fadeIn("slow");
		popupStatus6 = 1;
	}
}
//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$j("#backgroundPopup").fadeOut("slow");
		$j("#popupContact").fadeOut("slow");
	
		popupStatus = 0;
	}
}
function disablePopup1(){
	//disables popup only if it is enabled
	if(popupStatus1==1){
		$j("#backgroundPopup1").fadeOut("slow");
		
		$j("#popupContact1").fadeOut("slow");
		
		popupStatus1 = 0;
	}
}
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupStatus2==1){
		$j("#backgroundPopup2").fadeOut("slow");
		$j("#popupContact2").fadeOut("slow");
	
		popupStatus2 = 0;
	}
}

function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus3==1){
		$j("#backgroundPopup3").fadeOut("slow");
		$j("#popupContact3").fadeOut("slow");
	
		popupStatus3 = 0;
	}
}
function disablePopup4(){
	//disables popup only if it is enabled
	if(popupStatus4==1){
		$j("#backgroundPopup4").fadeOut("slow");
		$j("#popupContact4").fadeOut("slow");
	
		popupStatus4 = 0;
	}
}
function disablePopup5(){
	//disables popup only if it is enabled
	if(popupStatus5==1){
		$j("#backgroundPopup5").fadeOut("slow");
		$j("#popupContact5").fadeOut("slow");
	
		popupStatus5 = 0;
	}
}
function disablePopup6(){
	//disables popup only if it is enabled
	if(popupStatus6==1){
		$j("#backgroundPopup6").fadeOut("slow");
		$j("#popupContact6").fadeOut("slow");
	
		popupStatus6 = 0;
	}
}
//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact").height();
	var popupWidth = $j("#popupContact").width();
	//centering
	$j("#popupContact").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup").css({
		"height": windowHeight
	});

}
function centerPopup1(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact1").height();
	var popupWidth = $j("#popupContact1").width();
	//centering
		$j("#popupContact1").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup1").css({
		"height": windowHeight
	});

}

function centerPopup2(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact2").height();
	var popupWidth = $j("#popupContact2").width();
		$j("#popupContact2").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup2").css({
		"height": windowHeight
	});

}
function centerPopup3(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact3").height();
	var popupWidth = $j("#popupContact3").width();
		$j("#popupContact3").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup3").css({
		"height": windowHeight
	});

}
function centerPopup4(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact4").height();
	var popupWidth = $j("#popupContact4").width();
		$j("#popupContact4").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup4").css({
		"height": windowHeight
	});

}
function centerPopup5(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact5").height();
	var popupWidth = $j("#popupContact5").width();
		$j("#popupContact5").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup5").css({
		"height": windowHeight
	});

}
function centerPopup6(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $j("#popupContact6").height();
	var popupWidth = $j("#popupContact6").width();
		$j("#popupContact6").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6

	$j("#backgroundPopup6").css({
		"height": windowHeight
	});

}
//CONTROLLING EVENTS IN jQuery
$j(document).ready(function(){
 $j("#popupContact").hide();
  $j("#popupContact1").hide();
   $j("#popupContact2").hide();
   $j("#popupContact3").hide();
   $j("#popupContact4").hide();
   $j("#popupContact5").hide();
   $j("#popupContact6").hide();
	//LOADING POPUP
	//Click the button event!
	$j("#button").click(function(){
	$j('#popupContact1').hide();
	$j('#popupContact2').hide();
	$j('#backgroundPopup1').hide();
	$j('#backgroundPopup2').hide();
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
		
	});
	$j("#button1").click(function(){
	$j('#popupContact').hide();
	$j('#popupContact2').hide();
	$j('#backgroundPopup').hide();
	$j('#backgroundPopup2').hide();
		//centering with css
		centerPopup1();
		//load popup
		loadPopup1();
	});
	$j("#button2").click(function(){
	$j('#popupContact1').hide();
	$j('#popupContact').hide();
	$j('#backgroundPopup1').hide();
	$j('#backgroundPopup').hide();
		//centering with css
		centerPopup2();
		//load popup
		loadPopup2();
	});
	
	$j("#button3").click(function(){
	$j('#popupContact4').hide();
	$j('#popupContact5').hide();
	$j('#backgroundPopup4').hide();
	$j('#backgroundPopup5').hide();
		//centering with css
		centerPopup3();
		//load popup
		loadPopup3();
	});
	
		$j("#button4").click(function(){
	$j('#popupContact3').hide();
	$j('#popupContact5').hide();
	$j('#backgroundPopup3').hide();
	$j('#backgroundPopup5').hide();
		//centering with css
		centerPopup4();
		//load popup
		loadPopup4();
	});
	
		$j("#button5").click(function(){
	$j('#popupContact3').hide();
	$j('#popupContact4').hide();
	$j('#backgroundPopup3').hide();
	$j('#backgroundPopup4').hide();
		//centering with css
		centerPopup5();
		//load popup
		loadPopup5();
	});
		$j("#button6").click(function(){
	$j('#popupContact3').hide();
	$j('#popupContact6').hide();
	$j('#backgroundPopup3').hide();
	$j('#backgroundPopup6').hide();
		//centering with css
		centerPopup6();
		//load popup
		loadPopup6();
	});

	//CLOSING POPUP
	//Click the x event!
	$j("#popupContactClose").click(function(){
		disablePopup();
	});
	$j("#popupContactClose1").click(function(){
		disablePopup1();
	});
	$j("#popupContactClose2").click(function(){
		disablePopup2();
	});
	
	$j("#popupContactClose3").click(function(){
		disablePopup3();
	});
	$j("#popupContactClose4").click(function(){
		disablePopup4();
	});
	$j("#popupContactClose5").click(function(){
		disablePopup5();
	});
	$j("#popupContactClose6").click(function(){
		disablePopup6();
	});
	//Click out event!
	$j("#backgroundPopup").click(function(){
		disablePopup();
	});
		$j("#backgroundPopup1").click(function(){
		disablePopup1();
	});
		$j("#backgroundPopup2").click(function(){
		disablePopup2();
	});
	
	$j("#backgroundPopup3").click(function(){
		disablePopup3();
	});
	
	$j("#backgroundPopup4").click(function(){
		disablePopup4();
	});
	$j("#backgroundPopup5").click(function(){
		disablePopup5();
	});
	$j("#backgroundPopup6").click(function(){
		disablePopup6();
	});
	//Press Escape event!
	$j(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});

