// JavaScript Document
var lPosLeft='100px';
var lPosTop='100px';
var pWidth='494';
var pHeight='400';
var docHeight;
var docWidth;

function getDocDims(){
    docHeight = Math.max(
				$(document).height(), 
				$(window).height(),
				/* For opera: */
        document.documentElement.clientHeight
    	)+'px';
    docWidth = Math.max(
				$(document).width(), 
				$(window).width(),
				/* For opera: */
        document.documentElement.clientWidth
    	)+'px';
};

function hidePopup(){
		$('#eventPopupContent').animate({'width':'0px', 'height':'0px'}, 400);
		$('#eventPopup').animate({'width':'0px', 'height':'0px'}, 500);
		$('#pageBlind').animate({'opacity':'1'},500, function(){$('#eventPopupBlind').css({'width':'0px', 'height':'0px'});});
	}

function showPopup(){
		$('#eventPopupBlind').css({'width':docWidth, 'height':docHeight});
		$('#pageBlind').animate({'opacity':'0.3'}, 500)
		$('#eventPopup').css({'top':lPosTop, 'left':lPosLeft}).animate({'width':'594px', 'height':'430px'}, 500);
		$('#eventPopupContent').animate({'width':'514px', 'height':'335px'}, 450);
}

function getEventPage(l, url){
    var vHeight=$(window).height();
		var vScrollY=$(window).scrollTop(); 
		var lPos=$('#'+l).offset();
		lPosLeft=(parseInt(lPos.left)-(parseInt(pWidth)/2));
		lPosTop=(parseInt(lPos.top)-parseInt(pHeight)-40);
		if(lPosLeft < 25){lPosLeft=25;}
		if(lPosTop < parseInt(vScrollY)+25){lPosTop=parseInt(vScrollY)+25;}
		lPosLeft = lPosLeft+'px';
		lPosTop = lPosTop+'px';
		$('#eventPopupContent').empty().load(encodeURI(url), showPopup());
	}
	
function initPopups(){
		getDocDims();
	}
	
$(document).ready(function(){initPopups();});
