function windowClose( result )
{
	returnValue = result;
	
	parent.initPopUp();
	
	parent.hidePopWin( true );

	//window.returnValue = result; window.close();
}

function showmodal(strURL, strWidth, strHeight, strScroll, callBackFunction, Param1 )
{	
	if(strScroll == null || strScroll == '')
	{
		strScroll = 'no';
	}
		
	if ( strHeight == "" || strHeight == "0" )
	{
		var fullHeight = getViewportHeight();

		strHeight = fullHeight - 60;
	}

	if ( strWidth == "" || strWidth == "0" )
	{
		var fullWidth = getViewportWidth();
		
		strWidth = fullWidth - 120;
	}

	if ( strURL.indexOf( 'styledReport' ) == -1 )
	{		
		initPopUp();
			
		showPopWin( strURL, parseInt( strWidth ), parseInt( strHeight ), callBackFunction, Param1 );
		
		return false;
	}
}



//********************************************
// Future screen utility
//
//********************************************
var FUTUREScreenUtil = function()
{
}

 FUTUREScreenUtil.prototype.addEvent = function(obj, evType, fn)
 {
	if (obj.addEventListener)
	{
		obj.addEventListener(evType, fn, true);
		return true;
	} else if (obj.attachEvent)
	{
		var r = obj.attachEvent("on"+evType, fn);
		return r;
	} else 
	{
		return false;
	}
}

FUTUREScreenUtil.prototype.removeEvent = function(obj, evType, fn, useCapture)
{
  if (obj.removeEventListener)
  {
    obj.removeEventListener(evType, fn, useCapture);
    return true;
  } else if (obj.detachEvent)
  {
    var r = obj.detachEvent("on"+evType, fn);
    return r;
  } else 
  {
    alert("Handler could not be removed");
  }
}

/**
* Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*
* Thanks for the code Scott!
*/

FUTUREScreenUtil.prototype.hideSelectBoxes = function() 
{
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if( (this.gHideSelects && document.forms[i].elements[e].tagName == "SELECT") 
				|| (this.gHideObjects && document.forms[i].elements[e].tagName == "OBJECT") ) {
				document.forms[i].elements[e].style.visibility="hidden";
			}
		}
	}
}

/**
* Makes all drop down form select boxes on the screen visible so they do not reappear after the dialog is closed.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*/
FUTUREScreenUtil.prototype.displaySelectBoxes = function() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if( (this.gHideSelects && document.forms[i].elements[e].tagName == "SELECT") 
				|| (this.gHideObjects && document.forms[i].elements[e].tagName == "OBJECT") ) {
				document.forms[i].elements[e].style.visibility="visible";
			}
		}
	}
}

FUTUREScreenUtil.prototype.getViewportHeight = function() 
{
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 

	return window.undefined; 
}
FUTUREScreenUtil.prototype.getViewportWidth  = function()
{
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 

	return window.undefined; 
}


// Future Mask 
var FUTUREMask = function( maskPNGUrl )
{
	// Init globals
	FUTUREMask.prototype.ScreenUtil = new FUTUREScreenUtil();

    this.PopupMask = document.createElement("div");
    
    this.PopupMask.setAttribute("id", "popupMask" );
    this.PopupMask.setAttribute("style", "position: absolute;	z-index: 200;	top: 0px;	left: 0px;	width: 100%;	height: 100%;	opacity: .4;	filter: alpha(opacity=40);	background-color:transparent !important;	background-color: #333333;	background-image: url(" + maskPNGUrl + ") !important;	background-repeat: repeat;	display:none;" );    

	//Make
	//document.write("<div id=\"popupMask\" style=\"	position: absolute;	z-index: 200;	top: 0px;	left: 0px;	width: 100%;	height: 100%;	opacity: .4;	filter: alpha(opacity=40);	background-color:transparent !important;	background-color: #333333;	background-image: url(" + maskPNGUrl + ") !important;	background-repeat: repeat;	display:none;\">&nbsp;</div>");
	
	//this.PopupMask = document.getElementById("popupMask");
	
	document.body.appendChild( this.PopupMask );
}

