﻿/***************************/
//@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 popupStatusDaveLambert = 0;
var popupStatusEno = 0;
var popupStatusSeelen = 0;
var popupStatusTronico = 0;


//loading popup
function loadPopupDaveLambert(){
	if(popupStatusDaveLambert==0){
		$("#backgroundPopupDaveLambert").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupDaveLambert").fadeIn("slow");
		$("#popupContactDaveLambert").fadeIn("slow");
		popupStatusDaveLambert = 1;
	}
}

function loadPopupEno(){
	if(popupStatusEno==0){
		$("#backgroundPopupEno").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupEno").fadeIn("slow");
		$("#popupContactEno").fadeIn("slow");
		popupStatusEno = 1;
	}
}

function loadPopupSeelen(){
	if(popupStatusSeelen==0){
		$("#backgroundPopupSeelen").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupSeelen").fadeIn("slow");
		$("#popupContactSeelen").fadeIn("slow");
		popupStatusSeelen = 1;
	}
}

function loadPopupTronico(){
	if(popupStatusTronico==0){
		$("#backgroundPopupTronico").css({
			"opacity": "0.7"
		});
		$("#backgroundPopupTronico").fadeIn("slow");
		$("#popupContactTronico").fadeIn("slow");
		popupStatusTronico = 1;
	}
}



// end loading





//disabling popup
function disablePopupDaveLambert(){
	//disables popup only if it is enabled
	if(popupStatusDaveLambert==1){
		$("#backgroundPopupDaveLambert").fadeOut("slow");
		$("#popupContactDaveLambert").fadeOut("slow");
		popupStatusDaveLambert = 0;
	}
}

function disablePopupEno(){
	//disables popup only if it is enabled
	if(popupStatusEno==1){
		$("#backgroundPopupEno").fadeOut("slow");
		$("#popupContactEno").fadeOut("slow");
		popupStatusEno = 0;
	}
}

function disablePopupSeelen(){
	//disables popup only if it is enabled
	if(popupStatusSeelen==1){
		$("#backgroundPopupSeelen").fadeOut("slow");
		$("#popupContactSeelen").fadeOut("slow");
		popupStatusSeelen = 0;
	}
}

function disablePopupTronico(){
	//disables popup only if it is enabled
	if(popupStatusTronico==1){
		$("#backgroundPopupTronico").fadeOut("slow");
		$("#popupContactTronico").fadeOut("slow");
		popupStatusTronico = 0;
	}
}


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

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

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


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

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#lambert").click(function(){
		//centering with css
		centerPopupDaveLambert();
		//load popup
		loadPopupDaveLambert();
	});
	
	$("#eno").click(function(){
		//centering with css
		centerPopupEno();
		//load popup
		loadPopupEno();
	});
	
	$("#seelen").click(function(){
		//centering with css
		centerPopupSeelen();
		//load popup
		loadPopupSeelen();
	});
	
	$("#tronico").click(function(){
		//centering with css
		centerPopupTronico();
		//load popup
		loadPopupTronico();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#popupContactCloseDaveLambert").click(function(){
		disablePopupDaveLambert();
	});
	//Click out event!
	$("#backgroundPopupDaveLambert").click(function(){
		disablePopupDaveLambert();
	});
	
	$("#popupContactCloseEno").click(function(){
		disablePopupEno();
	});
	//Click out event!
	$("#backgroundPopupEno").click(function(){
		disablePopupEno();
	});
	
	$("#popupContactCloseSeelen").click(function(){
		disablePopupSeelen();
	});
	//Click out event!
	$("#backgroundPopupSeelen").click(function(){
		disablePopupSeelen();
	});
	
	$("#popupContactCloseTronico").click(function(){
		disablePopupTronico();
	});
	//Click out event!
	$("#backgroundPopupTronico").click(function(){
		disablePopupTronico();
	});
	
	
	
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusDaveLambert==1){
			disablePopupDaveLambert();
		}
	});
	
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusEno==1){
			disablePopupEno();
		}
	});
	
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusSeelen==1){
			disablePopupSeelen();
		}
	});
	
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusTronico==1){
			disablePopupTronico();
		}
	});


});
