// JavaScript Document

function getURLParam( name )
{
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var tmpURL = unescape(window.location.href);
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

// Current Page Reference
function getURL(uri) {
uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
uri.file = uri.page;
if (uri.ext != '') uri.file += '.' + uri.ext;
if (uri.file == '') uri.page = 'index';
uri.args = location.search.substr(1).split("?");
return uri;
}

function OpenNewWindow(Url, Width, Height)
{
	window.open(Url, '_blank', 'toolbar=no,menubar=no,title,location=no,status=no,resizable=yes,scrollbars=yes,' + WindowOpenFeaturesCentered(Width, Height));
}

function OpenNewFixedWindow(Url, Width, Height)
{
	window.open(Url, '_blank', 'toolbar=no,menubar=no,title,location=no,status=no,resizable=no,scrollbars=no,' + WindowOpenFeaturesCentered(Width, Height));
}

function WindowOpenFeaturesCentered(width, height, mode)
{
	return("width=" + width + ",height=" + height + "," + CenterDialogPosition(width, height, mode));
}

function CenterDialogPosition(dialogWidth, dialogHeight, positionMode)
{
	// return window.open string with top and left properties specified
	
	//var bCenterOnScreen = false;
	//var bCenterOnOwner = true;
	
	if (positionMode == null)
		positionMode = 1;
	
	// Center on same screen as current window
	if (positionMode == 1)
	{
		var p_left = (window.screen.availWidth / 2) - (dialogWidth / 2);
		var p_top = (window.screen.availHeight / 2) - (dialogHeight / 2);
	
		var screenNo = Math.ceil((window.screenLeft+1) / window.screen.availWidth);
	
		p_left += (screenNo - 1) * window.screen.availWidth;
	
		var s = "top=" + p_top + ",left=" + p_left;
	}
	
	// Center on owner window
	if (positionMode == 2)
	{
		var lWindowCaptionHeight = 20;
		var p_left = window.top.screenLeft + (window.top.document.body.scrollWidth / 2) - (dialogWidth / 2);
		var p_top = window.top.screenTop + (window.top.document.body.scrollHeight / 2) - (dialogHeight / 2) - lWindowCaptionHeight;
	
		//var screenNo = Math.ceil((window.screenLeft+1) / window.screen.availWidth);
	
		//p_left += (screenNo - 1) * window.screen.availWidth;
	
		var s = "top=" + p_top + ",left=" + p_left;
	}
	
	// Maximise on opposite screen to current window
	if (positionMode == 3)
	{
		// Hidden component on login screen obtained the screen count
		
		var lTaskBarHeight = 30;
		var lChromeWidth = 6;
		
		var p_left = (window.screen.availWidth / 2) - (dialogWidth / 2) - lChromeWidth;
		var p_top = ((window.screen.availHeight - lTaskBarHeight)/ 2) - (dialogHeight / 2);

		// screenNo = 1, 2, ...	
		var screenNo = Math.ceil((window.screenLeft+1) / window.screen.availWidth);
		
		//alert(window.screenLeft);

		// screenNo (2 -> 0, 1 -> 1)
		//alert(screenNo);
		screenNo = lScreenCount - screenNo;
		//alert(p_left);
		p_left += (screenNo * window.screen.availWidth);
		//alert(p_left);
	
		var s = "top=" + p_top + ",left=" + p_left;
	}

	return (s);
}




                  
