// JavaScript Document


/*----------------- Pop-Up Terms --------------------*/
//Set-Up Pop-Up
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#backgroundPopup").css({
			"opacity": "0.7"
		});
		$("#backgroundPopup").fadeIn("slow");
		$("#popupTerms").fadeIn("slow");
		popupStatus = 1;
	}
}

//disabling popup with jQuery
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#backgroundPopup").fadeOut("slow");
		$("#popupTerms").fadeOut("slow");
		popupStatus = 0;
	}
}

//Centering Popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popupTerms").height();
	var popupWidth = $("#popupTerms").width();
	//centering
	$("#popupTerms").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});
	//only need force for IE6	
	$("#backgroundPopup").css({
		"height": windowHeight
	});
	
}

//Control Events in jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event
	$("#terms-button").click(function(){
		//centering with css
		centerPopup();
		//load popup
		loadPopup();
	});
				
	//CLOSING POPUP
	//Click the x event
	$("#popupClose").click(function(){
		disablePopup();
	});
	//Click out event
	$("#backgroundPopup").click(function(){
		disablePopup();
	});
	//Press escape event
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});

/*----------------- Pop-Up CVV --------------------*/
var popupStatus1 = 0;

function loadPopup1(){

	if(popupStatus1==0){
		$("#cvvbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#cvvbackgroundPopup").fadeIn("slow");
		$("#popupCVV").fadeIn("slow");
		popupStatus1 = 1;
	}
}

function disablePopup1(){	
	if(popupStatus1==1){
		$("#cvvbackgroundPopup").fadeOut("slow");
		$("#popupCVV").fadeOut("slow");
		popupStatus1 = 0;
	}
}

function centerPopup1(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight1 = $("#popupCVV").height();
	var popupWidth1 = $("#popupCVV").width();	
	$("#popupCVV").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight1/2,
		"left": windowWidth/2-popupWidth1/2
	});		
	$("#cvvbackgroundPopup").css({
		"height": windowHeight
	});	
}
$(document).ready(function(){
	$("#cvv-button").click(function(){
		centerPopup1();
		loadPopup1();
	});
	$("#cvvpopupClose").click(function(){
		disablePopup1();
	});
	$("#cvvbackgroundPopup").click(function(){
		disablePopup1();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus1==1){
			disablePopup1();
		}
	});
});

/*----------------- Pop-Up Login / Buy --------------------*/

var popupStatus6 = 0;

function loadPopup6(){

	if(popupStatus6==0){
		$("#cartbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#cartbackgroundPopup").fadeIn("slow");
		$("#popupCART").fadeIn("slow");
		popupStatus6 = 1;
	}
}

function disablePopup6(){	
	if(popupStatus6==1){
		$("#cartbackgroundPopup").fadeOut("slow");
		$("#popupCART").fadeOut("slow");
		popupStatus6 = 0;
	}
}

function centerPopup6(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight6 = $("#popupCART").height();
	var popupWidth6 = $("#popupCART").width();	
	$("#popupCART").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight6/2,
		"left": windowWidth/2-popupWidth6/2
	});		
	$("#cartbackgroundPopup").css({
		"height": windowHeight
	});	
}
function runAddLogin() {
	centerPopup6();
	loadPopup6();
}
$(document).ready(function(){
	$("#cart_LOGIN").click(function(){
	parent.location.replace('http://www.ethics.net');
	location.reload();	
	});	
	
	$("#cart-button").click(function(){
		centerPopup6();
		loadPopup6();
	});
	$("#cartpopupClose").click(function(){
		disablePopup6();
	});
	$("#cartbackgroundPopup").click(function(){
		disablePopup6();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus6==1){
			disablePopup6();
		}
	});
});
/*----------------- Pop-Up 2 Memberships Warning --------------------*/
var popupStatus7 = 0;

function loadPopup7(){

	if(popupStatus7==0){
		$("#wrnbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#wrnbackgroundPopup").fadeIn("slow");
		$("#popupWAR").fadeIn("slow");
		popupStatus7 = 1;
	}
}