FUTUREMask.prototype.Show = function()
{
	var fullHeight = this.ScreenUtil.getViewportHeight();
	var fullWidth = this.ScreenUtil.getViewportWidth();	
	
	var theBody = document.documentElement;
	
	
	var scTop = parseInt(theBody.scrollTop,10);
	var scLeft = parseInt(theBody.scrollLeft,10);

	this.PopupMask.style.display = "block";	
	
	this.PopupMask.style.height = fullHeight + "px";
	this.PopupMask.style.width = fullWidth + "px";
	this.PopupMask.style.top = scTop + "px";
	this.PopupMask.style.left = scLeft + "px";
	
	this.hscroll = (document.all ? document.scrollLeft : window.pageXOffset);
	this.vscroll = (document.all ? document.scrollTop : window.pageYOffset);
	
	document.all ? window.attachEvent( 'onscroll', this.OnScroll ): window.addEventListener( 'scroll', this.OnScroll, false );
}

FUTUREMask.prototype.OnScroll = function ()
{
	window.scrollTo(this.hscroll, this.vscroll);		
}


FUTUREMask.prototype.Hide = function()
{
	this.PopupMask.style.display = "none";	
	
	document.all ? window.detachEvent( 'onscroll', this.OnScroll ): window.removeEventListener( 'scroll', this.OnScroll, false );
}

FUTUREMask.prototype.ScreenUtil = null;

FUTUREMask.prototype.PopupMask = null;

FUTUREMask.prototype.hscroll = 0;
FUTUREMask.prototype.vscroll = 0;


// Future Message Box
var FUTUREMessageBox = function( instanceName, width, height, buttons, type, value, action, actionParam, maskPNGUrl )
{
	// Init Global
	FUTUREMessageBox.prototype.Mask = new FUTUREMask(maskPNGUrl);
	
	FUTUREMessageBox.prototype.ScreenUtil = new FUTUREScreenUtil();

	// Properties
	this.InstanceName	= instanceName ;
	this.Width			= width			|| '100%' ;
	this.Height			= height		|| '200' ;
	
	this.Type			= type			|| 1 ;
	this.Buttons		= buttons		|| 1 ;
	
	this.Value			= value			|| '' ;
	this.Action			= action		|| '' ;
	this.ActionParam	= actionParam	|| '' ;
	
	this.BasePath		= '/messagebox/' ;
	this.CheckBrowser	= true ;
	this.DisplayErrors	= true ;

	this.Config			= new Object() ;

	// Events
	this.OnError		= null ;	// function( source, errorNumber, errorDescription )

    this.Create();		

	this.CenterMessage();
	
	this.Mask.Show();
}

FUTUREMessageBox.prototype.MessageMainDiv = null;

FUTUREMessageBox.prototype.Mask			= null;
FUTUREMessageBox.prototype.ScreenUtil	= null;

FUTUREMessageBox.prototype.btsOk		= "Ok";
FUTUREMessageBox.prototype.btsCancel	= "Odustani";
FUTUREMessageBox.prototype.btsYes		= "Da";
FUTUREMessageBox.prototype.btsNo		= "Ne";

FUTUREMessageBox.prototype.btOk			= 1;
FUTUREMessageBox.prototype.btCancel		= 2;
FUTUREMessageBox.prototype.btYes		= 4;
FUTUREMessageBox.prototype.btNo			= 8;
FUTUREMessageBox.prototype.btYesNo		= 12;
FUTUREMessageBox.prototype.btYesNoCancel = 14;
FUTUREMessageBox.prototype.btOkCancel	= 3;

FUTUREMessageBox.prototype.tNone		= 1;
FUTUREMessageBox.prototype.tQuestion	= 2;
FUTUREMessageBox.prototype.tWarning		= 4;
FUTUREMessageBox.prototype.tError		= 8;
FUTUREMessageBox.prototype.tInfo		= 16;

FUTUREMessageBox.prototype.Separator = "&nbsp";

FUTUREMessageBox.prototype.Version		= '1.0.0' ;
FUTUREMessageBox.prototype.VersionBuild	= '1' ;

