/* ---------------------------------------- global functions ----------------------------------------- */
var isPostProcessing = false;

function GetBForm(){ return document.forms['PageBaseForm']; }
function GetLForm(){ var frm = document.forms['LinkForm']; var bFrm = GetBForm(); if(bFrm){frm._XFORMSESSSTATE.value = bFrm._XFORMSESSSTATE.value; var exDiv=document.getElementById('LinkFormExElem');if(exDiv){exDiv.innerHTML='';}} return frm;}
function NavItemLinkPost(url){ var bFrm = GetBForm(); if(!bFrm || !bFrm._XFORMSESSSTATE.value){return false;} doLinkPost(url, bFrm._XFORMSESSSTATE.value); return false; }

function doPostBack()
{
	var frm = GetBForm();
	var args = doPostBack.arguments;
	
	if(args != null && args.length > 0) 
	{
		if(args[0].length > 0) 
			frm.action = args[0];
			
		for(var i=1; i < args.length; i++) 
			SetElementValue(args[i]);
	}
	frm.submit();
	return false;
}

function doLinkPost(action, formstate) {
	if(isPostProcessing){return false;}
	var frm = GetLForm();
	frm.action = action;

	try {
	 if(formstate){
		if(typeof(formstate)=='string'){
			frm._XFORMSTATE.value = formstate;
		}
		if(typeof(formstate)=='object'){
			frm._XFORMSTATE.value = formstate._XFORMSTATE.value
		}
	 }
	} catch(e) {;} 
	
	var args = doLinkPost.arguments;
	if(args != null && args.length == 3) {
		frm._XFORMSESSSTATE.value = args[2];
	}
	frm.submit();
	return false;
}

function doLinkPostArgs(action, formstate,Args) {
	if(isPostProcessing){return false;}
	var frm = GetLForm();
	BuildHiddenInput(document.getElementById('LinkFormExElem'),Args);
	frm.action = action;

	try {
	 if(formstate){
		if(typeof(formstate)=='string'){
			frm._XFORMSTATE.value = formstate;
		}
		if(typeof(formstate)=='object'){
			frm._XFORMSTATE.value = formstate._XFORMSTATE.value
		}
	 }
	} catch(e) {;} 
	
	var args = doLinkPost.arguments;
	if(args != null && args.length == 3) {
		frm._XFORMSESSSTATE.value = args[2];
	}
	frm.submit();
	return false;
}

function BuildHiddenInput(parent,Args)
{
	var a = GetKeyValueArray(Args);
	for(var i=0; i < a.length; i++) {
		var av = a[i];
		var val = document.getElementById(av).value;
		AppendToNode(parent, av, val);
	}
}


function doLinkPostNewWindow(action, formstate) {

	if(isPostProcessing){return false;}
	var frm = GetLForm();
	frm.action = action;
	if (formstate) {
		frm._XFORMSTATE.value = formstate;
	}
	else if (GetBForm()) {
		frm._XFORMSTATE.value = GetBForm()._XFORMSTATE.value;
	}
	NewWindow(action, frm);
}

function prepLinkPostForPopUp ( action, formstate ) {
	var frm = GetLForm();
	frm.action = action;

	try {	
	 if(formstate){
		if(typeof(formstate)=='string'){
			frm._XFORMSTATE.value = formstate;
		}
		
		if(typeof(formstate)=='object'){
			frm._XFORMSTATE.value = formstate._XFORMSTATE.value
		}
	 }
	} catch(e) {;} 	
	
	return false;
}

function doLinkSubmit() {

	if(isPostProcessing)
		return false;

	var args = doLinkSubmit.arguments;
	var frm = GetBForm();
	if(args != null && args.length > 0) {
		if(args[0].length > 0) 
			frm.action = args[0];
			
		for(var i=1; i < args.length; i++) 
			SetElementValue(args[i]);
	}
	frm.submit();
	return false;
}

function doLinkSubmitNewWindow() {

	if(isPostProcessing)
		return false;
		
	var frm = GetBForm();
	var pageAction = frm.action;
	var args = doLinkSubmitNewWindow.arguments;
	
	if(args != null && args.length > 0) {
		if(args[0].length > 0) 
			frm.action = args[0];
			
		for(var i=1; i < args.length; i++) 
			SetElementValue(args[i]);
	}
	
	NewWindow(args[0], frm);
	frm.action = pageAction;
}