function disablePopup7(){	
	if(popupStatus7==1){
		$("#wrnbackgroundPopup").fadeOut("slow");
		$("#popupWAR").fadeOut("slow");
		popupStatus7 = 0;
	}
}

function centerPopup7(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight7 = $("#popupWAR").height();
	var popupWidth7 = $("#popupWAR").width();	
	$("#popupWAR").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight7/2,
		"left": windowWidth/2-popupWidth7/2
	});		
	$("#wrnbackgroundPopup").css({
		"height": windowHeight
	});	
}
function runDoubleMembershipPopup() {
	centerPopup7();
	loadPopup7();
}
$(document).ready(function(){
	$("#wrn-button").click(function(){
		centerPopup7();
		loadPopup7();
	});
	$("#wrnpopupClose").click(function(){
		disablePopup7();
	});
	$("#wrnbackgroundPopup").click(function(){
		disablePopup7();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus7==1){
			disablePopup7();
		}
	});
});

/*----------------- Pop-Up Captcha --------------------*/
var popupStatus2 = 0;

function loadPopup2(){

	if(popupStatus2==0){
		$("#capbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#capbackgroundPopup").fadeIn("slow");
		$("#popupCAP").fadeIn("slow");
		popupStatus2 = 1;
	}
}

function disablePopup2(){	
	if(popupStatus2==1){
		$("#capbackgroundPopup").fadeOut("slow");
		$("#popupCAP").fadeOut("slow");
		popupStatus2 = 0;
	}
}

function centerPopup2(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight2 = $("#popupCAP").height();
	var popupWidth2 = $("#popupCAP").width();	
	$("#popupCAP").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight2/2,
		"left": windowWidth/2-popupWidth2/2
	});		
	$("#capbackgroundPopup").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){
	$("#cap-button").click(function(){
		centerPopup2();
		loadPopup2();
	});
	$("#cappopupClose").click(function(){
		disablePopup2();
	});
	$("#capbackgroundPopup").click(function(){
		disablePopup2();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus2==1){
			disablePopup2();
		}
	});
});

/*----------------- Pop-Up Silver --------------------*/
//Set-Up Pop-Up
//0 means disabled; 1 means enabled;
var popupStatus3 = 0;

//loading popup with jQuery
function loadPopup3(){
	//loads popup only if it is disabled
	if(popupStatus3==0){
		$("#silbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#silbackgroundPopup").fadeIn("slow");
		$("#popupSilver").fadeIn("slow");
		popupStatus3 = 1;
	}
}

//disabling popup with jQuery
function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus3==1){
		$("#silbackgroundPopup").fadeOut("slow");
		$("#popupSilver").fadeOut("slow");
		popupStatus3 = 0;
	}
}

//Centering Popup
function centerPopup3(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight3 = $("#popupSilver").height();
	var popupWidth3 = $("#popupSilver").width();
	//centering
	$("#popupSilver").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight3/2,
		"left": windowWidth/2-popupWidth3/2
	});
	//only need force for IE6	
	$("#silbackgroundPopup").css({
		"height": windowHeight
	});
	
}

//Control Events in jQuery
$(document).ready(function(){
	
	//LOADING POPUP
	//Click the button event
	$("#silver-button").click(function(){
		//centering with css
		centerPopup3();
		//load popup
		loadPopup3();
	});
				
	//CLOSING POPUP
	//Click the x event
	$("#silpopupClose").click(function(){
		disablePopup3();
	});
	//Click out event
	$("#silbackgroundPopup").click(function(){
		disablePopup3();
	});
	//Press escape event
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus3==1){
			disablePopup3();
		}
	});

});

/*----------------- Pop-Up Gold --------------------*/
var popupStatus4 = 0;

function loadPopup4(){

	if(popupStatus4==0){
		$("#goldbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#goldbackgroundPopup").fadeIn("slow");
		$("#popupGold").fadeIn("slow");
		popupStatus4 = 1;
	}
}

function disablePopup4(){	
	if(popupStatus4==1){
		$("#goldbackgroundPopup").fadeOut("slow");
		$("#popupGold").fadeOut("slow");
		popupStatus4 = 0;
	}
}