FUTUREMessageBox.prototype.Create = function()
{
	//ocument.open();
	//document.write( this.CreateHtml() ) ;
	//document.close();
	
	if ( ! this.MessageMainDiv )
	{
		this.CreateHtml();
	}
	
	//this.MessageMainDiv = document.getElementById("message");
	
	//alert( this.MessageMainDiv );
}

FUTUREMessageBox.prototype.Hide = function()
{
	this.MessageMainDiv.style.display = "none";

	this.Mask.Hide();	
}

FUTUREMessageBox.prototype.CenterMessage = function()
{	
	var fullHeight = this.ScreenUtil.getViewportHeight();
	var fullWidth = this.ScreenUtil.getViewportWidth();
	
	var theBody = document.documentElement;
	
	var scTop = parseInt(theBody.scrollTop,10);
	var scLeft = parseInt(theBody.scrollLeft,10);
		
	this.MessageMainDiv.style.top = (scTop + ((fullHeight - (this.Height)) / 2)) + "px";
	this.MessageMainDiv.style.left =  (scLeft + ((fullWidth - this.Width) / 2)) + "px";
}


FUTUREMessageBox.prototype.CreateHtml = function()
{
	// Check for errors
	if ( !this.InstanceName || this.InstanceName.length == 0 )
	{
		this._ThrowError( 701, 'You must specify an instance name.' ) ;
		return ;
	}

	var sHtml = ''; //'<div id="message" style="position: absolute;z-index: 201; width:' + this.Width  + 'px; height:' + this.Height + ';">' ;

	this.MessageMainDiv = document.createElement("div");
	this.MessageMainDiv.setAttribute("id", "message" );
	this.MessageMainDiv.style.position = "absolute";
	this.MessageMainDiv.style.zIndex = "201"; 
	this.MessageMainDiv.style.width = this.Width; 
	this.MessageMainDiv.style.height = this.Height;	
	
	if ( !this.CheckBrowser || FUTUREMessageBox_IsCompatibleBrowser() )
	{	
		this.OkButtonNoAction = '<input OnClick="document.body.msgbox.Hide();" style=\'WIDTH: 85px; HEIGHT: 24px\' type=\'button\' value=\'' + this.btsOk + '\'>';
		
		this.OkButton = '<input OnClick="document.body.msgbox.Hide(); Anthem_FireCallBackEvent(this,event,\'' + this.Action + '\', \'' + this.btOk + '&' + this.ActionParam + '\',true,\'\',\'\',\'\',true,null,null,null,true,true);" style=\'WIDTH: 85px; HEIGHT: 24px\' type=\'button\' value=\'' + this.btsOk + '\'>';
		this.CancelButton = '<input OnClick="document.body.msgbox.Hide();" style=\'WIDTH: 85px; HEIGHT: 24px\' type=\'button\' value=\'' + this.btsCancel + '\'>';
		this.YesButton = '<input OnClick="document.body.msgbox.Hide();Anthem_FireCallBackEvent(this,event,\'' + this.Action + '\', \'' + this.btYes + '&' + this.ActionParam + '\',true,\'\',\'\',\'\',true,null,null,null,true,true);" style=\'WIDTH: 85px; HEIGHT: 24px\' type=\'button\' value=\'' + this.btsYes + '\'>';
		this.NoButton = '<input OnClick="document.body.msgbox.Hide();Anthem_FireCallBackEvent(this,event,\'' + this.Action + '\', \'' + this.btNo + '&' + this.ActionParam + '\',true,\'\',\'\',\'\',true,null,null,null,true,true);" style=\'WIDTH: 85px; HEIGHT: 24px\' type=\'button\' value=\'' + this.btsNo + '\'>';

		sHtml += '<table width=\'100%\' height=\'100%\' border=\'0\' bgcolor=\'#ffffff\'>';
		sHtml += '<tr><td valign=\'middle\' align=\'center\'>';
		sHtml += '<table width=' + (this.Width - 8) + ' height=' + (this.Height - 8) + ' cellpadding=\'0\' cellspacing=\'0\' border=\'2\' bordercolor=\'#000000\' bgcolor=\'#ffffe1\'>';
		sHtml += '<tr><td>';
		sHtml += '<table border=\'0\' width=\'100%\' height=\'100%\'>';
		sHtml += '<tr><td align=\'left\'>';
		sHtml += '<div style=\'scrollbar-base-color: #FFFFE1; Width:' + this.Width + ';height:' + this.Height + '; overflow:auto;\'>';
		sHtml += '<p align=\'left\'><font face=\'Verdana\' size=\'x-small\'>' + this._HTMLEncode( this.Value ) + '</font></p></div>';
		sHtml += '</td></tr>';
		sHtml += '<tr height=\'20\' valign=\'middle\'><td align=\'center\'>';
		sHtml += '<hr width=\'90%\' size=\'1\' color=\'#000000\'>';		

		var bPrevButton = false;
			
		if( (this.Buttons & this.btOk) == this.btOk )
		{		
			if ( this.Action != null && this.Action != '' )
			{
				sHtml += this.OkButton;
			}
			else
			{
				sHtml += this.OkButtonNoAction;
			}
			
			bPrevButton = true;
		}

		if( (this.Buttons & this.btYes) == this.btYes)
		{
			if(bPrevButton) sHtml += this.Separator;
			
			sHtml += this.YesButton;			
			bPrevButton = true;
		}
		if( (this.Buttons & this.btNo) == this.btNo)
		{
			if(bPrevButton) sHtml += this.Separator;
			
			sHtml += this.NoButton;
			bPrevButton = true;
		}
		if( (this.Buttons & this.btCancel) == this.btCancel)
		{
			if(bPrevButton) sHtml += this.Separator;
			
			sHtml += this.CancelButton;
			bPrevButton = true;
		}

		sHtml += '</td></tr></table></td></tr></table></td></tr></table>';		
	}

	sHtml += '</div>' ;
	
	this.MessageMainDiv.innerHTML = sHtml;
	
	document.body.appendChild( this.MessageMainDiv );
	
	document.body.msgbox = this;

	//return sHtml ;
}

