var cc = "H4"; //category classvar selectString = "--- Select ---";var valueSeperator = "; "; // also declared in dropdown.jsvar xmlHttp = false;function AjaxInit(){	try { 	/* AJAX - Create a new XMLHttpRequest object to talk to the Web server */		xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");	} catch (e) {	  	try {			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");		} catch (e2) {			xmlHttp = false;		}	}	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {		xmlHttp = new XMLHttpRequest();	}}/* This is the queue that all Ajax requests get appended to.Ensures the requests are processed one after the other, to maintain order.When the push function is called, an ajax request (url + ready state function) get put in an array.Each time another ajax request is made, it gets put in a queue. If the queue is not currently in the state of processing, the request will be processed.Upon completion of the ready state function, the next request in the array is processed.*/var ajaxQueue = {	errors: [],	errorsInit : function(){		for(x=ajaxQueue.errors.length-1;x>=0;x--){			ajaxQueue.errors.pop();		}	},		urlQueue : [],	optionsQueue:[], 	updateQueue: [],	processing: false,	push : function(url, options, update){		if(typeof options == "string"){			this.urlQueue.push(url);			this.optionsQueue.push(options);			this.updateQueue.push(update);	//		document.getElementById("inqueue").value = (parseInt(document.getElementById("inqueue").value) + 1)+""			if(!ajaxQueue.processing) ajaxQueue.processNext();		}	},	processNext : function() {		if(ajaxQueue.urlQueue.length > 0){			xmlHttp = false; // clear the object			ajaxQueue.processing = true; // flag that ajax is currently processing a request			var processURL = ajaxQueue.urlQueue[0];			var processProc = ajaxQueue.optionsQueue[0];			var processUpd = ajaxQueue.updateQueue[0];			ProcessAjax(processURL,processProc);		}else{			ajaxQueue.processing = false;		}	},		pull : function(){		var removeURL = ajaxQueue.urlQueue.shift();		var removeProc = ajaxQueue.optionsQueue.shift();		var removeUpd = ajaxQueue.updateQueue.shift();//		document.getElementById("inqueue").value = (parseInt(document.getElementById("inqueue").value) - 1)+""		return true;	}}function ProcessAjax(processURL, returnFunction){	// this is the function called to process an Ajax request	// called seperately or from the ajaxQueue	if(!xmlHttp) AjaxInit();	if(xmlHttp) {		if(processURL!="") {			if(processURL.indexOf("&term=")==-1){				xmlHttp.open("GET",processURL , true);   // Open a connection to the server				xmlHttp.onreadystatechange = eval(returnFunction);   //ShowLookupValidate;  // Setup a function for the server to run when it's done				xmlHttp.send(null); // Send the request			}else{				var qs = new QueryString(processURL); // Parse a given querystring				var term = qs.get("term"); // if "&term=" in url, process with escape characters				var newTerm = escape(parseMerge(term));				if(unescape(newTerm)== selectString ){ // don't process AJAX for these terms					if(ajaxQueue.pull()) ajaxQueue.processNext();				}else{					processURL = processURL.replace(escape(term), newTerm);					processURL = replaceSpecialChar(processURL);//	alert(processURL)										xmlHttp.open("GET",processURL , true);   // Open a connection to the server					xmlHttp.onreadystatechange = eval(returnFunction);   //ShowLookupValidate;  // Setup a function for the server to run when it's done					xmlHttp.send(null); // Send the request				}			}		}else{ // used to process an error function which is stored on the local form			eval(returnFunction);			ajaxQueue.pull();			ajaxQueue.errorsInit();			ajaxQueue.processing = false;			ajaxQueue.processNext();		}	}}function parseMerge(mergeText){	// extracts field values from string with "_@fieldname@_"	// otherwise will evaluate javascript within "_@*javascriptformula*@_"	// _@ is used as these characters do not get encoded	// %plus% is used to calculate the addition or concatenation of field values because '+' gets replaced with empty spaces	sf = mergeText.indexOf("_@");	ef = mergeText.indexOf("@_");	if(sf == -1 || ef == -1) return mergeText;	sff = mergeText.indexOf("_@*");	eff = mergeText.indexOf("*@_");	if(sff == -1 || eff == -1){ // process fieldname		fieldName = mergeText.substring(sf+2, ef);		if(fieldName=="") return mergeText;		fieldValue = getFieldValue(fieldName);		newText = mergeText.replace("_@"+fieldName+"@_", fieldValue);	}else{ // process javascript formula		jsFormula = mergeText.substring(sff+3, eff);		mergeText = mergeText.replace(/%plus%/g, '+');		jsFormula = jsFormula.replace(/%plus%/g, '+'); // replaces all occurance of %plus% with "+" signs for correct evaluation	//	alert(jsFormula)		fieldValue = eval(jsFormula);	//	alert("replace: "+mergeText +" containing _@*"+jsFormula+"*@_ with "+fieldValue)		newText = mergeText.replace("_@*"+jsFormula+"*@_", fieldValue);	}	return parseMerge(newText);}function evalKey(key){	// replaces '+' with code to replace in parseMerge()	var newKey = key.replace(/\+/g, "%plus%");	return newKey}function queueField(fieldname){	// prepares a fieldname to be calculated when processed in the AJAX queue	return "_@"+fieldname+"@_";}function queueFormula(jsFormula){	// prepares a javascript formula to be calculated when processed in the AJAX queue	return "_@*"+evalKey(jsFormula)+"*@_";}function replaceSpecialChar(term){	// had to replace special char pattern as error on servlet "11/04/2008 01:38:34 PM  HTTP JVM: java.lang.IllegalArgumentException: null"	// sometimes these characters get copied from word documents	term = term.replace(/%u2013/g, "_u2013"); // longer dash	term = term.replace(/%u2018/g, "_u2018"); // left single quote	term = term.replace(/%u2019/g, "_u2019"); // right single quote	term = term.replace(/%u201C/g, "_u201C"); // left double quote	term = term.replace(/%u201D/g, "_u201D"); // right double quote	term = term.replace(/%22/g, "_22_"); // double quote	return term;}// next two functions use the servlet to perform db lookupsfunction dbLookup(db, view, term, returnField, server){/* Uses the servlet to perform db lookups.It should be passed a database, view, term to search for through the url ?&db=names.nsf&view=($VIMPeople)&term=bob'returnValue' should be list of fields or columnNumber to returnie. &returnValue=TeacherSchool=6,TeacherDeptCentre=7,TeacherTel=Phone,TeacherEmail=Emailwhere 'TeacherSchool' etc are fields on the form"server" is at the end as it is optional - if not provided the current server will be used.*/	term = trimStr(escape(term));//	term = trimStr(term);	if(server==null) server=""	var url = "/servlet/DBLookupSearch?&server="+server+"&db="+db+"&view="+view+"&term="+term+"&returnValue="+returnField+"&rn="+Math.floor(Math.random()*1000);	ajaxQueue.push(url,  'ShowLookupResults'); // put into AJAX queue	}function ShowLookupResults(){	// process the results returned by the dbLookup function	if (xmlHttp.readyState == 4 ){		if(ajaxQueue.pull()){			var response = xmlHttp.responseText;			if (response!="") {				var nameArray = response.split("\n");				for(x=0;x<nameArray.length-1;x++){					if(typeof nameArray[x] == "string"){						var fieldValueArray = nameArray[x].split("=");						var fieldObj = document.getElementById(fieldValueArray[0]);						insertTextInField(fieldObj, fieldValueArray[1]);					}				}			}			document.getElementById('wait').className='hide'			ajaxQueue.processNext(); // process next ajax request in queue		}	}else{		if(xmlHttp.readyState <4 && document.getElementById('wait').className=='hide') document.getElementById('wait').className=''	}}function formatResult(fieldname){	// formats the results substituting the "; " with a carriage return	var x = document.getElementById(fieldname).value	document.getElementById(fieldname).value = x.replace(/; /g, "\n")}/* the next two functions validate the drop down selection */function dbValidate(db, view, column, validateField, server){/* This function validate the elements of a field with what is in a database.This function should be passed the database, the view, the column, and the fieldname.If the field has multiple values, they should be seperated with the valueSeperator variable.The field value(s) is then passed to the servlet via url to be verified."server" is at the end as it is optional - if not provided the current server will be used.*/	var validateFieldObj = document.getElementById(validateField);	var parseField = validateFieldObj.value;		if(parseField=="") return;		var fieldArray = new Array();		if(parseField.indexOf(valueSeperator)==-1){ // if the field is single value, put in array		fieldArray[0] = parseField;	}else{ // 	if the field is multi-value, put in array		fieldArray = parseField.split(valueSeperator);	}		var checkValues = "";	for(x=0;x<fieldArray.length;x++){ // add values in array to url		checkValues = checkValues + fieldArray[x]+";"	}	if(server==null) server=""	var url = "/servlet/DBColumnValidate?&server="+server+"&db="+db+"&view="+view+"&col="+column+"&term="+checkValues;	ajaxQueue.push(url,  "ShowLookupValidate"); // put request in ajax queue}var initValid = "The following values are not valid: \n";function ShowLookupValidate(){	// process the results returned by the dbValidate function	if (xmlHttp.readyState == 4 ){			var response = xmlHttp.responseText;			if (response!="") {				ajaxQueue.errors.push(response);			}			if(ajaxQueue.pull()) ajaxQueue.processNext(); // process next ajax request in queue	}}function CST(tableName){	//check to see if sorttable.js is available	//sorts the given tableName (id)	//use onmousedown on table header <tr>	//ie <table class="sortable" id="TableA"><thead><tr onmousedown="CST('TableA');"....	if (typeof sorttable == "undefined") return	if (sorttable) sorttable.flagSortable(tableName);}function setRowGroup(rowName,classname){//sets a list of elements numbered in order such as element1, element2,element3...//to be all set to a class. You can enter as many elements of the same prefix as required. 	x = 1;	el = document.getElementById(rowName+x);	while (el != null){		el.className=classname;		x++;		el = document.getElementById(rowName+x);	}}function setClass(el,classname){	// given a form element, will set the class	if(isString(el)) el = document.getElementById(el);	if(el != null) el.className=classname;}function toggleClass(el,classname1,classname2){	// toggles the class of a form element	if(typeof el =="string") el = document.getElementById(el);	if(el.className==classname1){		el.className=classname2;	}else{		el.className=classname1;	}}function toggleText(el,text1,text2){//	toggles the text of an element	if(el.innerText==text1){		el.innerText=text2;	}else{		el.innerText=text1;	}}function toggleCheckbox(fieldname, onOff){	// select or deselect all function for a checkbox	var row = document.getElementsByName(fieldname);	for(rowNum=0;rowNum<row.length;rowNum++){		row[rowNum].checked = onOff;	}}function OpenThesaurus(returnField, numCols, fileName, fieldName, title){	// open thesaurus 	// returnField:	field to return value to..	// numCols:		number of columns to display in popup window	// fildName:		if a thesaurus already exists from another database that needs to be used, enter the notes database filename ie. map.nsf	// fieldName: 	if a thesaurus already exists from another database that needs to be used, enter the notes database fieldname ie. Thesaurus_Keywords	if(fileName==null) fileName = "";	if(fieldName==null) fieldName = "";	if(title==null) title = "";	// dbName should be defined as a global variable on the form	var url = "/"+dbName+"/Thesaurus?OpenForm&returnField="+returnField+"&numCols="+numCols+"&fileName="+fileName+"&fieldName="+fieldName+"&title="+title;	window.open(url,'Thesaurus','width=800,height=800,toolbar=yes, location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,copyhistory=yes, resizable=yes');}//below are other interesting functions..function isAlien(a) {   return isObject(a) && typeof a.constructor != "function";}function isArray(a) {    return isObject(a) && a.constructor == Array;}function isBoolean(a) {    return typeof a == "boolean";}function isEmpty(o) {    var i, v;    if (isObject(o)) {        for (i in o) {            v = o[i];            if (isUndefined(v) && isFunction(v)) {                return false;            }        }    }    return true;}function isFunction(a) {    return typeof a == "function";}function isNull(a) {    return typeof a == "object" && !a;}function isNumber(a) {    return typeof a == "number" && isFinite(a);}function isObject(a) {    return (a && typeof a == "object") || isFunction(a);}function isString(a) {    return typeof a == "string";}function isUndefined(a) {    return typeof a == "undefined";} function numbersonly(myfield, e, dec, allowTime)// copyright 1999 Idocs, Inc. http://www.idocs.com// Distribute this script freely but keep this notice in place//updated by Clayton Gilbert{var key;var keychar;var numbers = "0123456789";if(allowTime) numbers = "0123456789:APMapm "if (window.event)   key = window.event.keyCode;else if (e)   key = e.which;else   return true;keychar = String.fromCharCode(key);// control keysif ((key==null) || (key==0) || (key==8) ||     (key==9) || (key==13) || (key==27) || (key==46) || (key==37) || (key==39))   return true;// numberselse if (((numbers).indexOf(keychar) > -1))   return true;//decimal pointselse if (dec && (keychar=="."))   {   return true;   }else   return false;}function InvalidFilename(filename){// used to validate a filename with no special characters	if(filename.indexOf("#") > -1) return "#";	if(filename.indexOf("%") > -1) return "%";	if(filename.indexOf("@") > -1) return "@";	if(filename.indexOf("&") > -1) return "&";	if(filename.indexOf("*") > -1) return "*";	if(filename.indexOf("!") > -1) return "!";	if(filename.indexOf("^") > -1) return "^";	if(filename.indexOf("~") > -1) return "~";	if(filename.indexOf(";") > -1) return ";";	if(filename.indexOf(",") > -1) return ",";	if(filename.indexOf("{") > -1) return "{";	if(filename.indexOf("}") > -1) return "}";	if(filename.indexOf("?") > -1) return "?";	if(filename.indexOf("\"") > -1) return "\"";		return false;}function createCookie(name,value,daysValid) {	if(name==null) return "";	var days = 5; //number of days to keep cookie valid	if(isNumber(daysValid)) days = daysValid;	if (days) {		var date = new Date();		date.setTime(date.getTime()+(days*24*60*60*1000));		var expires = "; expires="+date.toGMTString();	}	else var expires = "";	name = name.replace(/ /g,''); //remove spaces	document.cookie = name+"="+value+expires+"; path=/";	}function readCookie(name) {	if(name==null) return "";	name = name.replace(/ /g,'');  //remove spaces	var nameEQ = name + "=";	var ca = document.cookie.split(';');	for(var i=0;i < ca.length;i++) {		var c = ca[i];		while (c.charAt(0)==' ') c = c.substring(1,c.length);		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);	}	return "";}function eraseCookie(name) {	if(name==null) return;	name = name.replace(/ /g,'');  //remove spaces	createCookie(name,"",-1);}// Another set for cookie values with domain. domain shoud be "med.unsw.edu.au" function setCookie (name,value,expires,path,domain,secure) {document.cookie = name + "=" + value +((expires) ? "; expires=" + expires.toGMTString() : "") +((path) ? "; path=" + path : "") +((domain) ? "; domain=" + domain : "") +((secure) ? "; secure" : "");}// this deletes the cookie when calledfunction deleteCookie( name, path, domain ) {if ( readCookie( name ) ) document.cookie = name + "=" +( ( path ) ? ";path=" + path : "") +( ( domain ) ? ";domain=" + domain : "" ) +";expires=Thu, 01-Jan-1970 00:00:01 GMT";}////////////////////////////////////////////////////////////////////////////////function getFrameSrc(fName){	var frames=top.document.getElementsByTagName("FRAME");	var frame=null;	for(var i=0; i < frames.length; i++){		if(frames[i].name == fName) {			frame = frames[i];			return frame.src;		}	}	return null;}function trim(array){ //trims an array	var returnArray = new Array();	for(x=0;x<array.length;x++){		if(typeof array[x] =="string"){			 if(trimStr(array[x]) != "") returnArray.splice(x,1,array[x])		}else{			returnArray.splice(x,1,array[x])		}	}	return returnArray;}function trimStr(a){ //trims a string	if(!isString(a)) return "";	return a.replace(/^\s+|\s+$/g, '') ;}function toArray(a, delimiter) { //makes a string an array	var retArr = a.split(delimiter)	return trim(retArr);}function arrayToString(a, delimiter){ //makes an array a string	if(a.length>1){		return a.join(delimiter);	}else{		return a[0];	}}function unique(a) { //makes an array unique	tmp = new Array(0);	for(i=0;i<a.length;i++){		if(!contains(tmp, a[i])){			tmp.length+=1;			tmp[tmp.length-1]=a[i];		}	}	return tmp;}function contains(a, e) {	for(j=0;j<a.length;j++)if(a[j]==e)return true;	return false;}function getkey(e){ //return what key was pressed	if (window.event)	   return window.event.keyCode;	else if (e)	   return e.which;	else	   return null;}function framePrint(whichFrame){	// (C) 2004 www.CodeLifter.com	// Free for all users, but leave in this header	if(parent[whichFrame]==null){		window.print();	}else{		parent[whichFrame].focus();		parent[whichFrame].print();	}}/* the next two functions provide capability to easily parse the query stringReference: http://adamv.com/dev/javascript/querystringClient-side access to querystring name=value pairsVersion 1.2.322 Jun 2005Adam Vandenbergnew Querystring([qs]) Creates a new Querystring object, optionally passing a string qs to parse. If qs is omitted, the querystring from the current page is used. If qs is passed, it should not begin with a "?". // Parse the current page's querystringvar qs = new Querystring()// Parse a given querystringvar qs2 = new Querystring("name1=value1&name2=value2")Querystring.get(name[, default_value]) Returns the value of querystring parameter name if it exists, or default_value if it doesn't. If default_value is omitted and parameter name doesn't exist, returns null. var v1 = qs2.get("name1")var v3 = qs2.get("name3", "default value")Note: If a name appears more than once in a querystring only the last value is kept. */// START OF QUERYSTRING FUNCTIONSfunction QueryString(qs) { // optionally pass a querystring to parse	this.params = new Object();	this.get=QueryString_get;		if (qs == null)		qs=location.search.substring(1,location.search.length);	if (qs.length == 0) return;		qs = qs.replace(" & ","%20%26%20"); // deal with some titles with the ampersand// Turn <plus> back to <space>// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1	qs = qs.replace(/\+/g, ' ');	var args = qs.split('&'); // parse out name/value pairs separated via &	// split out each name=value pair	for (var i=0;i<args.length;i++) {		var value;		var pair = args[i].split('=');		var name = unescape(pair[0]);		if (pair.length == 2){			value = unescape(pair[1])		}else{			value = name		}		this.params[name] = value;	}}function QueryString_get(key, default_) {	// This line changes UNDEFINED to NULL	if (default_ == null) default_ = null;	var value=this.params[key];	if (value==null) value=default_;		return value;}// END OF QUERYSTRING FUNCTIONSfunction getId(nameAndId){	// return the id from the name and id string	return nameAndId.substring(nameAndId.indexOf("(")+1, nameAndId.indexOf(")"));}function getIdnumber(nameAndId){	// return the id from full id (prefix + id)	return nameAndId.substring(nameAndId.indexOf("(")+2, nameAndId.indexOf(")"));}function SetAllCheckBoxes(FieldName, CheckValue)//checks all the checkboxes in a field.//FieldName: name of checkbox field//CheckValue: true, false, or null (will cause checkbox to toggle){	var objCheckBoxes = document.getElementsByName(FieldName);	if(!objCheckBoxes) objCheckBoxes = document.getElementById(FieldName);	if(!objCheckBoxes) return;	var countCheckBoxes = objCheckBoxes.length;	if(!countCheckBoxes){		if(CheckValue){ 			objCheckBoxes.checked = CheckValue;		}else{ // toggle the check box			if(objCheckBoxes.checked){				objCheckBoxes.checked = false;			}else{				objCheckBoxes.checked = true;			}		}	}else{		if(!CheckValue){ // toggle the check boxes			for(var i = 0; i < countCheckBoxes; i++){				if(objCheckBoxes[i].checked){					objCheckBoxes[i].checked = false;				}else{					objCheckBoxes[i].checked = true;				}			}		}else{ // set the check value for all check boxes			for(var i = 0; i < countCheckBoxes; i++)				objCheckBoxes[i].checked = CheckValue;		}	}}function insertTextInField(fieldObj, fieldValueArray){	// insert the values of an array into the field	if(isString(fieldObj)) fieldObj = document.getElementById(fieldObj);	if (fieldObj != null){		clearField(fieldObj);		if(fieldObj.type == 'text' || fieldObj.type == 'textarea' || fieldObj.type == 'hidden'){			if(fieldObj.value==""){				fieldObj.value = unescape(fieldValueArray);			}else{				fieldObj.value = fieldObj.value + valueSeperator + unescape(fieldValueArray);			}		}else if(fieldObj.type == 'select-one'){			if(fieldValueArray.indexOf(valueSeperator) > -1 ){				writeComboOptions(fieldObj, fieldValueArray.split(valueSeperator));			}else{				var fva = new Array();				if(fieldValueArray != ""){					fva[0] = unescape(fieldValueArray);					fva[1] = "";				}				writeComboOptions(fieldObj, fva, true);			}		}else if(fieldObj.type=='checkbox'){			/*			The way checkbox works, is that a checkbox input field should be defined on the form, and this should be use a class or style to hide the element.			This field is not the element that the returned checkbox values are appended to.			A new DIV element is created and inserted before that the given checkbox field. It is named the passed field id + "_DIV".			The returned values are created as "checkbox" elements and appended to the new DIV element - this is what gets displayed.			So the values of checkboxes (within the DIV), then need to be passed to a field that can have the values stored.			The ids of each checkbox input will be the passed field id + "_CHECKBOX".			Use function getFieldValue(..) to get it's values.			*/			if(isString(fieldValueArray)){				fieldValueArray = unescape(fieldValueArray);				fieldValueArray = trim(fieldValueArray.split(valueSeperator));			}			if(isArray(fieldValueArray)){				var newDIV = document.createElement("div") // temporary div to store the checkboxes				newDIV.id = fieldObj.id + "_DIV";				fieldObj.parentNode.insertBefore(newDIV,fieldObj); // insert the div before the given field object							for(var i = 0; i < fieldValueArray.length; i++) {					//create checkbox					var chkbox = document.createElement("input"); 					chkbox.defaultChecked = false					chkbox.type = "checkbox"					chkbox.id = fieldObj.id + "_CHECKBOX"; 					chkbox.name = fieldObj.id+"_CHECKBOX";  					chkbox.value = fieldValueArray[i];					var text = document.createTextNode(fieldValueArray[i]); // add text to checkbox					newDIV.appendChild( chkbox );					newDIV.appendChild( text);					var br=document.createElement('br'); // add newline					newDIV.appendChild(br);				}			}		}else{			fieldObj.innerHTML = unescape(fieldValueArray);		}	}}function clearField(fieldObj){	// clears the contents of a field or options of a combobox	if(isString(fieldObj)) fieldObj = document.getElementById(fieldObj);	if (fieldObj != null){		if(fieldObj.type == 'text' || fieldObj.type == 'textarea' || fieldObj.type == 'hidden'){				fieldObj.value = "";		}else if(fieldObj.type == 'select-one'){			while(fieldObj.length != 0) {				fieldObj.remove(0);			}		}else if(fieldObj.type == 'checkbox'){			var divEl = document.getElementById(fieldObj.id+"_DIV");			if(divEl) divEl.parentNode.removeChild(divEl);  //remove element so it can be created - see function "InsertTextInField(..)"		}	}}function writeComboOptions(selectObject, nodes, noSelectText){ 	// write the options into a combobox 	// noSelectText is optional, if omitted then display the "- select -" as first option 	// if a "|" pipe is present in the node, it will be split into value and text 	if(isString(selectObject)) selectObject = document.getElementById(selectObject); 	if(!selectObject) return; 	if(!nodes) clearField(selectObject);	var elOptIni = document.createElement('option');	if(!noSelectText){		elOptIni.text = selectString; //default select string - defined at top		elOptIni.value = null;		try {			selectObject.add(elOptIni, null); // standards compliant; doesn't work in IE		}catch(ex) {			selectObject.add(elOptIni); // IE only		}	}  	if(!nodes) return;	for(var i = 0; i < nodes.length; i++) {		var values = nodes[i];		if(trimStr(values)!=""){			var elOptNew = document.createElement('option');			var optVal = unescape(values);			if(optVal.indexOf("|")==-1){				elOptNew.text = optVal;				elOptNew.value = optVal;				}else{ // split text and value using pipe				var valuesArray = optVal.split("|");				elOptNew.text = trimStr(valuesArray[0]);				elOptNew.value = trimStr(valuesArray[1]);			}			try {				selectObject.add(elOptNew, null); // standards compliant; doesn't work in IE			}catch(ex) {				selectObject.add(elOptNew); // IE only			}		}	}}function getFieldValue(fieldName, returnNumberChecked){	// return field value for whatever type	// Optional: returnNumberChecked - return number of checked for checkbox	var fieldObj = document.getElementById(fieldName);	if(fieldObj==null || fieldName == "") return "";	if(fieldObj.type == 'text' || fieldObj.type == 'textarea' || fieldObj.type == 'hidden'){		return fieldObj.value;	}else if(fieldObj.type == 'select-one'){		return getComboValue(fieldName)	}else if(fieldObj.type == 'radio'){		return getRadioValue(fieldName);	}else if(fieldObj.type == 'checkbox'){		return getCheckValue(fieldName, returnNumberChecked);	}}function getRadioValue(fieldName) {	// return value of radio value	var radioObj = document.getElementsByName(fieldName);	if(!radioObj) return "";	var radioLength = radioObj.length;	if(radioLength == undefined)		if(radioObj.checked)			return radioObj.value;		else			return "";	for(var i = 0; i < radioLength; i++) {		if(radioObj[i].checked) {			return radioObj[i].value;		}	}	return "";}function getComboValue(fieldName) {	// return value of combobox	var comboObj = document.getElementById(fieldName);	if(!comboObj) return "";	if(comboObj.selectedIndex == -1) return "";	var cval =comboObj.options[comboObj.selectedIndex].value;	if (cval=="null" || cval==selectString) return "";	if (cval!="") return cval;	var ctext = comboObj.options[comboObj.selectedIndex].text;	if(ctext==selectString) return ""; // don't want to return the selectString from global variable	return ctext;	}function getComboOptions(fieldName, objectTextValue){	/*returns the options of a combobox.	objectTextValue: 		"Object" returns object		"text" returns text seperated by the valueSeperator		"value" returns value seperated by the valueSeperator	*/	var comboObj = document.getElementById(fieldName);	if(!comboObj) return "";	if(comboObj.type != 'select-one') return "";	if(objectTextValue=="object") return comboObj;	var comboVals = "";	var num = comboObj.options.length;	if(num == 1) {		if(objectTextValue=="text"){			return comboObj.options[0].text;		}else{			return comboObj.options[0].value;		}	}	for (x=0; x<comboObj.options.length;x++){		var comboV = "";		if(objectTextValue=="text"){			comboV = comboObj.options[x].text;		}else{			comboV = comboObj.options[x].value;		}		if(comboV!='null') comboVals = comboVals + comboV + valueSeperator;	}	return comboVals;}function getCheckValue(fieldName, returnNumberChecked){	// return value of checkbox	// optional returnNumberChecked is boolean true to return the number of checkboxes checked.	var checkObj = document.getElementsByName(fieldName);	if(!checkObj) {		if (returnNumberChecked){			return 0;		}else{			return "";		}	}	var txt = "";	var txtNum = 0;	if (checkObj.length) {		for (i = 0; i < checkObj.length; i++) {			if (checkObj[i].checked) {				if(returnNumberChecked){					txtNum++;				}else{					txt = txt + checkObj[i].value + valueSeperator;				}			}		}	}else if (checkObj.checked) { //handle single instance		if (returnNumberChecked){			return 1;		}else{			return checkObj.checked;		}	}	if (returnNumberChecked){		return txtNum;	}else{		return txt;	}}function selectComboOption(fieldName, comboValue){	var comboObj = document.getElementById(fieldName);	for(x=0;x<comboObj.options.length;x++){		if(comboObj.options[x].value==comboValue){			comboObj.options[x].selected = true;		}	}}function homePopupWin(url) { // locate to center	var width = parseInt(screen.availWidth*60/100); // 60% of screen size	var height = parseInt(screen.availHeight*70/100); // 70% of screen size	if (width > 1000) width=1000;	var left = parseInt((screen.availWidth/2) - (width/2));	var top = parseInt((screen.availHeight/2) - (height/2)-50);	var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,scrollbars,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;	myWindow = window.open(url, "subWindow", windowFeatures);}// this function is to replace blank line with special character to display multi-line in Textarea input boxfunction addNewLine(field) {	var temp="";		var dummy=String.fromCharCode(160); // special character : ctrl+shift+space	var rtn="";	var trimStr="";	var browser=navigator.appName;	if (browser=="Microsoft Internet Explorer") { // For IE				var str=field.value.split("\r\n");		} else {		var str=field.value.split("\n");		}	for(var j=0;j<str.length;++j) { 		rtn="\n";		trimStr=str[j].replace(/ /g,"");		if (trimStr=="") {			if (str.length==j+1) rtn="";			temp=temp + dummy + rtn;		} else {			if (str.length==j+1) rtn="";			temp=temp + str[j] + rtn;						}	} 	if (temp.substring(0,2)==dummy) temp="";	field.value=temp;}