
//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;


//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#PopupBackground").css({
		"opacity": "0.7"
		});
	
		$("#PopupBackground").fadeIn("slow");
			
		$("#popupWindow").fadeIn("slow");
	
		popupStatus = 1;
	}
}


//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#PopupBackground").fadeOut("slow");
			
		$("#popupWindow").fadeOut("slow");
		
		popupStatus = 0;
	}
}


//centering popup
function centerPopup(){
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var WscrollHeight = document.documentElement.scrollHeight;
	var popupHeight = $("#popupWindow").height();
	var popupWidth = $("#popupWindow").width();
	var scrolled =  $("html").scrollTop();
	//centering
	
	$("#popupWindow").css({
	"position": "absolute",
	"top": scrolled + 50,
	//"top": 50,
	"left": windowWidth/2-popupWidth/2
	});
//only need force for IE6

	$("#PopupBackground").css({
	"height": windowHeight+100
	});

}


$(document).ready(function(){

	$(".button_pop").click(function(){
		centerPopup();
		loadPopup();
	});

	$(".PopupClose").click(function(){
	disablePopup();
	});
	
	
	//loadPopup();


});

function changeframe(new_height)
{
	//parent.window.document.getElementById('myframe').style.height = 600;
	
	var iframe = parent.document.getElementById("myframe");
	iframe.height = new_height + "px";
}

function closeModal() {
var btnClose = parent.document.getElementById('.PopupClose');
btnClose.click();
return false;
}

