//JQuery popup

var popupStatus = 0;

function loadPopup(){
	//enable
	if(popupStatus==0){
		$("#bgPopup").css({
			"opacity": "0.65"
		});
		$("#bgPopup").fadeIn("slow");
		$("#popup").fadeIn("slow");
		popupStatus = 1;
	}
}

function disablePopup(){
	//disable
	if(popupStatus==1){
		$("#bgPopup").fadeOut("normal");
		$("#popup").fadeOut("normal");
		popupStatus = 0;
	}
}

//centering popup
function centerPopup(){
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = $("#popup").height();
	var popupWidth = $("#popup").width();
	
	var s = '<iframe height="340" width="600" scrolling="no" src="contact_rep.aspx" frameborder="0" marginwidth="0" marginheight="0" />';
	$("div#popcontent").html(s);
	
	$("#popup").css({
		"position": "absolute",
		"top": windowHeight/2-popupHeight/2,
		"left": windowWidth/2-popupWidth/2
	});

	//only need force for IE6
	$("#bgPopup").css({
		"height": windowHeight
	});
	
	
	
}

$(document).ready(function(){


	
	$("#quoter").click(function(){

		centerPopup();
		loadPopup();
	});
	//hit x
	$("#popupClose").click(function(){
		disablePopup();
	});
	//click out
	$("#bgPopup").click(function(){
		disablePopup();
	});
	//press escape
	$(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

});