FUTUREMessageBox.prototype._HTMLEncode = function( text )
{
	if ( typeof( text ) != "string" )
		text = text.toString() ;

	text = text.replace(
		/&/g, "&amp;").replace(
		/"/g, "&quot;").replace(
		/</g, "&lt;").replace(
		/>/g, "&gt;") ;

	return text ;
}

FUTUREMessageBox.prototype._ThrowError = function( errorNumber, errorDescription )
{
	this.ErrorNumber		= errorNumber ;
	this.ErrorDescription	= errorDescription ;

	if ( this.DisplayErrors )
	{
		document.write( '<div style="COLOR: #ff0000">' ) ;
		document.write( '[ FUTURE Message Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ;
		document.write( '</div>' ) ;
	}

	if ( typeof( this.OnError ) == 'function' )
		this.OnError( this, errorNumber, errorDescription ) ;
}

function FUTUREMessageBox_IsCompatibleBrowser()
{
	var sAgent = navigator.userAgent.toLowerCase() ;

	// Internet Explorer
	if ( sAgent.indexOf("msie") != -1 && sAgent.indexOf("mac") == -1 && sAgent.indexOf("opera") == -1 )
	{
		var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
		return ( sBrowserVersion >= 5.5 ) ;
	}

	// Gecko (Opera 9 tries to behave like Gecko at this point).
	if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
		return true ;

	// Opera
	if ( this.EnableOpera && navigator.appName == 'Opera' && parseInt( navigator.appVersion ) >= 9 )
			return true ;

	// Safari
	if ( this.EnableSafari && sAgent.indexOf( 'safari' ) != -1 )
		return ( sAgent.match( /safari\/(\d+)/ )[1] >= 312 ) ;	// Build must be at least 312 (1.3)

	return false ;
}

// MODAL PART

/**
 * POPUP WINDOW CODE v1.1
 * Used for displaying DHTML only popups instead of using buggy modal windows.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Contributions by Eric Angel (tab index code) and Scott (hiding/showing selects for IE users)
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/subModal
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

// Popup code
/**
 * POPUP WINDOW CODE
 * Used for displaying DHTML only popups instead of using buggy modal windows.
 *
 * By Seth Banks (webmaster at subimage dot com)
 * http://www.subimage.com/
 *
 * Contributions by Eric Angel (tab index code) and Scott (hiding/showing selects for IE users)
 *
 * Up to date code can be found at http://www.subimage.com/dhtml/subModal
 *
 * This code is free for you to use anywhere, just keep this comment block.
 */

/**
 * Code below taken from - http://www.evolt.org/article/document_body_doctype_switching_and_more/17/30655/
 *
 * Modified 4/22/04 to work with Opera/Moz (by webmaster at subimage dot com)
 *
 * Gets the full width/height because it's different for most browsers.
 */
function getViewportHeight() {
	if (window.innerHeight!=window.undefined) return window.innerHeight;
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}
function getViewportWidth() {
	if (window.innerWidth!=window.undefined) return window.innerWidth; 
	if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth; 
	if (document.body) return document.body.clientWidth; 
	return window.undefined; 
}

// Popup code
var gPopupMask = null;
var gPopupContainer = null;
var gPopFrame = null;
var gReturnFunc;
var gParam1;
var gPopupIsShown = false;
var gPopupTitle = null;

var gHideSelects = false;
var gHideObjects = true;
var gLoadingUrl = null;

var gTabIndexes = new Array();
// Pre-defined list of tags we want to disable/enable tabbing into
var gTabbableTags = new Array("A","BUTTON","TEXTAREA","INPUT","IFRAME");	

// If using Mozilla or Firefox, use Tab-key trap.
document.onkeypress = keyDownHandler;

/**
 * Initializes popup code on load.	
 */
function initPopUp() {
	gPopupMask = document.getElementById("popupMask");
	gPopupContainer = document.getElementById("popupContainer");
	gPopFrame = document.getElementById("popupFrame");	
	
	if ( gPopupMask == null )
	{
		renderPopWinMain();
		
		initPopUp();
	}
	
	// check to see if this is IE version 6 or lower. hide select boxes if so
	// maybe they'll fix this in version 7?
	var brsVersion = parseInt(window.navigator.appVersion.charAt(0), 10);
	if (brsVersion <= 6 && window.navigator.userAgent.indexOf("MSIE") > -1) {
		gHideSelects = true;
	}
}

function renderPopWinMain()
{
	renderPopWin('/script/modal/close.gif"', '/script/modal/loading.html');
}

function renderPopWin(closeIconUrl, loadingUrl)
{
	gPopFrame = document.getElementById("popupFrame");	
	
	if ( gPopupMask != null )
	{
		return;
	}
	
	gLoadingUrl=loadingUrl;

	body = document.getElementsByTagName('body')[0];
	popmask = document.createElement('div');
	popmask.id = 'popupMask';
	popcont = document.createElement('div');
	popcont.id = 'popupContainer';
	//popcont.className = 'resizeMe';
	popcont.innerHTML = '' +
		'<div id="popupInner" class=drag style="">' +
			'<div id="popupTitleBar">' +
				'<div id="popupTitle"></div>' +
				'<div id="popupControls">' +
					'<img src="' + closeIconUrl + '" onclick="hidePopWin(true);" />' +
				'</div>' +
			'</div>' +
			'<iframe src="' + loadingUrl + '" style="width:100%;height:100%;background-color:transparent;" scrolling="no" frameborder="0" allowtransparency="true" id="popupFrame" name="popupFrame" width="100%" height="100%"></iframe>' +
		'</div>';
	body.appendChild(popmask);
	body.appendChild(popcont);

/*
	document.write("<div id=\"popupMask\" style=\"display: none;\">&nbsp;</div>");
	document.write("<div id=\"popupContainer\" style=\"display: none;\">");
	document.write("<div id=\"popupInner\">");
	document.write("<div id=\"popupTitleBar\">");
	document.write("<div id=\"popupTitle\"></div>");
	document.write("<div id=\"popupControls\">");
	document.write("<img src=\"" + closeIconUrl + "\" onclick=\"hidePopWin(false);\" />");
	document.write("</div>");
	document.write("</div>");
	document.write("<iframe src=\"" + loadingUrl + "\" style=\"width:100%;height:100%;background-color:transparent;\" scrolling=\"auto\" frameborder=\"0\" allowtransparency=\"true\" id=\"popupFrame\" name=\"popupFrame\" width=\"100%\" height=\"100%\"></iframe>");
	document.write("</div>");
	document.write("</div>");
	*/
}

 /**
	* @argument width - int in pixels
	* @argument height - int in pixels
	* @argument url - url to display
	* @argument returnFunc - function to call when returning true from the window.
	*/


function showPopWin(url, width, height, returnFunc, param1) {
	gPopupIsShown = true;
	
	disableTabIndexes();
	gPopupMask.style.display = "block";
	gPopupContainer.style.display = "block";
	// calculate where to place the window on screen
	centerPopWin(width, height);
	
	var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
	
	gPopupContainer.style.width = width + "px";
	gPopupContainer.style.height = (height+titleBarHeight) + "px";
	// need to set the width of the iframe to the title bar width because of the dropshadow
	// some oddness was occuring and causing the frame to poke outside the border in IE6
	gPopFrame.style.width = parseInt(document.getElementById("popupTitleBar").offsetWidth, 10) + "px";
	gPopFrame.style.height = (height) + "px";

	document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title;
	gPopupTitle = window.frames["popupFrame"].document.title;	
	
	// set the url
	gPopFrame.src = url;
	
	gReturnFunc = returnFunc;
	gParam1 = param1;
	
	// for IE
	if (gHideSelects || gHideObjects) {
		hideSelectBoxes();
	}
	
	window.setTimeout("setPopTitle();", 60);
}

//
var gi = 0;
function centerPopWin(width, height) {
	if (gPopupIsShown == true) {
	    if (width == null || isNaN(width)) {
			width = gPopupContainer.offsetWidth;
		}
		if (height == null) {
			height = gPopupContainer.offsetHeight;
		}
		
		var fullHeight = getViewportHeight();
		var fullWidth = getViewportWidth();
		
		var theBody = document.documentElement;
		
		var scTop = parseInt(theBody.scrollTop,10);
		var scLeft = parseInt(theBody.scrollLeft,10);
		
		gPopupMask.style.height = fullHeight + "px";
		gPopupMask.style.width = fullWidth + "px";
		gPopupMask.style.top = scTop + "px";
		gPopupMask.style.left = scLeft + "px";
		
		//window.status = gPopupMask.style.top + " " + gPopupMask.style.left + " " + gi++;
		
		var titleBarHeight = parseInt(document.getElementById("popupTitleBar").offsetHeight, 10);
		
		gPopupContainer.style.top = (scTop + ((fullHeight - (height+titleBarHeight)) / 2)) + "px";
		gPopupContainer.style.left =  (scLeft + ((fullWidth - width) / 2)) + "px";
			
		//alert(fullWidth + " " + width + " " + gPopupContainer.style.left);
	}
}
//addEvent(window, "scroll", centerPopWin);
window.onscroll = centerPopWin;

/**
 * @argument callReturnFunc - bool - determines if we call the return function specified
 * @argument returnVal - anything - return value 
 */
function hidePopWin(callReturnFunc) {
	gPopupIsShown = false;
	restoreTabIndexes();
	if (gPopupMask == null) {
		return;
	}
	gPopupMask.style.display = "none";
	gPopupContainer.style.display = "none";
	
	if (callReturnFunc == true && gReturnFunc != null) 
	{
		if ( gParam1 != null && gParam1 != '' )
		{
			gReturnFunc ( gParam1, window.frames["popupFrame"].returnValue );
		}
		else
		{		
			gReturnFunc ( window.frames["popupFrame"].returnValue );
		}
	}
	
	gPopFrame.src = gLoadingUrl;
	
	// display all select boxes
	if (gHideSelects || gHideObjects) {
		displaySelectBoxes();
	}
}

/**
 * Sets the popup title based on the title of the html document it contains.
 * Uses a timeout to keep checking until the title is valid.
 */
function setPopTitle() {
try
{
	if (window.frames["popupFrame"].document.title == null || window.frames["popupFrame"].document.title == gPopupTitle) 
	{
		window.setTimeout("setPopTitle();", 99);
	} 
	else 
	{
		document.getElementById("popupTitle").innerHTML = window.frames["popupFrame"].document.title;			
	}	
}
catch(e)
{}
}

// Tab key trap. iff popup is shown and key was [TAB], suppress it.
// @argument e - event - keyboard event that caused this function to be called.
function keyDownHandler(e) {
	   var kC  = (window.event) ?    // MSIE or Firefox?
                  event.keyCode : e.keyCode; 
       var Esc = (window.event) ?    
                 27 : e.DOM_VK_ESCAPE // MSIE : Firefox
    
	if (!document.all) {
		if (gPopupIsShown && e.keyCode == 9)  return false;
    }
        
    if ( parent.gPopupIsShown && kC==Esc && gPopupIsShown == false ) parent.hidePopWin(true);
}

// For IE.  Go through predefined tags and disable tabbing into them.
function disableTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				gTabIndexes[i] = tagElements[k].tabIndex;
				tagElements[k].tabIndex="-1";
				i++;
			}
		}
	}
}

