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

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

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

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

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


//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event!
	$("#REGPOPbutton2").click(function(){
		//centering with css
		centerREGPopup2();
		//load popup
		loadREGPopup2();
		
		disablePROFPopup();
		disablePopup();
		disableCOMPopup();
		/*disablePROFPopup();
		disablePopup();
		disablePopup2();
		disablePopup3();
		disableREGPopup();
		disableREGPopup3();*/
	});
				
	//CLOSING POPUP
	//Click the x event!
	$("#REGPopUpClose").click(function(){
		disableREGPopup2();
	});
	//Click out event!
	$("#REGbackgroundPopup").click(function(){
		disableREGPopup2();
	});
	//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && REGpopup2Status==1){
			disableREGPopup2();
		}
	});

});
