$(document).ready(function(){
  $("a.new_window").attr("target", "_blank");
 });
 
var popupStatus = 0;
var popupStatusBasic = 0;
var popupStatusAdvanced = 0;
var popupStatusProfessional = 0;
var popupStatusUltimate = 0;

// 0 = disabled, 1 = enabled

function loadPopupBasic(){
//loads popup only if it is disabled  
if(popupStatusBasic==0){  
$("#backgroundPopup").css({  
"opacity": "0.7"  
});  
$("#backgroundPopup").fadeIn("slow");  
$("#popupBasic").fadeIn("slow");  
popupStatusBasic = 1; 
popupStatus = 1;
}  
}

function loadPopupAdvanced(){
//loads popup only if it is disabled  
if(popupStatusAdvanced==0){  
$("#backgroundPopup").css({  
"opacity": "0.7"  
});  
$("#backgroundPopup").fadeIn("slow");  
$("#popupAdvanced").fadeIn("slow");  
popupStatusAdvanced = 1; 
popupStatus = 1;
}  
}

function loadPopupProfessional(){
//loads popup only if it is disabled  
if(popupStatusProfessional==0){  
$("#backgroundPopup").css({  
"opacity": "0.7"  
});  
$("#backgroundPopup").fadeIn("slow");  
$("#popupProfessional").fadeIn("slow");  
popupStatusProfessional = 1; 
popupStatus = 1;
}  
}

function loadPopupUltimate(){
//loads popup only if it is disabled  
if(popupStatusUltimate==0){  
$("#backgroundPopup").css({  
"opacity": "0.7"  
});  
$("#backgroundPopup").fadeIn("slow");  
$("#popupUltimate").fadeIn("slow");  
popupStatusUltimate = 1; 
popupStatus = 1;
}  
}

function disablePopup(){  
//disables popup only if it is enabled  
if(popupStatus==1){  
$("#backgroundPopup").fadeOut("slow");  
$("#popupAdvanced").fadeOut("slow");
$("#popupBasic").fadeOut("slow");
$("#popupProfessional").fadeOut("slow");
$("#popupUltimate").fadeOut("slow");  
popupStatus = 0;
popupStatusBasic = 0;
popupStatusProfessional = 0;
popupStatusUltimate = 0;
}  
}

//centering popup  
function centerPopup(type){  
//request data for centering  
var windowWidth = document.documentElement.clientWidth;  
var windowHeight = document.documentElement.clientHeight;  

if (type == 1)
	{
	var popupHeight = $("#popupBasic").height(); 
	var popupWidth = $("#popupBasic").width();
		
	$("#popupBasic").css({  
	"position": "absolute",  
	"top": windowHeight/2-popupHeight/4,  
	"left": windowWidth/2-popupWidth/2 
	});
	}


if (type == 2)
	{
	var popupHeight = $("#popupProfessional").height(); 
	var popupWidth = $("#popupProfessional").width();
		
	$("#popupProfessional").css({  
	"position": "absolute",  
	"top": windowHeight/2-popupHeight/4,  
	"left": windowWidth/2-popupWidth/2  
	});
	}

if (type == 3)
	{
	var popupHeight = $("#popupUltimate").height(); 
	var popupWidth = $("#popupUltimate").width();
	
	$("#popupUltimate").css({  
	"position": "absolute",  
	"top": windowHeight/2-popupHeight/4,  
	"left": windowWidth/2-popupWidth/2  
	});
	}
	
if (type == 4)
	{
	var popupHeight = $("#popupAdvanced").height(); 
	var popupWidth = $("#popupAdvanced").width();
		
	$("#popupAdvanced").css({  
	"position": "absolute",  
	"top": windowHeight/2-popupHeight/4,  
	"left": windowWidth/2-popupWidth/2 
	});
	}
  
$("#backgroundPopup").css({  
"height": windowHeight  
});  
  
}


$(document).ready(function(){  
						   $("#basic").click(function(){
														centerPopup(1);  
														//load popup  
														loadPopupBasic();
														});
							$("#advanced").click(function(){
														centerPopup(4);  
														//load popup  
														loadPopupAdvanced();
														});
						   $("#professional").click(function(){
														centerPopup(2);  
														//load popup  
														loadPopupProfessional();
														});
						   $("#ultimate").click(function(){
														centerPopup(3);  
														//load popup  
														loadPopupUltimate();
														});
						   
						   	$("#popupClose1").click(function(){  
							disablePopup();  
							});
						   
						   	$("#popupClose2").click(function(){  
							disablePopup();  
							});
						   
						   	$("#popupClose3").click(function(){  
							disablePopup();  
							});
							
							$("#popupClose").click(function(){  
							disablePopup();  
							});

							$("#backgroundPopup").click(function(){  
							disablePopup();  
							});   
						   
}); 