// For IE. Restore tab-indexes.
function restoreTabIndexes() {
	if (document.all) {
		var i = 0;
		for (var j = 0; j < gTabbableTags.length; j++) {
			var tagElements = document.getElementsByTagName(gTabbableTags[j]);
			for (var k = 0 ; k < tagElements.length; k++) {
				tagElements[k].tabIndex = gTabIndexes[i];
				tagElements[k].tabEnabled = true;
				i++;
			}
		}
	}
}


/**
* Hides all drop down form select boxes on the screen so they do not appear above the mask layer.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*
* Thanks for the code Scott!
*/
function hideSelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if( (gHideSelects && document.forms[i].elements[e].tagName == "SELECT") 
				|| (gHideObjects && document.forms[i].elements[e].tagName == "OBJECT") ) {
				document.forms[i].elements[e].style.visibility="hidden";
			}
		}
	}
}

/**
* Makes all drop down form select boxes on the screen visible so they do not reappear after the dialog is closed.
* IE has a problem with wanted select form tags to always be the topmost z-index or layer
*/
function displaySelectBoxes() {
	for(var i = 0; i < document.forms.length; i++) {
		for(var e = 0; e < document.forms[i].length; e++){
			if( (gHideSelects && document.forms[i].elements[e].tagName == "SELECT") 
				|| (gHideObjects && document.forms[i].elements[e].tagName == "OBJECT") ) {
				document.forms[i].elements[e].style.visibility="visible";
			}
		}
	}
}



