﻿function getRandomNumber()
{return (Math.round((Math.random()*51+1)))}

function OpenPopup(aUrl, aWidth, aHeight)
{
	var left = (window.screen.width)/2 - aWidth;
	var top = (window.screen.height)/2 - aHeight;
	var winProps = "width=" + aWidth + ",height=" + aHeight + ",noresize,toolbar=no,menubar=no,scrollbars=no,left=" + left + ",top=" + top;
	var randomNum = getRandomNumber();
	
	var popupUrl = aUrl;
	if(popupUrl.indexOf("http://") == -1)
	{
	    popupUrl = applicationRoot + popupUrl;
	}
	
	var winInst = open(popupUrl, "popUpWindow" + randomNum, winProps);
	winInst.focus();
	
	return winInst;
}

function OpenPopupSilent(aUrl, aWidth, aHeight)
{
	var popup = OpenPopup(aUrl, aWidth, aHeight);
}

function OpenScrollablePopup(aUrl, aWidth, aHeight)
{
	var left = (window.screen.width)/2 - aWidth;
	var top = (window.screen.height)/2 - aHeight;
	var winProps = "width=" + aWidth + ",height=" + aHeight + ",noresize,toolbar=no,menubar=no,scrollbars=yes,left=" + left + ",top=" + top;
	var randomNum = getRandomNumber();
	
	var popupUrl = aUrl;
	if(popupUrl.indexOf("http://") == -1)
	{
	    popupUrl = applicationRoot + popupUrl;
	}
	
	var winInst = open(popupUrl, "popUpWindow" + randomNum, winProps);
	winInst.focus();
	
	return winInst;
}

function OpenScrollablePopupSilent(aUrl, aWidth, aHeight)
{
	var popup = OpenScrollablePopup(aUrl, aWidth, aHeight);
}

function openExternalSite(aUrl)
{
	var winInst = open(aUrl, "externalSite");
	winInst.focus();
}