///* JQuery Popup Settings 	*/////
///* File Effected: Product.php, tab: Insulating Glass(IG) */

//0 means disabled; 1 means enabled;
var popupStatusIG = 0;

////////////////////////////////////////////////////////////
//// Global Variables - Based on <DIV> "id" attributes  ////
////////////////////////////////////////////////////////////

var popupIG = ("#popup_IGFeatBenefits, #popup_IGUnitDefined, #popup_IGIllustration");
var closePopupIG =("#popup_Close");
var bgroundPopupIG = ("#backgroundPopup");
var fadeInPopupIG = ("fast"); 

function loadPopupIG1(){
	//loads popup only if it is disabled
	if(popupStatusIG==0){
		$(bgroundPopupIG).css({
		"opacity": "0.4"
	});
	$(bgroundPopupIG).fadeIn(fadeInPopupIG);
	$("#popup_IGFeatBenefits").fadeIn(fadeInPopupIG);
	popupStatusIG = 1;
	}
}

function loadPopupIG2(){
	//loads popup only if it is disabled
	if(popupStatusIG==0){
		$(bgroundPopupIG).css({
		"opacity": "0.4"
	});
	$(bgroundPopupIG).fadeIn(fadeInPopupIG);
	$("#popup_IGUnitDefined").fadeIn(fadeInPopupIG);
	popupStatusIG = 1;
	}
}

function loadPopupIG3(){
	//loads popup only if it is disabled
	if(popupStatusIG==0){
		$(bgroundPopupIG).css({
		"opacity": "0.4"
	});
	$(bgroundPopupIG).fadeIn(fadeInPopupIG);
	$("#popup_IGIllustration").fadeIn(fadeInPopupIG);
	popupStatusIG = 1;
	}
}


////////////////////////////////////////////////
//// GLOBAL disabling POPUP FUNCTION ////
////////////////////////////////////////////////

function disablePopupIG(){
	//disables popup only if it is enabled
	if(popupStatusIG==1){
		$(bgroundPopupIG).fadeOut(fadeInPopupIG);
		$(popupIG).fadeOut(fadeInPopupIG);
		popupStatusIG = 0;
	}
}
////////////////////////////////////////////////
//// GLOBAL CENTER POPUP ON SCREEN FUNCTION ////
////////////////////////////////////////////////

function centerPopupIG(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $(popupIG).height();
	var popupWidth = $(popupIG).width();
	
	//centering
	$(popupIG).css({
		"position": "absolute","top": windowHeight/2-popupHeight/2, "left":windowWidth/2-popupWidth/2
	});
	//only need force for IE6
	$(bgroundPopupIG).css({
	"height": windowHeight
	});
}

$(document).ready(function(){
//Click the button event!
	$("#Prod_IG_btn-1").click(function(){
	//centering with css
	centerPopupIG();
	//load popup
	loadPopupIG1();
	//window.alert("I am an alert box");
	});
	
	$("#Prod_IG_btn-2").click(function(){
	//centering with css
	centerPopupIG();
	//load popup
	loadPopupIG2();
	//window.alert("I am an alert box");
	});
	
	$("#Prod_IG_btn-3").click(function(){
	//centering with css
	centerPopupIG();
	//load popup
	loadPopupIG3();
	//window.alert("I am an alert box");

	});

///////////////////////////////
//// GLOBAL CLOSE FUNCTION POPUP ////
///////////////////////////////

//Click the popup x event!
	// USES inline script that references function disablePopupIG(){} //	

//CLOSING BLACK BACGROUND POPUP 
	//Click out event!
	$(bgroundPopupIG).click(function(){
		disablePopupIG();
	});

//Press Escape event!
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatusIG==1){
			disablePopupIG();
		}
	});	
});