//Generic Drag Script- © Dynamic Drive (www.dynamicdrive.com)
//For full source code and terms of usage,
//visit http://www.dynamicdrive.com

var ie=document.all
var ns6=document.getElementById&&!document.all

var dragapproved=false
var z,x,y

function move(e){
if (dragapproved){
z.style.left=ns6? temp1+e.clientX-x: temp1+event.clientX-x
z.style.top=ns6? temp2+e.clientY-y : temp2+event.clientY-y
return false
}
}

function drags(e){
if (!ie&&!ns6)
return
var firedobj=ns6? e.target : event.srcElement
var topelement=ns6? "HTML" : "BODY"

if ( firedobj == null )
{
    return;
}

while (firedobj.tagName!=topelement&&firedobj.className!="drag"){
firedobj=ns6? firedobj.parentNode : firedobj.parentElement; if ( firedobj == null ) break; 
}

if ( firedobj == null )
{
    return;
}

if (firedobj.className=="drag"){
dragapproved=true
z=firedobj
temp1=parseInt(z.style.left+0)
temp2=parseInt(z.style.top+0)
x=ns6? e.clientX: event.clientX
y=ns6? e.clientY: event.clientY
document.onmousemove=move
return false
}
}
document.onmousedown=drags
document.onmouseup=new Function("dragapproved=false")


