//var popup_manager = "jpopupmanager.php"; //This controls the popup pages

//builds the popup by the src parameter (basically calls jpopupmanager and gives it a page)
//function build_popup(src) {
//		var src_string = popup_manager + "?p=" + src;
//		$.get(src_string, function(data){
//						$("#jpopup_content").html(data);
//					});
//}

//Loads the popup content, attempted fix on the PHP issues.
function popup_load(src){
	var url = "jpopupmanager.php?p=" + src;
	$("#jpopup_content").load(url);
}

//Center's the popup
function center(num){
	num = parseInt(num);
	num = 100 - num;
	num = num / 2;
	return num;
}

//after the popup has been created, it doesn't resize with the page.
function fix_size(){
	var h = $("#jpopup").height();
	var w = $("#jpopup").width();
		if(h < 200){
			h = 200;
			$("#jpopup").css({"height" : h + 'px'});
		}
		if(w < 400){
			w = 400;
			$("#jpopup").css({"width" : w + 'px'});
		}
}

///Page Fade, in and out
function fade_out(){
		$("#jblackout").css("width","100%");
		$("#jblackout").css("height","100%");
			}
			
function fade_in() {
		$("#jblackout").css("width","0");
		$("#jblackout").css("height","0");
			}
////End Page Fade in and out

///popup function (displays the #jpopup element)
function popup_display(src, h, w) {
		popup_load(src);
		fade_out();
		var c_h = center(h);
		var c_w = center(w);
		var css = {
		'height' : h + "%",
		'width' : w + "%",
		'top' : c_h + "%",
		'left' : c_w + "%"
		}
		$("#jpopup").css(css);
		fix_size();
	}
	
function popup_close() {
		var css = {
		'position' : 'absolute',
		'top' : '-500px',
		'left' : '-500px'
		}
		$("#jpopup").css(css);
		$("#jpopup_content").html("");
		fade_in();
	}
///end popup function