function centerPopup4(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight4 = $("#popupGold").height();
	var popupWidth4 = $("#popupGold").width();	
	$("#popupGold").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight4/2,
		"left": windowWidth/2-popupWidth4/2
	});		
	$("#goldbackgroundPopup").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){
	$("#gold-button").click(function(){
		centerPopup4();
		loadPopup4();
	});
	$("#goldpopupClose").click(function(){
		disablePopup4();
	});
	$("#goldbackgroundPopup").click(function(){
		disablePopup4();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus4==1){
			disablePopup4();
		}
	});
});
/*----------------- Pop-Up Plat --------------------*/
var popupStatus5 = 0;

function loadPopup5(){

	if(popupStatus5==0){
		$("#platbackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#platbackgroundPopup").fadeIn("slow");
		$("#popupPlat").fadeIn("slow");
		popupStatus5 = 1;
	}
}

function disablePopup5(){	
	if(popupStatus5==1){
		$("#platbackgroundPopup").fadeOut("slow");
		$("#popupPlat").fadeOut("slow");
		popupStatus5 = 0;
	}
}

function centerPopup5(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight5 = $("#popupPlat").height();
	var popupWidth5 = $("#popupPlat").width();	
	$("#popupPlat").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight5/2,
		"left": windowWidth/2-popupWidth5/2
	});		
	$("#platbackgroundPopup").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){
	$("#plat-button").click(function(){
		centerPopup5();
		loadPopup5();
	});
	$("#platpopupClose").click(function(){
		disablePopup5();
	});
	$("#platbackgroundPopup").click(function(){
		disablePopup5();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus5==1){
			disablePopup5();
		}
	});
});


/*----------------- Trial Details --------------------*/

var popupStatus9 = 0;

function loadPopup9(){

	if(popupStatus9==0){
		$("#trialBackgroundPopup").css({
			"opacity": "0.7"
		});
		$("#trialBackgroundPopup").fadeIn("slow");
		$("#popupTrial").fadeIn("slow");
		popupStatus9 = 1;
	}
}

function disablePopup9(){	
	if(popupStatus9==1){
		$("#trialBackgroundPopup").fadeOut("slow");
		$("#popupTrial").fadeOut("slow");
		popupStatus9 = 0;
	}
}

function centerPopup9(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight6 = $("#popupTrial").height();
	var popupWidth6 = $("#popupTrial").width();	
	$("#popupTrial").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight6/2,
		"left": windowWidth/2-popupWidth6/2
	});		
	$("#trialBackgroundPopup").css({
		"height": windowHeight
	});	
}

$(document).ready(function(){
	$("#trial-button").click(function(){
		centerPopup9();
		loadPopup9();
	});
	$("#trialpopupClose").click(function(){
		disablePopup9();
	});
	$("#trialbackgroundPopup").click(function(){
		disablePopup9();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus9==1){
			disablePopup9();
		}
	});
});

/*----------------- Ethics Pledge --------------------*/
var pledgeStatus = 0;

function loadPopPledge(){

	if(pledgeStatus==0){
		$("#pledgeBackground").css({
			"opacity": "0.7"
		});
		$("#pledgeBackground").fadeIn("slow");
		$("#pledgeForeground").fadeIn("slow");
		pledgeStatus = 1;
	}
}

function disablePopPledge(){	
	if(pledgeStatus==1){
		$("#pledgeBackground").fadeOut("slow");
		$("#pledgeForeground").fadeOut("slow");
		pledgeStatus = 0;
	}
}

function centerPopPledge(){	
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight1 = $("#pledgeForeground").height();
	var popupWidth1 = $("#pledgeForeground").width();	
	$("#pledgeForeground").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight1/2,
		"left": windowWidth/2-popupWidth1/2
	});		
	$("#pledgeBackground").css({
		"height": windowHeight
	});	
}
$(document).ready(function(){
	$("#pledge-button").click(function(){
		centerPopPledge();
		loadPopPledge();
	});
	$("#pledgeClose").click(function(){
		disablePopPledge();
	});
	$("#pledgeBackground").click(function(){
		disablePopPledge();
	});
	$(document).keypress(function(e){
		if(e.keyCode==27 && pledgeStatus==1){
			disablePopPledge();
		}
	});
});


