// JavaScript Document ----- This script should create a screen-dimming message popup function

jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
};

function makeOverlay() {
	$('body').append('<div id="dimmer" class="dimmer" style="width:'+ $(window).width() + 'px; height:' + $(window).height() +'px; position:fixed; left:0px; top:0px; background-color:#000000; display:none;">&nbsp;</div>');
	$('#popWrap').appendTo('body');
};

function contentLoad(loc)
{
	/* if( $("loc:contains(';')") ) {
		loc=loc.slice(0, loc.indexOf(";") );
	} */
$("#POPtitle").load(loc+' #headline');
$("#popMessage").load(loc+' #message');
}





function popup(loc) {
	$('#popWrap').detach().appendTo('body');
	$('#popWrap').appendTo('body');
	contentLoad(loc);
	$('#popWrap').center().hide(0).fadeIn('fast');
}

function fullpop(loc) {
	$('#popWrap').detach().appendTo('body');
	contentLoad(loc);
	makeOverlay();
	$('#dimmer').hide(0).fadeTo('normal',.5, function() {$('#popWrap').center().hide(0).fadeIn('normal');});
}

function closeAlert() {
	$('#popWrap').fadeOut('slow');
	$('#dimmer').fadeOut('slow');
}

$(document).ready( function() {

	try{
	  if(msgLoc != undefined) {
		  contentLoad(msgLoc);
		  makeOverlay();
		  $('#dimmer').hide(0).fadeTo('normal',.5, function() {$('#popWrap').center().hide(0).fadeIn('normal');});
	  }
	}
	catch(err){}
	
	

	$('#close-button').click( function() {
		closeAlert();
	});


	
});