function doFormSubmit() {

	var action, groupid, isvalid;
	var args = doFormSubmit.arguments;
	var frm = GetBForm();
	
	if(args != null) {
		action = args[0];
		if(args.length > 1) 
			groupid = args[1];
	}

	isvalid = Page_ClientValidate(groupid);

	if(isvalid) {
		if(action.length > 0) 
			frm.action = action;
		
		for(var i=2; i < args.length; i++) 
			SetElementValue(args[i]);
	}

	return isvalid;
}

function doFormSubmitNewWindow() {

	var action, groupid, isvalid;
	var args = doFormSubmitNewWindow.arguments;
	var frm = GetBForm();
	
	if(args != null) {
		action = args[0];
		if(args.length > 1) 
			groupid = args[1];
	}

	isvalid = Page_ClientValidate(groupid);

	if(isvalid) {
		if(action.length > 0) 
			frm.action = action;
		
		for(var i=2; i < args.length; i++) 
			SetElementValue(args[i]);
	}
	
	if(isvalid) {
		NewWindow(args[0], frm);
	}	
}

function GL_SubmitAnchor_Click() {

	var args = GL_SubmitAnchor_Click.arguments;
	var frm = GetBForm();

	if(args != null) {
		if(args[0].length > 0) 
			frm.action = args[0];
			
		for(var i=1; i < args.length; i++) 
			SetElementValue(args[i]);
	}

	frm.submit();
	return false;
}

function GL_TextBox_Enter(e, buttonid) 
{
	if ( window.event ) e = window.event;
	var key = ( e.keyCode ) ? e.keyCode : e.which;

	if (key == 13) {
		document.getElementById(buttonid).click();
		return false;
	}
	return true;
}


/* ---------------------------------------- utility functions ----------------------------------------- */
function clearForm(frm) {

	var el;
	for(var i=0; i < frm.length; i++) {
	
		el = frm.elements[i];
		switch(el.type) {
			case "text":
				el.value = "";
				break;
			case "select-one":
				if(el.name == "dr")
					el.options[3].selected = true;
				else
					el.options[0].selected = true;
				break;
		}
	}
}

function validateEmail(str) {
	if(trim(str).length > 80)
	{
		return false;
	}
	else
	{
		if(str.indexOf("@")==-1 || (str.indexOf("@")!=str.lastIndexOf("@")) || str.indexOf(" ")!=-1){
			return false;
		}else{
			if(str.indexOf(".")==-1){
				return false
			}else{
				return true;
			}
		}
	}
}

function SetElementValue(arg) {

	var name, ctrl, val;
	var frm = GetBForm();
		
	if(arg.indexOf('=') > 0) {
		name = arg.substring(0,arg.indexOf('='));
		val = arg.substring(arg.indexOf('=')+1,arg.length);
	}
	else {
		name = arg.substring(0,arg.indexOf(':'));
		val = eval("frm." + arg.substring(arg.indexOf(':')+1,arg.length)).value;
	}

	ctrl = frm.elements[name];
	
	if ( ctrl )
	{
		if ( ctrl.length && ctrl.length > 1 ) {
			for ( var i=0; i < ctrl.length; i++ )
			{
				if ( ctrl[i].value = val )
				{
					ctrl[i].checked = true;
					break;
				}
			}
		}
		else {
			ctrl.value = val;
		}
	}
}


/* ---------------------------------------- will we ever be rid of the NewWindow function? ----------------------------------------- */
function LogMeOut() {
	var mommy = self;
	while (mommy.parent != mommy && mommy.parent != null) {
		mommy = mommy.parent;
	}
	try	{
		var whatever = mommy.window.opener.location.href;
		if (LogMeOut.arguments.length == 1) 
			mommy.window.opener.LogMeOut(LogMeOut.arguments[0]);
		else
			mommy.window.opener.LogMeOut();
	} catch(e) {
		KillWindows();
		if (LogMeOut.arguments.length == 1) 
			mommy.location="../lo/default.aspx?napc=l&reason=" + LogMeOut.arguments[0];
		if (LogMeOut.arguments.length == 2) 
		{
			var action = LogMeOut.arguments[0];
			if (action.indexOf('http') == -1){
				action ="../lo/default.aspx?reason=" + action;
			}
			doLinkPost( action, LogMeOut.arguments[1] );
		}
		else
			mommy.location="../lo/default.aspx?napc=l";
	}
}

