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

//loading popup with jQuery magic!
function loadPopupOverview(){
	//loads popup only if it is disabled
	if(popupStatusOverview==0){
		$("#backgroundOverviewPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundOverviewPopup").fadeIn("slow");
		$("#overview-box").fadeIn("slow");
		popupStatusOverview = 1;
	}
}

//disabling popup with jQuery magic!
function disablePopupOverview(){
	//disables popup only if it is enabled
	if(popupStatusOverview==1){
		$("#backgroundOverviewPopup").fadeOut("slow");
		$("#overview-box").fadeOut("slow");
		popupStatusOverview = 0;
		//$('.fout').remove();
		//$('.field').val("");
	}
}

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

	$("#backgroundOverviewPopup").css({
		"height": windowHeight
	});

}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
		
	/*$("#backgroundOverviewPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundOverviewPopup").fadeIn("slow");
		$("#overview-box").fadeIn("slow");
		popupStatusOverview = 1;*/
	
	//LOADING POPUP
	//Click the button event!
	$("#popOverview").click(function(){
		//hide all other popups
		disablePopupRegister();
		disablePopup();
		disablePopupSucces();
		disablePopupPassword();
		//centering with css
		centerPopupOverview();
		//load popup
		loadPopupOverview();
	});

	//CLOSING POPUP
	//Click the x event!
	$("#close-overview").click(function(){
		disablePopupOverview();
	});
	//Click out event!
	$("#backgroundOverviewPopup").click(function(){
		disablePopupOverview();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusOverview==1){
			disablePopupOverview();
		}
	});

});
