var popupStatus = 0;


//loading popup with jQuery magic!
function loadPopup(){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#popupContact").fadeIn("slow");
			var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact").height();
		var popupWidth = $("#popupContact").width();
		//centering
		$("#popupContact").css({
			"position": "absolute",
			"top": windowHeight/2+popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		popupStatus = 1;
		}
}

function loadPopup2(str){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#popupContact2").fadeIn("slow");
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact2").height();
		var popupWidth = $("#popupContact2").width();
		//centering
		$("#popupContact2").css({
			"position": "absolute",
			"top": windowHeight/2+popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		popupStatus = 1;
		document.getElementById('holder2').innerHTML = "<iframe src='../functions/email.php?id="+str+"' style=\"border:0\" frameborder='none' width='1090' height='920'></iframe>";
		}
}

function loadPopup3(str){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#popupContact3").fadeIn("slow");
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact3").height();
		var popupWidth = $("#popupContact3").width();
		//centering
		$("#popupContact3").css({
			"position": "absolute",
			"top": windowHeight/2+popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		popupStatus = 1;
		document.getElementById('holder3').innerHTML = "<iframe src='../functions/requestviewing.php?id="+str+"' style=\"border:0\" frameborder='none' width='400' height='920'></iframe>";
		}
}

function loadPopup4(str){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#popupContact4").fadeIn("slow");
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact4").height();
		var popupWidth = $("#popupContact4").width();
		//centering
		$("#popupContact4").css({
			"position": "absolute",
			"top": windowHeight/2+popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		popupStatus = 1;		
		document.getElementById('holder4').innerHTML = "<iframe src='../functions/phone.php?id="+str+"' style=\"border:0\" frameborder='none' width='1090' height='920'></iframe>";
	}
}

function loadPopup5(str){
	//loads popup only if it is disabled
	if(popupStatus==0){
		$("#popupContact5").fadeIn("slow");
		var windowWidth = document.documentElement.clientWidth;
		var windowHeight = document.documentElement.clientHeight;
		var popupHeight = $("#popupContact5").height();
		var popupWidth = $("#popupContact5").width();
		//centering
		$("#popupContact5").css({
			"position": "absolute",
			"top": windowHeight/2+popupHeight/2,
			"left": windowWidth/2-popupWidth/2
		});
		popupStatus = 1;		
		document.getElementById('holder5').innerHTML = "<iframe src='../functions/emailfriend.php?id="+str+"' style=\"border:0\" frameborder='none' width='1090' height='920'></iframe>";
	}
}

//disabling popup with jQuery magic!
function disablePopup(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#popupContact").fadeOut("slow");
		popupStatus = 0;
	}
}


function disablePopup4(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#popupContact4").fadeOut("slow");
		popupStatus = 0;
	}
}
function disablePopup2(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#popupContact2").fadeOut("slow");
		popupStatus = 0;
	}
}

function disablePopup3(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#popupContact3").fadeOut("slow");
		popupStatus = 0;
	}
}

function disablePopup5(){
	//disables popup only if it is enabled
	if(popupStatus==1){
		$("#popupContact5").fadeOut("slow");
		popupStatus = 0;
	}
}

//CONTROLLING EVENTS IN jQuery
$(document).ready(function(){
	$("#popupContactClose").click(function(){
		disablePopup();
	});
});

$(document).ready(function(){
	$("#popupContactClose2").click(function(){
		disablePopup2();
	});
});

