﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle	
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var REGpopup5Status = 0;

//loading popup with jQuery magic!
function loadREGPopup5(){
	//loads popup only if it is disabled
	if(REGpopup5Status==0){
		$("#REGbackgroundPopup").css({
			"opacity": "0.8"
		});
		$("#REGbackgroundPopup").fadeIn("slow");
		$("#registerPopUp").fadeIn("slow");
		REGpopup5Status = 1;
	}
}

//disabling popup with jQuery magic!
function disableREGPopup5(){
	//disables popup only if it is enabled
	if(REGpopup5Status==1){
		$("#REGbackgroundPopup").fadeOut("slow");
		$("#registerPopUp").fadeOut("slow");
		REGpopup5Status = 0;
	}
}

//centering popup
function centerREGPopup5(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var REGpopup5Height = $("#registerPopUp").height();
	var REGpopup5Width = $("#registerPopUp").width();
	//centering
	$("#registerPopUp").css({
		
		"top": windowHeight/2-REGpopup5Height/2,
		"left": windowWidth/2-REGpopup5Width/2
	});
	//only need force for IE6
	
	$("#REGbackgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#REGPOPbutton5").click(function(){
		//centering with css
		centerREGPopup5();
		//load popup
		loadREGPopup5();
		
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#REGPopUpClose").click(function(){
		disableREGPopup5();
	});
	//Click out event!
	$("#REGbackgroundPopup").click(function(){
		disableREGPopup5();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && REGpopup5Status==1){
			disableREGPopup5();
		}
	});

});
