

function popUp(titleText, bodyText, flag, flagalttext, footerText, footerLink)
{
	var popUpWindow = document.getElementById('calendarPopUpScreen');
	var popUpFooterBtn = document.getElementById('popUpFooterBtn');
	var popUpCloseBtn = document.getElementById('popUpCloseBtn');
	var popUpFlag = document.getElementById('imgFlag');
	
	// If a footerLink has been parsed then set the href
	if(footerLink)
	{
	    popUpFooterBtn.className = 'visible';
		popUpFooterBtn.setAttribute('href', footerLink);
	}
	else
	{
	    popUpFooterBtn.className = 'hidden';
	}
	
	if(footerText)
	{
		document.getElementById('popUpFooterText').innerHTML = footerText;
	}
	
	if(flag)
	{
	    popUpFlag.setAttribute('src', flag);
	    popUpFlag.setAttribute('alt', flagalttext);
	}
	
	// Close the PpopUp when link is clicked
	popUpFooterBtn.onclick = popUpCloseBtn.onclick = hidePopUp;
	
	// Populate content with parsed data
	updateText();
	
	function updateText()
	{
		document.getElementById('popUpTitle').innerHTML = titleText;
		document.getElementById('popUpMainText').innerHTML = bodyText;
		//document.getElementById('popUpFooterText').innerHTML = footerText;
        //document.getElementById('popUpFooterText').setAttribute('href', footerLink);
		positionPopUp();
		showPopUp();
	}
	
	function showPopUp()
	{
		popUpWindow.className = 'visiblePopUp';
	}
	
	function hidePopUp()
	{
		popUpWindow.className = 'hiddenPopUp';
	}
	
	// position the popUp in the middle of the page
	function positionPopUp()
	{
		var winWidth = getClientWidth();
		var winHeight = getClientHeight();
		
		var popUpWidth = popUpWindow.style.width;
		var popUpHeight = popUpWindow.style.height;
		popUpWindow.style.top = getScrollTop()+"px";
	}
	
	//-------------------------------------------------------------------------------------
	// Functions returns an array of all elements of a node with a with a given className 

   	function getElementsByClassName(classname, node)  {
		if(!node) node = document.getElementsByTagName("body")[0];
		var a = [];
		var re = new RegExp('\\b' + classname + '\\b');
		var els = node.getElementsByTagName("*");
		for(var i=0,j=els.length; i<j; i++)
			if(re.test(els[i].className))a.push(els[i]);
		return a;
	}

	//-------------------------------------------------------------------------------------
	// Functions to retrieve window size and scroll position in all browsers
	
	function getClientWidth() {
		return getFilterResults (
			window.innerWidth ? window.innerWidth : 0,
			document.documentElement ? document.documentElement.clientWidth : 0,
			document.body ? document.body.clientWidth : 0
		);
	}
	function getClientHeight() {
		return getFilterResults (
			window.innerHeight ? window.innerHeight : 0,
			document.documentElement ? document.documentElement.clientHeight : 0,
			document.body ? document.body.clientHeight : 0
		);
	}
	function getScrollLeft() {
		return getFilterResults (
			window.pageXOffset ? window.pageXOffset : 0,
			document.documentElement ? document.documentElement.scrollLeft : 0,
			document.body ? document.body.scrollLeft : 0
		);
	}
	function getScrollTop() {
		return getFilterResults (
			window.pageYOffset ? window.pageYOffset : 0,
			document.documentElement ? document.documentElement.scrollTop : 0,
			document.body ? document.body.scrollTop : 0
		);
	}
	function getFilterResults(n_win, n_docel, n_body) {
		var n_result = n_win ? n_win : 0;
		if (n_docel && (!n_result || (n_result > n_docel)))
			n_result = n_docel;
		return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
	}
	//-------------------------------------------------------------------------------------

}



