﻿function loadP(valor) 
{
	$("#bdPopup").css({
		"opacity": 0.7, 
		"height": windowHeight
		});
	$("#bdPopup").fadeIn(300);
	
	div = '#' + valor;
	
	var windowWidth;
	var windowHeight;
	
	if (window.innerWidth || window.innerHeight)
	{ 
		windowWidth = window.innerWidth; 
		windowHeight = window.innerHeight; 
	} 
	//IE Mozilla 
	if (document.body.clientWidth || document.body.clientHeight)
	{ 
		windowWidth = document.body.clientWidth; 
		windowHeight = document.body.clientHeight; 
	}
	
	var popupHeight = $(div).height();
	var popupWidth = $(div).width();
	
	//centering
	if(navigator.appName == "Netscape") 
	{ 
		$(div).css({
		"top": "50%",
		"left": "50%",
		marginTop:"-"+(popupHeight/2)+"px",
		marginLeft:"-"+(popupWidth/2)+"px"
	});
	}
	else if(navigator.appName == "Microsoft Internet Explorer"	)
	{
		$(div).css({
			"left": "50%",
			marginLeft:"-"+(popupWidth/2)+"px"
		});
	}
	
	$(div).fadeIn(300);
	
	popupStatus = 1;
	
	$("#popClose").click(function() {
		$(this).add(div).fadeOut(300);
	});
	
	$(document).keypress(function(e) {
		if (e.keyCode == 27 && popupStatus == 1) {
			disablePopup();
		}
	});
}



function loader()
{
	var loader = document.getElementById("loader");
	$(loader).css({
		"top":"50%",
		"left":"50%",
		marginLeft:"-103px"
		})
	$(loader).show();
	
}

function centerLoader(loader) {
	//request data for centering
	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var loaderH = $(loader).height();
	var loaderW = $(loader).width();
	//centering
	$(loader).css({
		"top": "50%",
		"left": "50%",
		marginTop:"-17px",
		marginLeft:"-17px"
	});

}

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