var popupStatus = 0;
function loadPopup()
{
if (popupStatus == 0)
{
$('div#popupBackground').css(
{
'opacity': '0.8'
});
$('div#popupBackground').fadeIn('slow');
$('div#popupBox').fadeIn('slow');
popupStatus = 1;
}
}
function centerPopup()
{
var windowWidth  = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var bodyHeight   = $('body').height();
var popupWidth   = $('div#popupBox').width();
var popupHeight  = $('div#popupBox').height();
$('div#popupBox').css(
{
'position': 'absolute',
'top'     : (windowHeight  / 2) - (popupWidth / 2),
'left'    : (windowWidth / 2) - (popupWidth  / 2)
});
$('div#popupBackground').css(
{
'height': windowHeight
});
}
function closePopup(func)
{
if (popupStatus == 1)
{
$('div#popupBackground').fadeOut('slow');
$('div#popupBox').fadeOut('slow', func);
popupStatus = 0;
}
}
function openPopup()
{
centerPopup();
loadPopup();
$(window).resize(function()
{
centerPopup();
});
$('div#popupBox .close, div#popupBackground').click(function()
{
closePopup();
return false;
});
$(document).keypress(function(e)
{
if (e.keyCode == 27)
{
closePopup();
}
});
}
function showPopup(link)
{
$('div#popupBox').load('/popuploader.asp', {option: link}, function(response, status, xhr)
{
if (status == 'error')
{
$('div#popupBox').html('<strong>Sorry, but we were unable to complete that request. The webmaster has been notified.</strong> (Message: ' + xhr.status + ' ' + xhr.statusText + ')');
}
$('div#popupBox').append('<div id="popupClose"><a href="#" id="closevideo">Close [x]</a><script type="text/javascript">$(document).ready(function(){$(\'#closevideo\').click(function(){closePopup()});});</script></div>');
closeMenuBottom(openPopup);
});
}
