function reloadFrame(framename)
{
	window.parent.frames[framename].location.reload();
	return;
}
function setCookie (name,value)
{
	var today = new Date();
	var expiry = new Date(today.getTime() + 28 * 24 * 60 * 60 * 1000);
	window.document.cookie = name + "=" + escape (value) + "; expires=" + expiry.toGMTString() +  "; path=/"; 
}
function getCookie (name)
{
	var dcookie = window.document.cookie;
	var cname = name + "=";
	var clen = dcookie.length;
	var cbegin = 0;
	while (cbegin < clen)
	{
		var vbegin = cbegin + cname.length;
		if (dcookie.substring(cbegin, vbegin) == cname)
		{
			var vend = dcookie.indexOf (";", vbegin);
			if (vend == -1) vend = clen;
			return unescape(dcookie.substring(vbegin, vend));
		}
		cbegin = dcookie.indexOf(" ", cbegin) + 1;
		if (cbegin == 0) break;
	}
	return null;
}
function getRT(documentObject, sourceField, targetFieldName, targetFieldObject)
{
	var form = documentObject.forms[0];
	//this gets a handle to the form
	if (documentObject.applets.length != 0 )
	{
		for(i=0;i<form.elements.length;i++)
		{
			// this makes sure there is an applet on the form somewhere
			appletName = "lna"+ form.elements[i].name;
			if(documentObject.applets[appletName] != null)
			{
				if (form.elements[i].name == targetFieldName)
				{ 
					targetFieldObject.value = documentObject.applets[appletName].getText("text//html");
				} 
			}
		}
	}
}
function evalObject(objectItem)
{
	var item = eval(objectItem);
	var objresults = "";
	for (var i in item)
	{
		objresults += i + " - " + item[i] + "\n";
	}
	alert(objresults);
}
var V_MANDATORY = 1;
var V_CHAR = 2;
var V_NUMERIC = 4;
var V_MONTH_MMYYYY = 8;
//fldname is the name of the first field name in group
//fldtype is the type of field.  Valid types are: 'text','select-one','select-multiple','textarea','checkbox','radio'
//n is the number of field in a group
//msg is the additional static text to prompt a user
function validate(fldname, fldtype, n, criteria, msg)
{
	var form = document.forms[0];
	//handle single field and multiple fields in group
	var fld_tmp = getStem(fldname, n);
	
	for (var p=1; p<=n; p++){
		//don't append serial number when checking for a single field
		if (n==1) q = ""
		else q = p;
		
		var fld = eval("form." + fld_tmp + q);
		
		//check for mandatory
		if ((V_MANDATORY & criteria) == V_MANDATORY){
			if (!isFilled(fld, fldtype, msg)) return false;
		}
		//check for numeric value
		if ((V_NUMERIC & criteria) == V_NUMERIC){
			if (!isNumeric(fld, fldtype, msg)) return false;
		}
		//check for month year format (mm/yyyy)		
		if ((V_MONTH_MMYYYY & criteria) == V_MONTH_MMYYYY){
			if (!isMMYYYY(fld, fldtype, msg)) return false;
		}
	}
	return true
}
//fld is the field object, multi values are separated by ;
//type is one of 'text','select-one','select-multiple','textarea','checkbox','radio'
function getValue(fld, type)
{
	var rtn = "";
	switch (type)
	{
		case "text":
		case "textarea":
		{
			return fld.value;
		}
		case "select-one":
		{
			if (fld.length == 0 || fld.selectedIndex == -1)
			{
				return "";
			}
			n = fld.selectedIndex;
			return fld.options[n].text;
		}
		case "select-multiple":
		{
			if (fld.length == 0 || fld.selectedIndex == -1)
			{
				return "";
			}
			for (var p=0; p < fld.options.length; p++)
			{
				if (fld.options[p].selected)
				{
					if (rtn!="") rtn += ";";
					rtn += fld.options[p].text;
				}
			}
			return rtn;
		}
		case "select-one-value":
		{
			if (fld.length == 0 || fld.selectedIndex == -1)
			{
				return "";
			}
			n = fld.selectedIndex;
			return fld.options[n].value;
		}
		case "select-multiple-value":
		{
			if (fld.length == 0 || fld.selectedIndex == -1)
			{
				return "";
			}
			for (var p=0; p < fld.options.length; p++)
			{
				if (fld.options[p].selected)
				{
					if (rtn!="") rtn += ";";
					rtn += fld.options[p].value;
				}
			}
			return rtn;
		}
		case "checkbox":
		{
			if (typeof(fld.length) == 'undefined')
			{
				if (fld.checked)
					return fld.value;
				else
					return "";
			}
			for (var p=0; p < fld.length; p++)
			{
				if (fld[p].checked)
				{
					if (rtn!="") rtn += ";";
					rtn += fld[p].value;
				}
			}
			return rtn;
		}
		case "radio":
		{
			for (var p=0; p < fld.length; p++)
			{
				if (fld[p].checked)
				{
					if (rtn!="") rtn += ";";
					rtn += fld[p].value;
				}
			}
			return rtn;
		}
		default:
			alert("getValue: Unknown type - " + type);
	}
}
//fld is the field object, multi values are separated by ;
//type is one of 'text','select-one','select-multiple','textarea','checkbox','radio'
//val is the value to be inserted
function setValue(fld, type, val)
{
	var rtn = "";
	
	switch (type)
	{
		case "text":
		case "textarea":
		{
			fld.value = val;
			break;
		}
		case "select-one":
		{
			for (var p=0; p<fld.options.length; p++)
			{
				if (fld.options[p].text==val)
				{
					fld.selectedIndex = p;
				}
			}
			break;
		}
		case "select-one-value":
		{
			for (var p=0; p<fld.options.length; p++)
			{
				if (fld.options[p].value==val)
				{
					fld.selectedIndex = p;
				}
			}
			break;
		}
		case "select-multiple":
		{
			var aVal = val.split(";");
		
			//clear the field
			for (var p=0; p < fld.options.length; p++)
				fld.options[p].selected = false;
			
			for (var n=0; n < aVal.length; n++)
			{
				for (var p=0; p < fld.options.length; p++)
				{
					if (fld.options[p].text==aVal[n])
					{
						fld.options[p].selected = true;
						break;
					}
				}
			}
			break
		}
		case "select-multiple-value":
		{
			var aVal = val.split(";");
		
			//clear the field
			for (var p=0; p < fld.options.length; p++)
				fld.options[p].selected = false;
			
			for (var n=0; n < aVal.length; n++)
			{
				for (var p=0; p < fld.options.length; p++)
				{
					if (fld.options[p].value==aVal[n])
					{
						fld.options[p].selected = true;
						break;
					}
				}
			}
			break;
		}
		case "checkbox":
		{
			var aVal = val.split(";");
			for (var n=0; n < aVal.length; n++)
			{
				for (var p=0; p < fld.length; p++)
				{
					if (fld[p].value==aVal[n])
					{
						fld[p].checked = true;
						break;
					}
				}
			}
			break
		}
		case "radio":
		{
			for (var p=0; p < fld.length; p++)
			{
				if (fld[p].value==val)
				{
					fld[p].checked = true;
				}			
			}
			break;
		}
		default:
			alert("setValue: Unknown type - " + type);
	}
}
//fld is the field object
//type is one of 'text','select-one','select-multiple','textarea','checkbox','radio'
function setFocus(fld, type)
{
	switch (type){
	case "text":
	case "textarea":{	
		fld.focus();
		fld.select();
		//window.scrollBy(0,-130); 
		break}
	case "select-one":
	case "select-multiple":{
		fld.focus();	
		break}
	case "checkbox":
	case "radio":{
		fld[0].focus();
		break}
	default:
		alert("setFocus: Unknown type")
	}
}
function getStem(fldname, n)
{
	var form = document.forms[0];
	var fld_tmp;
	
	//handle single field and multiple fields in group
	if (n==1) 
		fld_tmp = fldname;
	else {
		fld_len = fldname.length
		if (fldname.charAt(fld_len-1)=="1") 
			fld_tmp = fldname.substring(0, fld_len-1)
		else
			fld_tmp = fldname;
	}
	return fld_tmp;
}
//check if something has been entered
function isFilled(fld, type, msg)
{
	var tmp = getValue(fld, type);
	if (tmp == "" || tmp =="N/A"){				
		setFocus(fld, type);
		alert("Mandatory field requires a value.\n" + msg);
		return false;
	}
	return true;
}
//check if value is numeric
function isNumeric(fld, type, msg)
{
	var tmp = getValue(fld, type);
	var aValues = tmp.split(";");
	
	for (var n=0; n<aValues.length; n++){
		if (isNaN(aValues[n])){				
			setFocus(fld, type);
			alert("Numeric field requires a numeric value.\n" + msg);
			return false;
		}
	}
	return true;	
}
//check if date formate is mm/yyyy
function isMMYYYY(fld, type, msg)
{
	var tmp = getValue(fld, type);
	if (tmp=="") return true;
	
	var aValues = tmp.split(";");
	
	var cPattern = /^(\d{1,2})(\/|-)(\d{4})$/;
		
	for (var n=0; n<aValues.length; n++){
		var arrMatch = tmp.match(cPattern);
		if (arrMatch==null){
			setFocus(fld, type);
			alert("The correct format is mm/yyyy.\n" + msg);
			return false}
		else{
			month = arrMatch[1];
			year = arrMatch[3];
			if (month < 1 || month > 12 || year <=0) {
				setFocus(fld, type);
				alert("Incorrect value is found. month must be between 1 and 12.\n" + msg);
				return false;
			} 				
		}
	}
	return true;
}
// fullTrim will remove ALL spaces - use for validation checking of fields
// to make sure an actual value has been entered...not just empty spaces.
function fullTrim(cstring)
{
	var temp = "";
	if (cstring == null)
	{
		return temp;
	}
	cstring = '' + cstring;
	splitstring = cstring.split(" ");
	for(i = 0; i < splitstring.length; i++)
	temp += splitstring[i];
	return temp;
}
//trim() will trim all extra spaces on the left and right
function trim(cString)
{
	len = cString.length;
	if (len==0) return cString;
	
	for (var n=0; n<len; n++)
	{
		lPos = n;
		if (cString.charAt(n) != " ") break;
	}
	for (var n=len-1; n>=0; n--)
	{
		rPos = n;
		if (cString.charAt(n) != " ") break;
	}
	return cString.slice(lPos, rPos+1);
}
function compute(fld1, fld2, op, opt)
{
	var form = document.forms[0];
	
	fld1_tmp = eval("form." + fld1 + ".value");
	fld2_tmp = eval("form." + fld2 + ".value");
	if (isNaN(fld1_tmp) || isNaN(fld2_tmp) || (fld1_tmp=="") || (fld2_tmp=="")){
		return ""
	}else{
		result = eval(fld1_tmp + op + fld2_tmp)
		if (isNaN(result)) return ""
		else {
			if (op=="/" && opt=="100") 
				return result * 100
			else if (op=="*" && opt=="100")
				return result / 100
			else
				return result
		}
	}
}
function sum(fldname, n)
{
	var form = document.forms[0];
	var fld_tmp;
	
	//handle single field and multiple fields in group
	if (n==1) 
		fld_tmp = fldname;
	else {
		fld_len = fldname.length
		if (fldname.charAt(fld_len-1)=="1") 
			fld_tmp = fldname.substring(0, fld_len-1)
		else
			fld_tmp = fldname;
	}
	var tmp = 0;
	for (p=1; p<=n; p++){
		//don't append serial number when checking for a single field
		if (n==1) q = ""
		else q = p;
		
		fldvalue = eval("form." + fld_tmp + q + ".value");
		if (fldvalue != "")
			tmp = tmp + parseFloat(fldvalue)
	}
	return tmp;
}
function formatNumber(num, opt, factor)
{
//opt == -1 round up. ie, 58.15 gives 59
//opt == -2 round down. ie, 58.95 gives 58
//opt == -3 normal rounding, ie, 58.49 gives 58; 58.50 gives 59
//opt == n indicates number of decimal points will be kept.  No rounding is carried out.
//factor to be rounded to.  Assuming factor >= 1
	tmp_num = parseInt(num);
	tmp_opt = parseInt(opt);
	tmp_factor = (factor=="") ? 1 : parseInt(factor);
	if (isNaN(tmp_opt) || isNaN(tmp_num)) return num;
		
	left_over = (tmp_factor==1) ? (num - tmp_num) : (tmp_num % tmp_factor);
	switch (tmp_opt){
	case -1:{
		if (tmp_factor==1) 
			return (num>tmp_num) ? (tmp_num + 1) : tmp_num;
		else
			//return (num>=tmp_num) ? (tmp_num + tmp_factor - left_over) : tmp_num;
			return (left_over != 0) ? (tmp_num + tmp_factor - left_over) : tmp_num;
			
		break}
	case -2:{
		if (tmp_factor==1)
			return tmp_num
		else
			return tmp_num - left_over;
			
		break}
	case -3:{
		half_factor = factor / 2;
		if (tmp_factor==1)
			return (left_over>=half_factor) ? (tmp_num + tmp_factor) : tmp_num;
		else
			return (left_over>=half_factor) ? (tmp_num + tmp_factor - left_over) : (tmp_num - left_over);
		//remaider = num - tmp_num;
		//return (remaider>=0.5) ? (tmp_num + 1) : tmp_num;
		break}
	default:{ //deal with decimal points
		remaider = num - tmp_num;
		strTmp = new String(remaider);
		new_remaider = strTmp.substring(0, tmp_opt + 2);
		return tmp_num + parseFloat(new_remaider);
		break}		
	}
}
//double click to clear radio button
function clearRadio(fld)
{
	for (var p=0; p < fld.length; p++){
		fld[p].checked = false;
	}	
}
function words(cString, cSep)
{
	var cTmp = cString.split(cSep)
	return cTmp.length;
}
function word(cString, cSep, n)
{
	var cTmp = cString.split(cSep)
	return (n <= cTmp.length) ? cTmp[n-1] : ""
}
function left(cString, n)
{
	var cTmp = "";
	for (var i=0; i < n; i++)
	{
		cTmp = cTmp + cString.charAt(i);
	}
	return cTmp
}
function strLeft(cString, subString)
{
	cCharPos = cString.indexOf(subString)
	if (cCharPos <= 0)
	{
		return "";
	}
	else
	{
		return left(cString, cCharPos);
	}
}
function right(cString, n)
{
	var cTmp = "";
	strLength = cString.length;
	for (var i=0; i < n; i++)
	{
		cTmp = cString.charAt(strLength-i) + cTmp;
	}
	return cTmp
}
function strRight(cString, subString)
{
	cCharPos = cString.indexOf(subString)
	cLen = cString.length
	if (cCharPos == -1)
	{
		return "";
	}
	else
	{
		return right(cString, cLen-cCharPos);
	}
}
function instr(cString, subString)
{
	if (cString.indexOf(subString) > -1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
function detectBrowser()
{
	var oldOnError = window.onerror;
	var element = null;
	window.onerror = defaultOnError;
	navigator.OS = '';
	navigator.version = 0;
	navigator.org = '';
	navigator.family = '';
	var platform;
	if (typeof(window.navigator.platform) != 'undefined')
	{
		platform = window.navigator.platform.toLowerCase();
		if (platform.indexOf('win') != -1)
			navigator.OS = 'win';
		else if (platform.indexOf('mac') != -1)
			navigator.OS = 'mac';
		else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
			navigator.OS = 'nix';
	}
	var i = 0;
	var ua = window.navigator.userAgent.toLowerCase();
	if (ua.indexOf('opera') != -1)
	{
		i = ua.indexOf('opera');
		navigator.family = 'opera';
		navigator.org = 'opera';
		navigator.version = parseFloat('0' + ua.substr(i+6), 10);
	}
	else if ((i = ua.indexOf('msie')) != -1)
	{
		navigator.org = 'microsoft';
		navigator.version = parseFloat('0' + ua.substr(i+5), 10);
		if (navigator.version < 4)
			navigator.family = 'ie3';
		else
			navigator.family = 'ie4'
	}
	else if (typeof(window.controllers) != 'undefined' && typeof(window.locationbar) != 'undefined')
	{
		i = ua.lastIndexOf('/')
		navigator.version = parseFloat('0' + ua.substr(i+1), 10);
		navigator.family = 'gecko';
		if (ua.indexOf('netscape') != -1)
			navigator.org = 'netscape';
		else if (ua.indexOf('compuserve') != -1)
			navigator.org = 'compuserve';
		else
			navigator.org = 'mozilla';
	}
	else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
	{
		var is_major = parseFloat(navigator.appVersion);
		if (is_major < 4)
			navigator.version = is_major;
		else
		{
			i = ua.lastIndexOf('/')
			navigator.version = parseFloat('0' + ua.substr(i+1), 10);
		}
		navigator.org = 'netscape';
		navigator.family = 'nn' + parseInt(navigator.appVersion);
	}
	else if ((i = ua.indexOf('aol')) != -1 )
	{
		// aol
		navigator.family = 'aol';
		navigator.org = 'aol';
		navigator.version = parseFloat('0' + ua.substr(i+4), 10);
	}
	navigator.DOMCORE1 = (typeof(document.getElementsByTagName) != 'undefined' && typeof(document.createElement) != 'undefined');
	navigator.DOMCORE2 = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined' && typeof(document.createElementNS) != 'undefined');
	navigator.DOMHTML = (navigator.DOMCORE1 && typeof(document.getElementById) != 'undefined');
	navigator.DOMCSS1 = ( (navigator.family == 'gecko') || (navigator.family == 'ie4') );
	navigator.DOMCSS2 = false;
	if (navigator.DOMCORE1)
	{
		element = document.createElement('p');
		navigator.DOMCSS2 = (typeof(element.style) == 'object');
	}
	navigator.DOMEVENTS = (typeof(document.createEvent) != 'undefined');
	window.onerror = oldOnError;
}
function validateEmail(checkAddress)
{
	// Checking for the existence of "@" and ".". 
	// Length must >= 5 and the "." must not directly precede or follow the "@"
	if (fullTrim(checkAddress) == "")
	{
		return true;
	}
	else if (checkAddress.indexOf("@") == -1)
	{
		return false;
	}
	else if (checkAddress.charAt(0) == ".")
	{
		return false;
	}
	else if (checkAddress.charAt(0) == "@")
	{
		return false;
	}
	else if (checkAddress.len < 6)
	{
		return false;
	}
	else if (checkAddress.indexOf(".") == -1)
	{
		return false;
	}
	else if (checkAddress.charAt(checkAddress.indexOf("@")+1) == ".")
	{
		return false;
	}
	else if (checkAddress.charAt(checkAddress.indexOf("@")-1) == ".")
	{
		return false;
	}
	else
	{
		return true;
	}
}
function showProcess(profileUNID)
{
	var boxWidth = (screen.width/3) * 2;
	var boxHeight = (screen.height/3) * 2;
	var winX = (screen.width - boxWidth) / 2;
	var winY = (screen.height - boxHeight) / 2;
	var windowoptions="menubar=no,scrollbars=yes,resizable=yes,toolbar=no,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
	var href = window.location.href;
	var newurl = href.substring(0,(href.lastIndexOf('.nsf')+5));
	newWindowURL = newurl + "(WebOutputDistribForm)?OpenAgent&UNID=" + profileUNID;
	window.open(newWindowURL,"_blank",windowoptions);
	currentWindowURL = newurl + "ConfirmPayment?OpenForm&UNID=" + profileUNID;
	window.open(currentWindowURL, '_self');
}
function showHelp(helpTopicURL)
{
	var boxWidth = (screen.width/3)*2;
	var boxHeight = (screen.height/3)*2;
	var winX = (screen.width - boxWidth) / 2;
	var winY = (screen.height - boxHeight) / 2;
	var windowoptions="menubar=no,scrollbars=yes,resizable=yes,toolbar=no,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
	windowURL = helpTopicURL + "&NoEdit=1&HideMenu=1&IsDialog=1";
	window.open(windowURL ,"_blank",windowoptions)
}
function openLinkInWindow(urlValue)
{
	if (urlValue == "")
	{
		return false;
	}
	var boxWidth = (screen.width/3)*2;
	var boxHeight = (screen.height/3)*2;
	var winX = (screen.width - boxWidth) / 2;
	var winY = (screen.height - boxHeight) / 4;
	if (urlValue.indexOf('.nsf') == -1)
	{
		var windowoptions="menubar=yes,scrollbars=yes,resizable=yes,toolbar=no,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
		var windowURL = urlValue;
	}
	else
	{
		var windowoptions="menubar=no,scrollbars=yes,resizable=yes,toolbar=no,status=yes,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
		var windowURL = urlValue + "&IsDialog=1";
	}
	window.open(windowURL,"_blank",windowoptions)
}
function openExternalURLLink(urlValue)
{
	if (urlValue == "")
	{
		return false;
	}
	var boxWidth = (screen.width/3)*2;
	var boxHeight = (screen.height/3)*2;
	var winX = (screen.width - boxWidth) / 2;
	var winY = (screen.height - boxHeight) / 4;
	var windowoptions="menubar=yes,scrollbars=yes,resizable=yes,toolbar=no,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
	window.open(urlValue,"_blank",windowoptions)
}
function hideBlock(sectionName)
{
	hideShowBlock(sectionName, true);
}
function showBlock(sectionName)
{
	hideShowBlock(sectionName, false);
}
function hideShowBlock(sectionName, hide)
{
	var visibilityFlag;
	var displayFlag;
	if (hide)
	{
		visibilityFlag = 'hidden';
		displayFlag = 'none';
	}
	else
	{
		visibilityFlag = 'visible';
		displayFlag = 'block';
	}
	if (document.getElementById)
	{
		// DOM3 = IE5, NS6
		document.getElementById(sectionName).style.display = displayFlag;
	}
	else
 	{
		if (document.layers)
		{
			// Netscape 4
			//document.hideshow.visibility = 'hidden';
			var hideSectionHandle = eval("document." + sectionName + ".display");
			hideSectionHandle = displayFlag;
		}
		else
		{
			// IE 4
			//document.all.hideshow.style.visibility = 'hidden';
			var hideSectionHandle = eval("document.all." + sectionName + ".style.display");
			hideSectionHandle = displayFlag;
		}
	}
}
function isBlockVisible(sectionName)
{
	var displayFlag = "";
	if (document.getElementById)
	{
		// DOM3 = IE5, NS6
		displayFlag = document.getElementById(sectionName).style.display;
	}
	else
 	{
		if (document.layers)
		{
			// Netscape 4
			var sectionHandle = eval("document." + sectionName);
			displayFlag = sectionHandle.display;
		}
		else
		{
			// IE 4
			var sectionHandle = eval("document.all." + sectionName + ".style");
			displayFlag = sectionHandle.display;
		}
	}
	alert("Display Flag: " + displayFlag);
	if (displayFlag == "none")
		return false;
	else
		return true;
}
function showCell(sectionName)
{
	hideShowCell(sectionName, false);
}
function hideShowCell(sectionName, hide)
{
	var visibilityFlag;
	var displayFlag;
	if (hide)
	{
		visibilityFlag = 'hidden';
		displayFlag = 'none';
	}
	else
	{
		if (navigator.appName.indexOf("Microsoft") > -1)
		{
			visibilityFlag = 'visible';
			displayFlag = 'block';
		}
		else
		{
			visibilityFlag = 'visible';
			displayFlag = 'table-cell';
		} 
	}
	if (document.getElementById)
	{
		// DOM3 = IE5, NS6
		document.getElementById(sectionName).style.display = displayFlag;
	}
	else
 	{
		if (document.layers)
		{
			// Netscape 4
			//document.hideshow.visibility = 'hidden';
			var hideSectionHandle = eval("document." + sectionName + ".display");
			hideSectionHandle = displayFlag;
		}
		else
		{
			// IE 4
			//document.all.hideshow.style.visibility = 'hidden';
			var hideSectionHandle = eval("document.all." + sectionName + ".style.display");
			hideSectionHandle = displayFlag;
		}
	}
}
function getObject(objectName)
{
	
	if (document.getElementById)
	{
		// DOM3 = IE5, NS6
		return document.getElementById(objectName);
	}
	else
 	{
		if (document.layers)
		{
			// Netscape 4
			return eval("document." + objectName);
		}
		else
		{
			// IE 4
			return eval("document.all." + objectName);
		}
	}
}
function selectName(selectOptions)
{
	if (selectOptions == null || selectOptions == "")
	{
		return;
	}
	var boxWidth = 600;
	var boxHeight = 360;
	var winX = (screen.width - boxWidth) / 2;
	var winY = (screen.height - boxHeight) / 2;
	var windowoptions="status=no,resizable=yes,menubar=no,scrollbars=yes,toolbar=no,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
	var href = window.location.href.toLowerCase();
	windowURL = href.substring(0,(href.indexOf('.nsf')+5)) + "NamesSelect?OpenForm" + selectOptions;
	childWindow = window.open(windowURL,"_blank",windowoptions);
	if (!childWindow.opener) childWindow.opener = self;
}
function getNotesName(nameFormat, nameValue) 
{ 
        // Perform conversion of a Lotus Notes name into the following supported name formats: 
        // * Common 
        // * Abbreviated 
        // * Canonical 
        var returnName = ""; 

        if (nameValue == null || fullTrim(nameValue) == "") 
        { 
                // Passed value is null 
                return returnName; 
        } 
        
        if (nameFormat == null || fullTrim(nameFormat) == "") 
        { 
                // Passed format is null - return original value 
                return nameValue; 
        } 
        
        if (nameFormat == "Canonical") 
        { 
                if (nameValue.toLowerCase().indexOf("cn=") != -1) 
                { 
                        // The name is already in canonical format.  Return it 
                        return nameValue; 
                } 

                if (nameValue.indexOf("/") == -1) 
                { 
                        // The name doesn't contain any canonical components.  Return the common name in canonical format 
                        returnName = "CN=" + nameValue; 
                        return returnName;         
                } 
                
                var components = nameValue.split("/"); 
                for (var n=0; n < components.length; n++) 
                { 
                        if (n == 0) 
                                returnName = returnName + "CN=" + components[n]; 
                        else if (n+1 == components.length) 
                                returnName = returnName + "/O=" + components[n]; 
                        else 
                                returnName = returnName + "/OU=" + components[n]; 
                } 
                return returnName;         
        } 
        else if (nameFormat == "Abbreviated") 
        { 
                if (nameValue.toLowerCase().indexOf("cn=") == -1) 
                { 
                        // The name is not in canonical format.  Return it as is 
                        return nameValue; 
                } 
                
                if (nameValue.indexOf("/") == -1) 
                { 
                        // The name doesn't contain any canonical components.  Return the name as is 
                        return nameValue; 
                } 
                
                var components = nameValue.split("/"); 
                for (var n=0; n < components.length; n++) 
                { 
                        if (n > 0) 
                                returnName = returnName + "/"; 
                                
                        if (components[n].indexOf("=") == -1) 
                        {         
                                returnName = returnName + components[n]; 
                        } 
                        else 
                        { 
                                var nameComponents = components[n].split("="); 
                                returnName = returnName + nameComponents[1]; 
                        } 
                } 
                return returnName;         
        } 
        else if (nameFormat == "Common") 
        { 
                if (nameValue.indexOf("/") == -1) 
                { 
                        // The name doesn't contain any canonical components.  Return the name as is 
                        return nameValue; 
                } 

                var components = nameValue.split("/"); 
                if (components[0].indexOf("=") == -1) 
                {         
                        returnName = components[0]; 
                } 
                else 
                { 
                        var nameComponents = components[0].split("="); 
                        returnName = nameComponents[1]; 
                } 
                return returnName; 
        } 
        else 
        { 
                // Unsupported format - return the value as is 
                return nameValue; 
        } 
}
var ajaxReq;
var ajaxProcessingWindow = null;
function ajaxRequest(agentName, args)
{
	var requestURL = document.forms[0].WebPageDb.value + "/" + agentName + "?OpenAgent" + args;
	//alert("Request: " + requestURL);
	if (window.XMLHttpRequest) 
	{
		ajaxReq = new XMLHttpRequest();
		//ajaxReq.overrideMimeType('text/xml');
		ajaxReq.onreadystatechange = ajaxProcessResponse;
		ajaxReq.open("GET", requestURL , true);
		ajaxReq.send(null);
	} 
	else if (window.ActiveXObject)
	{
		ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
		if (ajaxReq) 
		{
			ajaxReq.onreadystatechange = ajaxProcessResponse;
			ajaxReq.open("GET", requestURL, true);
			ajaxReq.send();
		}
	}
}

function ajaxProcessResponse()
{
	if (ajaxReq.readyState == 4)    // 4 = completed
	{
		if (ajaxProcessingWindow != null)
		{
			ajaxProcessingWindow.close();
			ajaxProcessingWindow = null;
		}
		if (ajaxReq.status == 200)    // 200 = ok
		{
			//var response = ajaxReq.responseXML.documentElement;   
			var response = ajaxReq.responseText;
			ajaxPopulateData(response);
		} 
		else 
		{
			alert("There was a problem processing the XML response: " + ajaxReq.statusText);
		}
	}
}
function ajaxPopulateData(response)
{
	//alert("Response: " + response);
	var returnedDataObject = eval(response); 
	if (returnedDataObject == null)
	{
		alert("The response from the server could not be successfully decoded.");
		return false;  // Response was not successfully evaluated or returned
	}
	for (var i = 0; i < returnedDataObject.length; i++)
	{
		var totalItems;
		var dataType;
		var alertMessage = "";
		var errorMessage = "";
		var targetFieldName;
		var postFunctionName = "";
		if (returnedDataObject[i].totalItems)
			totalItems = returnedDataObject[i].totalItems;
		if (returnedDataObject[i].dataType)
			dataType = returnedDataObject[i].dataType;
		if (returnedDataObject[i].targetFieldName)
			targetFieldName = returnedDataObject[i].targetFieldName;
		if (returnedDataObject[i].alertMessage)
			alertMessage = returnedDataObject[i].alertMessage;
		if (returnedDataObject[i].errorMessage)
			errorMessage = returnedDataObject[i].errorMessage;
	
		if (returnedDataObject[i].postFunction)
			postFunctionName = returnedDataObject[i].postFunction;
		//alert("Total items returned: " + totalItems);
		//alert("Data type: " + dataType);
		//alert("Target field: " + targetFieldName);
		//alert("Post function name: " + postFunctionName);
		if (fullTrim(errorMessage) != "")
		{
			alert("The server request failed.\r\n\r\n" + errorMessage);
		}
		else
		{
			if (parseInt(totalItems) > 0)
			{
				var itemsArray = returnedDataObject[i].items;
				var targetField = eval("document.forms[0]." + targetFieldName);
				if (targetField != null)
				{
					if (dataType == "select-one" || dataType == "select-multiple")
					{
						// Clear out existing value in the list
						targetField.options.length = 0;
	
						// Set the first option to null
						//targetField.options[0] = new Option("");
	
						// Load the list with new values
						for (var j = 0; j < itemsArray.length; j++)
						{
							var itemText = itemsArray[j].text;
							var itemValue = itemsArray[j].value;
							targetField.options[j] = new Option(itemText, itemValue);
						}
					}
					else
					{
						setValue(targetField, dataType, itemsArray);
					}
				}
	
			}
			else
			{
				// No items were returned
				if (fullTrim(targetFieldName) != "")
				{
					var targetField = eval("document.forms[0]." + targetFieldName);
					if (targetField != null)
					{
						if (dataType == "select-one" || dataType == "select-multiple")
						{
							// Clear out existing value in the list
							targetField.options.length = 0;
						}
					}
				}
			}
	
			// Display an alert message
			if (fullTrim(alertMessage) != "")
			{
				alert(alertMessage);
			}
			// Call the post data load function if specified
			if (fullTrim(postFunctionName) != "")
			{
				callFunction = eval("window." + postFunctionName);
				if (callFunction)
					eval("window." + postFunctionName + "()");
			}
		}
	}
}
function ajaxShowProcessingWindow(title)
{
	// Load the processing window
	var boxWidth = 300;
	var boxHeight = 190;
	var winX = (screen.width - boxWidth) / 2;
	var winY = (screen.height - boxHeight) / 2;
	var windowoptions="menubar=no,scrollbars=no,resizable=no,toolbar=no,top="+winY+",left="+winX+",height="+boxHeight+",width="+boxWidth;
	var windowURL = document.forms[0].WebPageDb.value + "/WebProcessing?OpenForm&Title=" + title;
	ajaxProcessingWindow = window.open(windowURL,"_blank",windowoptions);
}