function KillWindows() {
	for(var i=0;i<windowArray.length;i++) {
		if (windowArray[i] != null && !(windowArray[i].closed)) {
			windowArray[i].close();
		}
	}
}

var windowHandle, windowInterval;
var OLD_TARGET = "";
var OLD_ACTION = "";
var CURRENT_FORM = new Object();
var RootNewWindowDirectory;

function SubmitFormToWin(){ 
	if (CURRENT_FORM.tagName && CURRENT_FORM.tagName.toLowerCase() == "form"){
		CURRENT_FORM.submit();
		if (oBD.ie5Mac)
			window.setTimeout("changeTargetAndAction()",100);
		else
			window.setTimeout("changeTargetAndAction()",1);
	}
}
function changeTargetAndAction(){
	if (CURRENT_FORM.tagName && CURRENT_FORM.tagName.toLowerCase() == "form"){
		CURRENT_FORM.target = OLD_TARGET;
		CURRENT_FORM.action = OLD_ACTION;
		OLD_TARGET = "";
		OLD_ACTION = "";
		CURRENT_FORM = new Object();
	}
}


function NewWindow() {

	if(isPostProcessing)
		return false;

	var mommy = self;
	while (mommy.parent != mommy && mommy.parent != null) {
		mommy = mommy.parent;
	}
	try	{
		var whatever = mommy.opener.location.href;
		if (NewWindow.arguments.length == 0)
			windowHandle = mommy.opener.newWindow(NewWindow.arguments[0]);
		else
			windowHandle = mommy.opener.newWindow(NewWindow.arguments[0],NewWindow.arguments[1]);
	} catch(e) {
		var x, y, arg0, arg1, itIsAlreadyOpen = false;
		var windowIndex, windowURL, options, reloadNecessary;
		arg0 = NewWindow.arguments[0];
		arg1 = NewWindow.arguments[1];
			
		if (NewWindow.arguments.length > 1) {
			if(typeof arg1 == "string") {
				var querystring = arg1;
				var formObj = null;
				if (querystring == "") {
					reloadNecessary = false;
				} else {
					reloadNecessary = true;
				}
			} else { 
				var querystring = "";
				var formObj = arg1;
				reloadNecessary = true;
			}
		} else {
			var querystring = "";
			var formObj = null;
			reloadNecessary = false;
		}
			
		scrollbar=1;
		outsideURL = false;
			
		switch(arg0 + "") {
		
			case "pcrSpreadSheet":
				windowURL = "../pcr/pcrcsv.aspx";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "pcrSpreadSheetGsl":
				windowURL = "../pcr/pcrcsv.aspx";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "finSpreadSheet":
				windowURL = "../ar/arcsv.aspx";
				x = 800;
				y = 500;
				windowIndex=4;
			break;
				
			case "prRedirect":
				windowURL = "../pr/default.aspx";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "euSearchTips":
				windowURL = RootNewWindowDirectory + "/eu/searchtips.html";
				x = 800;
				y = 500;
				windowIndex=0;
			break;

			case "euFocusTips":
				windowURL = RootNewWindowDirectory + "/eu/help.html";
				x = 800;
				y = 500;
				windowIndex=0;
			break;

			case "euModules":
				windowURL = RootNewWindowDirectory + "/du/modules.aspx";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "euFormatForPrint":
				windowURL = RootNewWindowDirectory + "/eu/s.aspx";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "euOde":
				windowURL = RootNewWindowDirectory + "/eu/ode.aspx";
				x = 800;
				y = 410;
				windowIndex=0;
			break;

			case "betaFeedback":
				windowURL = RootNewWindowDirectory + "/eu/feedback.aspx";
				x = 800;
				y = 480;
				windowIndex=0;
			break;

			case "assignIPs":
				windowURL = RootNewWindowDirectory + "/admn/addIPs.asp";
				x = 800;
				y = 480;
				windowIndex=0;
			break;

			case "HMD":
				windowURL = RootNewWindowDirectory + "/mds/newglobalstock.asp";
				x = 800;
				y = 480;
				windowIndex=4;
			break;

			case "addUsers":
				windowURL = RootNewWindowDirectory + "/admn/addusers.asp";
				x = 800;
				y = 550;
				windowIndex=0;
			break;

			case "newClientCode":
				windowURL = RootNewWindowDirectory + "/cibs/newClientCodeSpec.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;

			case "addToBriefcase":
				windowURL = RootNewWindowDirectory + "/srch/hl-briefcase.asp";
				x = 400;
				y = 200;
				windowIndex=0;
			break;

			case "briefcase":
				windowURL = RootNewWindowDirectory + "/brfcs/briefcase.asp";
				x = 800;
				y = 500;
				windowIndex=0;
			break;

			case "bulkSave":
				windowURL = RootNewWindowDirectory + "/cust/bulkSave.asp";
				x = 250;
				y = 125;
				windowIndex=0;
			break;

			case "copyToBriefcase":
				windowURL = RootNewWindowDirectory + "/srch/hl-briefcase.asp";
				x = 400;
				y = 200;
				windowIndex=0;
			break;

			case "saveBriefcase":
				windowURL = RootNewWindowDirectory + "/brfcs/briefcase-rename.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;

			case "adminPref":
				windowURL = RootNewWindowDirectory + "/pref/Admn-general.asp";
				x = 800;
				y = 600;
				windowIndex=0;
			break;

			case "assignItemToGroup":
				windowURL = RootNewWindowDirectory + "/admn/assignitemtogroup.asp";
				x = 800;
				y = 600;
				windowIndex=0;
			break;

			case "addToGroups":
				windowURL = RootNewWindowDirectory + "/sym/doCompTran.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;

			case "bulkRegistrationReviewData":
				windowURL = RootNewWindowDirectory + "/cust/bulkRunJobReview.asp";
				x = 480;
				y = 640;
				windowIndex=0;
			break;

			case "bulkRegistrationSaveProfile":
				windowURL = RootNewWindowDirectory + "/cust/bulk_reg_step3_save_profile.asp";
				x = 250;
				y = 125;
				windowIndex=0;
			break;

			case "cleanCopy":
				windowURL = RootNewWindowDirectory + "/arch/clean_copy.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
				
			case "DisplayArticleReport":
				windowURL = RootNewWindowDirectory + "/arch/display.asp";
				x = 800;
				y = 550;
				windowIndex=0;
			break;
				
			case "printCopy":
				windowURL = RootNewWindowDirectory + "/arch/print_results.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
				
			case "saveCopy":
				windowURL = RootNewWindowDirectory + "/arch/save_results.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
			
			case "investextPDF":
				windowURL = RootNewWindowDirectory + "/arch/getInvestPdf.pdf";
				x = 800;
				y = 550;
				windowIndex=4;
			break;
			
			case "migrationJobStatus":
				windowURL = RootNewWindowDirectory + "/mig/migrationJobStatus.asp";
				x = 800;
				y = 480;
				windowIndex=0;
			break;
							
			case "mdsCleanCopy":
				windowURL = RootNewWindowDirectory + "/mds/CleanCopy.asp";
				x = 800;
				y = 550;
				windowIndex=4;
			break;

			case "companyList":
				windowURL = RootNewWindowDirectory + "/sym/colistcreate.asp";
				x = 800;
				y = 575;
				windowIndex=0;
			break;

			case "costCentre":
			   	
				windowURL = "../cc/default.aspx";
				x = 800;
				y = 500;
				windowIndex=0;
			break;

			case "email":
				windowURL = RootNewWindowDirectory + "/ode/email-request.asp";
				x = 800;
				y = 550;
				windowIndex=0;
			break;

			case "trackEmailAdmin":
				windowURL = RootNewWindowDirectory + "/track/emailAdmin.asp";
				x = 800;
				y = 550;
				windowIndex=0;
			break;

			case "modifyGroup":
				windowURL = RootNewWindowDirectory + "/admn/modifygroup.asp";
				x = 800;
				y = 600;
				windowIndex=0;
			break;

			case "onlineUsage":
				windowURL = RootNewWindowDirectory + "/usg/onlineusage.asp";
				x = 800;
				y = 500;
				windowIndex=0;
			break;
				
			case "redirectEditor":
				windowURL = RootNewWindowDirectory + "/cust/redirectEditor.asp";
				x = 520;
				y = 240;
				windowIndex=0;
			break;

			case "reportCleanCopy":
				windowURL = RootNewWindowDirectory + "/usg/reportCleanCopy.asp";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "reportDownload":
				windowURL = RootNewWindowDirectory + "/usg/reportDownload.csv";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "pricingMessage":
				windowURL = RootNewWindowDirectory + "/srch/Pricing-Message.asp";
				x = 200;
				y = 200;
				windowIndex=0;
			break;

			case "printerFormatCopy":
				windowURL = RootNewWindowDirectory + "/arch/print_results.asp";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "saveFormatCopy":
				windowURL = RootNewWindowDirectory + "/arch/save_results.asp";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "preferences":
				windowURL = RootNewWindowDirectory + "/pref/prefs-general.asp";
				x = 800;
				y = 525;
				windowIndex=0;
				scrollbar=0;
			break;

			case "preferenceIWE":
				windowURL = RootNewWindowDirectory + "/pref/prefs-iwe.asp";
				x = 800;
				y = 525;
				windowIndex=0;
			break;

			case "savedQuotesList":
				windowURL = RootNewWindowDirectory + "/sym/editmodule.asp";
				x = 800;
				y = 575;
				windowIndex=0;
			break;

			case "saveSearch":
				windowURL = RootNewWindowDirectory + "/srch/save-search.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;
				
			case "screenTooSmall":
				windowURL = RootNewWindowDirectory + "/sess/screenTooSmall.asp";
				x = 400;
				y = 150;
				windowIndex=0;
			break;

			case "newCustomFormat":
				windowURL = "newCustomFormat.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;
				
			case "customSearch":
				windowURL = RootNewWindowDirectory + "/gen/custom_search.asp";
				x = 750;
				y = 600;
				windowIndex=0;
			break;
				
			case "customDisplay":
				windowURL = RootNewWindowDirectory + "/gen/custom_display.asp";
			    x = 750;
				y = 600;
				windowIndex=0;
			break;
				
			case "newItem":
				windowURL = RootNewWindowDirectory + "/sym/newItem.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;

			case "searchBuilder":
				reloadNecessary = false;
				tab = "tab0";
				windowURL = RootNewWindowDirectory + "/sb/searchBuilder3.asp";
				x = 700;
				y = 525;
				windowIndex=0;
			break;

			case "screeningCSV":
				windowURL = RootNewWindowDirectory + "/nds/factiva.csv";
				x = 500;
				y = 500;
				windowIndex=4;
			break;

			case "sourcesCSV":
				windowURL = RootNewWindowDirectory + "/srb/src.csv";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
			
			case "chartCleanCopy":
				windowURL = RootNewWindowDirectory + "/chmd/cleancopy.asp";
				x = 650;
				y = 550;
				windowIndex=4;
			break;
				
			case "userAgreement":
				windowURL = RootNewWindowDirectory + "/srch/User-Aggrement.asp";
				x = 200;
				y = 200;
				windowIndex=0;
			break;

			case "validationList":
				windowURL = RootNewWindowDirectory + "/cibs/validationList.asp";
				x = 800;
				y = 500;
				windowIndex=0;
			break;
				
			case "login":
				windowURL = RootNewWindowDirectory + "/sess/login.asp";
				x = 800;
				y = 600;
				windowIndex=4;
			break;

			case "rtfHeadlines":
				windowURL = RootNewWindowDirectory + "/fmt/rtf-display.rtf";
				x = 800;
				y = 500;
				windowIndex=4;
			break;

			case "rtfDisplay":
				windowURL = RootNewWindowDirectory + "/arch/rtf_display.rtf";
				x = 800;
				y = 500;
				windowIndex=4;
			break;
				
			case "examples":
				windowURL = RootNewWindowDirectory + "/help/ft_exmpl.html";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
			
			case "migrationPreviewMessage":
				windowURL = RootNewWindowDirectory + "/mig/migrationPreview.asp";
				x = 500;
				y = 200;
				windowIndex=4;
			break;
			
			case "FIIDetails":
				windowURL = RootNewWindowDirectory + "/sb/viewCode.asp";
				x = 650;
				y = 525;
				windowIndex=0;
			break;
			
			case "FIISrcDetails":
				windowURL = RootNewWindowDirectory + "/srb/viewSources.asp";
				x = 650;
				y = 525;
				windowIndex=0;
			break;
			
			case "FIISrcBrowser":
				windowURL = RootNewWindowDirectory + "/esrcb/sb.asp";
				x = 715;
				y = 560;
				windowIndex=0;
			break;
			
			case "sourcesCleanCopy":
				windowURL = RootNewWindowDirectory + "/srb/viewsources.asp";
				x = 500;
				y = 500;
				windowIndex=4;
			break;

			case "sbCSV":
				windowURL = RootNewWindowDirectory + "/sb/codes.csv";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
				
			case "sbCleanCopy":
				windowURL = RootNewWindowDirectory + "/sb/viewCode.asp";
				x = 500;
				y = 500;
				windowIndex=4;
			break;
            case "manageCategory":
				windowURL = RootNewWindowDirectory + "/gTrack/addRenameCategory.asp";
				x = 500;
				y = 300;
				windowIndex=0;
			break;
			case "unsubscribeItems":
			    windowURL = RootNewWindowDirectory + "/gTrack/markUnsubscribable.asp";
			    x = 500;
				y = 300;
				windowIndex=0;
				break;
			case "categoryList":
			    windowURL = RootNewWindowDirectory + "/gTrack/showCategories.asp";
			    x = 400;
				y = 400;
				windowIndex=0;
				break;	
		    case "modifyDA":
		        windowURL = RootNewWindowDirectory + "/dae/modifyDA.aspx";
			    x = 800;
				y = 500;
				windowIndex=0;
				break;	
				
			case "saveScreening":
				windowURL = RootNewWindowDirectory + "/../pcf/saveSearch.aspx";
				x = 500;
				y = 300;
				windowIndex=0;
			    break;
			  
			   case "../ri/default.aspx":
				windowURL = arg0;
				//windowURL = "../ri/default.aspx";
				x = 650;
				y = 525;
				windowIndex = 5;
				outsideURL = false;
			break;
						
			case "":
				alert("There has been an error processing your request: window will not be opened.");
				return false;
			    break;

			default:
				windowURL = arg0;
				x = 800;
				y = 500;
				windowIndex=4;
				outsideURL = true;
			break;
		}

		var WindowAttrs;
		if (oBD.dom) {
			WindowAttrs = "screenX=" + (window.screenX + ((window.outerWidth - x) / 2)) + ","
				+ "screenY=" + (window.screenY + ((window.outerHeight - y) / 2)) + ",";
		} else {
			WindowAttrs = "top=" + (screen.height - y) / 2 + ","
				+ "left=" + (screen.width - x) / 2 + ",";
		}

		if (windowIndex == 4 || windowIndex == 5) {
			if (outsideURL) 
				var windowName = "" + Math.floor(Math.random() * 100000000);
			else
				var windowName = windowNameArray[windowIndex];
			if(windowIndex == 5)
			{
				windowHandle = window.open("",windowName, WindowAttrs + "toolbar=0,scrollbars=" + scrollbar + ",location=0,statusbar=1,menubar=0,resizable=1,width=" + x + ",height=" + y);
			}
			else
			{
				windowHandle = window.open("", windowName, WindowAttrs + "toolbar=1,scrollbars=" + scrollbar + ",location=1,statusbar=1,menubar=1,resizable=1,width=" + x + ",height=" + y);	
			}
// for safari: windowHandle.location.href != window.location.href
// for safari 1.2.3: windowHandle.location.href != "/"

			if (windowHandle.location.href != "/" && windowHandle.location.href != window.location.href && windowHandle.location.href != "about:blank" && windowHandle.location.href != "") {
				try {
					windowHandle.close();
					windowHandle = window.open("", windowName, "toolbar=1,scrollbars=" + scrollbar + ",location=1,statusbar=1,menubar=1,resizable=1,width=" + x + ",height=" + y);
				} catch (e)	{;}
			}

			if (formObj == null) {
				try {
					windowHandle.focus();
				} catch(e) {;}
				windowHandle.location = windowURL + querystring;
			} else { 
				try {
					windowHandle.focus();
				} catch(e) {;}

				OLD_TARGET = formObj.target;
				OLD_ACTION = formObj.action;
				CURRENT_FORM = formObj;
				formObj.target=windowName;
				formObj.action=windowURL + querystring;
				if (oBD.ie5Mac)
					window.setTimeout("SubmitFormToWin()",100);
				else
					window.setTimeout("SubmitFormToWin()",1);
			}
		} else {
			windowHandle = window.open("", windowNameArray[windowIndex], WindowAttrs + "toolbar=0,scrollbars=" + scrollbar + ",location=0,statusbar=1,menubar=0,resizable=0,width=" + x + ",height=" + y);
				
			eval("if (windowHandle." + arg0 + " != null) {itIsAlreadyOpen = true;}");

			if (itIsAlreadyOpen && !reloadNecessary) {
				try {
					windowHandle.focus();
				} catch(e) {;}
				windowInterval = setInterval("checkWindowStatus(\"" + arg0 + "\", \"" + windowIndex + "\")", 1000);
			} else {
				if (formObj == null) {
					windowHandle = window.open(windowURL + querystring,windowNameArray[windowIndex]); 
					windowHandle.resizeTo(x,y);
					try {
						windowHandle.focus();
					} catch(e) {;}
					windowInterval = setInterval("checkWindowStatus(\"" + arg0 + "\", \"" + windowIndex + "\")", 1000);
					eval("windowArray[" + windowIndex + "] = windowHandle");
				} else {
				

					OLD_TARGET = formObj.target;
					OLD_ACTION = formObj.action;
					CURRENT_FORM = formObj;
				
					formObj.target=windowNameArray[windowIndex];
					formObj.action=windowURL + querystring;
				
					if (oBD.ie5Mac)
						window.setTimeout("SubmitFormToWin()",100);
					else
						window.setTimeout("SubmitFormToWin()",1);
				
					windowInterval = setInterval("checkWindowStatus(\"" + arg0 + "\", \"" + windowIndex + "\")", 1000);
					windowHandle.resizeTo(x,y);
					try {
						windowHandle.focus();
					} catch(e) {;}
					eval("windowArray[" + windowIndex + "] = windowHandle");
				
				}
			}
		}
	}

	return windowHandle;
}