/*
/////////////////////////////////////////////////////////////////////////
// Generic Resize by Erik Arvidsson                                    //
//                                                                     //
// You may use this script as long as this disclaimer is remained.     //
// See www.dtek.chalmers.se/~d96erik/dhtml/ for mor info               //
//                                                                     //
// How to use this script!                                             //
// Link the script in the HEAD and create a container (DIV, preferable //
// absolute positioned) and add the class="resizeMe" to it.            //
/////////////////////////////////////////////////////////////////////////

var theobject = null; //This gets a value as soon as a resize start

function resizeObject() {
	this.el        = null; //pointer to the object
	this.dir    = "";      //type of current resize (n, s, e, w, ne, nw, se, sw)
	this.grabx = null;     //Some useful values
	this.graby = null;
	this.width = null;
	this.height = null;
	this.left = null;
	this.top = null;
}
	

//Find out what kind of resize! Return a string inlcluding the directions
function getDirection(el) {
	var xPos, yPos, offset, dir;
	dir = "";

	xPos = window.event.offsetX;
	yPos = window.event.offsetY;

	
	offset = 8; //The distance from the edge in pixels

	if (yPos<offset) dir += "n";
	else if (yPos > el.offsetHeight-offset) dir += "s";
	if (xPos<offset) dir += "w";
	else if (xPos > el.offsetWidth-offset) dir += "e";

	return dir;
}

function doDown() {
	var el = getReal(event.srcElement, "className", "resizeMe");

	if (el == null) {
		theobject = null;
		return;
	}		

	dir = getDirection(el);
	if (dir == "") return;

	theobject = new resizeObject();
		
	theobject.el = el;
	theobject.dir = dir;

	theobject.grabx = window.event.clientX;
	theobject.graby = window.event.clientY;
	theobject.width = el.offsetWidth;
	theobject.height = el.offsetHeight;
	theobject.left = el.offsetLeft;
	theobject.top = el.offsetTop;

	window.event.returnValue = false;
	window.event.cancelBubble = true;
}

function doUp() {
	if (theobject != null) {
		theobject = null;
	}
}

function doMove() {
	var el, xPos, yPos, str, xMin, yMin;
	xMin = 8; //The smallest width possible
	yMin = 8; //             height

	el = getReal(event.srcElement, "className", "resizeMe");

	if (el.className == "resizeMe") {
		str = getDirection(el);
	//Fix the cursor	
		if (str == "") str = "default";
		else str += "-resize";
		el.style.cursor = str;
	}
	
//Dragging starts here
	if(theobject != null) {
		if (dir.indexOf("e") != -1)
			theobject.el.style.width = Math.max(xMin, theobject.width + window.event.clientX - theobject.grabx);
	
		if (dir.indexOf("s") != -1)
			theobject.el.style.height = Math.max(yMin, theobject.height + window.event.clientY - theobject.graby);		

		if (dir.indexOf("w") != -1) {
			theobject.el.style.left = Math.min(theobject.left + window.event.clientX - theobject.grabx, theobject.left + theobject.width - xMin);
			theobject.el.style.width = Math.max(xMin, theobject.width - window.event.clientX + theobject.grabx);
		}
		if (dir.indexOf("n") != -1) {
			theobject.el.style.top = Math.min(theobject.top + window.event.clientY - theobject.graby, theobject.top + theobject.height - yMin);
			theobject.el.style.height = Math.max(yMin, theobject.height - window.event.clientY + theobject.graby);
		}
		
		window.event.returnValue = false;
		window.event.cancelBubble = true;
	} 
}


function getReal(el, type, value) {
	temp = el;
	while ((temp != null) && (temp.tagName != "BODY")) {
		if (eval("temp." + type) == value) {
			el = temp;
			return el;
		}
		temp = temp.parentElement;
	}
	return el;
}

document.onmousedown = doDown;
document.onmouseup   = doUp;
document.onmousemove = doMove;


*/
