/** CONSTANTS ***/
var winPosTop  = 100;
var winPosLeft = 100;

/** GLOBALLY USED VARIABLES ***/
var winName = "calcPop";
var winStats;
var winWasOpened = false;
var floater;

/** DEFAULT WINDOW SIZES ***/
var smallCode      = "small";
var smallWinWidth  = 304;
var smallWinHeight = 225;
var highCode       = "high";
var highWinWidth   = 304;
var highWinHeight  = 450;
var wideCode       = "wide";
var wideWinWidth   = 450;
var wideWinHeight  = 225;

/** FUNCTIONS USED BY OTHER FUNCTIONS ***/
function setWinStats(theWidth,theHeight,theMenu,theStatus) { // SET PROPERTIES FOR NEW WINDOW
		closeOtherPopups();

		var showMenu = "no";
		var showStatus = "yes";
		var winWidth;
		var winHeight;
		if(theWidth==smallCode) {
			winWidth  = smallWinWidth;
			winHeight = smallWinHeight;
		}
		else if(theWidth==highCode) {
			winWidth  = highWinWidth;
			winHeight = highWinHeight;
		}
		else if(theWidth==wideCode) {
			winWidth  = wideWinWidth;
			winHeight = wideWinHeight;
		}
		else {
			winWidth  = theWidth;
			winHeight = theHeight;
		}
		winStats =  'width='+winWidth+',height='+winHeight;

		if(theMenu=="yes") {
			showMenu = "yes";
		}
		if(theStatus=="no") {
			showStatus = "no";
		}

		winStats += ',toolbar=no,location=no,directories=no,menubar='+showMenu+',status='+showStatus+',scrollbars=yes,resizable=yes,';
		if (navigator.appName.indexOf("Microsoft")>=0) winStats+='left='   +winPosLeft+',top='    +winPosTop+',';
		else                                           winStats+='screenX='+winPosLeft+',screenY='+winPosTop+',';
}
function openNewWin(theURL,theStats) {
		floater=window.open(theURL,winName,theStats);
		winWasOpened = true;
}
function closeOtherPopups() {
		if (floater && !floater.closed) floater.close();
}
function randomiseWinName() { // NEW WINNAME = NEW WINDOW FOR EACH CALL
		winName = Math.round(Math.random()*1000);
}

/*** FUNCTIONS USED TO DISPATCH OR OPEN POP-UPS ***/
<!-- OPEN NEW WIN WITH URL ---------------------------------------------------//-->
function openInfoPop(url,width,height,menu,status){
  setWinStats(width,height,menu,status);
  openNewWin(url,winStats);
}

<!-- OPEN NEW POP WITH URL ----------------------------------------------------//-->
function openCustomPopURL(url,width,height,menu){
  setWinStats(width,height,menu);
  randomiseWinName();
  openNewWin(url,winStats);
}