function checkWindowStatus(stringToSet, windowIndex) {
	try {
		if (windowHandle.closed) {
			clearInterval(windowInterval);
		} else {
			if (oBD.ie5) {
				if (windowHandle.document.readyState == "complete") {
					eval("windowHandle." + stringToSet + " = true");
					windowHandle.SubWindowObj = windowHandle;
					windowHandle.SubWindowIndex = windowIndex;
					clearInterval(windowInterval);
				}
			} else {
				eval("windowHandle." + stringToSet + " = true");
				windowHandle.SubWindowObj = windowHandle;
				windowHandle.SubWindowIndex = windowIndex;
				clearInterval(windowInterval);
			}
		}
	} catch (e) {;}
}

var SubWindowObj, SubWindowIndex, windowNameArray, windowArray;

windowNameArray = new Array("FCPWindow","FCPWindow1","FCPWindow2","FCPWindow3","FCPOutsideSource","FCPWindow4");
windowArray = new Array(windowNameArray.length);

if (self.parent == self) {
	setInterval("RemindOthers()", 10000);
}

function RemindOthers() {
	if (SubWindowObj == null) {
		try {
			for(var i=0;i<windowArray.length;i++) {
				if (windowArray[i] != null) {
					if (windowArray[i].closed) {
						windowArray[i] = null;
					} else {
						windowArray[i].SubWindowObj = windowArray[i];
						windowArray[i].SubWindowIndex = i;
					}
				}
			}
		} catch (e) {}
	} else {
		try {
			window.opener.location.href;
			eval("window.opener.windowArray[" + SubWindowIndex + "] = SubWindowObj");
		} catch(e) {
			window.close();
		}
	}
}
function hasIllegalChar(str){
	if (str.match(/[<>&#\\%+|]/)){
		return true;
	} else {
		return false;
	}
}

function trim(str){ 
	/* this code replicated in login.asp, make changes in both places. */
	for(var i=0;i<str.length;i++){
		if (str.charCodeAt(i) <= 32){
			str = str.substring(0,i) + " " + str.substr(i+1);
		}
	}
	str = str.replace(/^[\s]+/g,"");
	str = str.replace(/[\s]+$/g,"");
	return str;
}

function CStr(vVariant){
	try{
		var str = new String(vVariant).toString();
		if(str == "undefined" || str == "null")
			str = "";
		}
	catch(e){str = "";}
	return str;
}

function CInt(vVariant){
	try{
		var num = 0;
		if (CStr(vVariant) != "" && !isNaN(vVariant))
			num = parseInt(vVariant);
	}
	catch(e){num = 0;}
	return num;
}

function isNumeric(vVariant){
	try {
		var num = 0;
		var numeric = false;
		if (CStr(vVariant) != "" && !isNaN(vVariant)){
			num = parseInt(vVariant);
			numeric = true;
		}
	}
	catch(e){numeric = false;}
	return numeric;
}


function OpenHelpWindow(url)
{
	var _newHelpWin = window.open("","fmcHelpWindow","height=525,width=550,left=0,top=0,location=0,menubar=0,toolbar=0,resizable=1,status=0,scrollbars=1");
	_newHelpWin.location=url;
	_newHelpWin.focus();
}

function processChkBox( inputName, ele ){
	var tEle = GetBForm()[inputName];
	if ( tEle ) {
		if ( ele.checked ) {
			tEle.value = "True";
		} 
		else {
			tEle.value = "False";
		}	
	}
	return true;
}

function BrowserData(){
	agent  = navigator.userAgent.toLowerCase();
				
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
		
	/* detection for netscape Browsers */
	this.ns    = ((agent.indexOf('mozilla')   !=   -1) && 
				 ((agent.indexOf('spoofer')   ==   -1) && 
				 (agent.indexOf('compatible') ==   -1)));
	this.ns4   = (this.ns && (this.major      ==    4));
	this.ns6   = (this.ns && (this.major      >=    5));
	this.dom = (document.getElementsByTagName && !document.all);
		
	/* detection for ie Browsers */
	this.ie    = (agent.indexOf("msie")       !=   -1);
	this.ie3   = (this.ie && (this.major      < 4));
	this.ie4   = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.0")   ==   -1));
		             
	this.ie5 = (document.getElementById && document.all);             
	this.ie50   = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.0")   !=   -1));
	this.ie55  = (this.ie && (this.major      ==    4) && 
	             (agent.indexOf("msie 5.5")   !=   -1));
		
	this.ie6   = (this.ie && (agent.indexOf("msie 6.0") != -1) );
		
	this.ie5Mac = ((agent.indexOf("mac") != -1) && this.ie5);
		
	/* detection for aol ie browsers */
	this.aol = (agent.indexOf("aol") != -1);
	this.aol3 = (this.aol && this.ie3);
	this.aol4 = (this.aol && this.ie4);
	this.aol5 = (this.aol && this.ie5);
}

oBD = new BrowserData();

/* direct link builder */
function flipDirectLinkBox()
{
	var directLinkBox = document.getElementById('directLinkBox');
	if ( directLinkBox )
	{
		if (directLinkBox.style.display == 'none') directLinkBox.style.display = 'block';
		else directLinkBox.style.display = 'none';
	}
}

function createDirectLink()
{
	var directLinkALink = document.getElementById('directLinkALink');
	directLinkALink.setAttribute('href',document.getElementById('directLinkURLHRef').getAttribute('value'));
	directLinkALink.innerHTML = GetBForm().elements['directLinkURLName'].value;
}

function onDirectLinkRadioClick(ele)
{
	document.getElementById('directLinkURLHRef').value = ele.value;
	document.getElementById('directLinkALink').href = ele.value;
}
function ImageMapDoLinkPost(url, formState){
	if(formState){
		formState = unescape(formState);
	}
	return doLinkPost(url, formState);
}
