﻿/***************************/
//@Author: Adrian "yEnS" Mato Gondelle	
/***************************/

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var REGpopup3Status = 0;

//loading popup with jQuery magic!
function loadREGPopup3(){
	//loads popup only if it is disabled
	if(REGpopup3Status==0){
		$("#REGbackgroundPopup").css({
			"opacity": "0.8"
		});
		$("#REGbackgroundPopup").fadeIn("slow");
		$("#registerPopUp").fadeIn("slow");
		REGpopup3Status = 1;
	}
}

//disabling popup with jQuery magic!
function disableREGPopup3(){
	//disables popup only if it is enabled
	if(REGpopup3Status==1){
		$("#REGbackgroundPopup").fadeOut("slow");
		$("#registerPopUp").fadeOut("slow");
		REGpopup3Status = 0;
	}
}

//centering popup
function centerREGPopup3(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var REGpopup3Height = $("#registerPopUp").height();
	var REGpopup3Width = $("#registerPopUp").width();
	//centering
	$("#registerPopUp").css({
		
		"top": windowHeight/2-REGpopup3Height/2,
		"left": windowWidth/2-REGpopup3Width/2
	});
	//only need force for IE6
	
	$("#REGbackgroundPopup").css({
		"height": windowHeight
	});
	
}


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#REGPOPbutton3").click(function(){
		//centering with css
		centerREGPopup3();
		//load popup
		loadREGPopup3();
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#REGPopUpClose").click(function(){
		disableREGPopup3();
	});
	//Click out event!
	$("#REGbackgroundPopup").click(function(){
		disableREGPopup3();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && REGpopup3Status==1){
			disableREGPopup3();
		}
	});

});