Array.prototype.hasMatch = function() {var matchFound=false;var ComparisonArray = arguments[0];for(i=0; i<this.length; i++) {if (ComparisonArray.indexOf(this[i]) > -1) {matchFound= true;break;}}return matchFound;}Array.prototype.removeValue = function() {/** FYI: arguments passed to this function are auto-cast.As a result, 0 = false = "0" */// blank temporary arrayvar k = new Array();// loops through the array being modifiedfor (i = 0; i < this.length; i++) { // assumes no match until proven guiltyvar match = false; // remove leading and trailing spaces before evaluatingvar thisValue = this[i].Trim(); // loops through arguments, allowing multiple values (of any datatype) to be passedfor (a = 0; a < arguments.length && !match; a++) {// if any of the arguments match the current value or current value is nullif (arguments[a] == thisValue || thisValue == '') {match = true;}}if (!match) {// store the value in the temporary arrayk.push(thisValue);}}// clear the entire source arraythis.splice(0,this.length);// copy temporary array into the source arrayfor (i = 0; i < k.length; i++) {this.push(k[i]);}}Array.prototype.Trim = function() {var k = new Array();for (i = 0; i < this.length; i++) {var strThisValue = this[i].Trim();if (strThisValue != '') {k.push(strThisValue);}}this.splice(0,this.length);for(i = 0; i < k.length;i++) {this.push(k[i]);}}/** * prototype for String object to remove leading newline, space, and tab characters. * * @return  trimmed string */String.prototype.TrimLeft = function() {var len = this.length;var code, start = 0;for (var i = 0; i < len; i++) {code = this.charCodeAt(i);  if ((code == 9) || (code == 10) || (code == 13) || (code == 32)) {start = i + 1; // store the next position } else {break;}}return this.substr(start);}/** * prototype for String object to remove trailing newline, space, and tab characters * * @return  trimmed string */String.prototype.TrimRight = function() {var len = this.length;var code, end = this.length - 1;for (var i = end; i >= 0; i--) {code = this.charCodeAt(i);  if ((code == 9) || (code == 10) || (code == 13) || (code == 32)) {end = i - 1; // store the previous position } else {break;}}return this.substr(0, len - (len - (end + 1)));}/** * prototype for String object to remove both leading and trailing newline, space, and tab characters * * @return  trimmed string */String.prototype.Trim = function() {return this.TrimRight().TrimLeft();}function setForm() {thisform = document.forms[document.forms.length - 1];}/** * Dummy functions to allow subforms to hold their own field validation code. */function valSub(form) {return true;}function valSubSub(form) {return true;}function valCategorization(form) {return true;}function valGenDetails(form) {return true;}function valDetails(form) {return true;}function valAttach(form) {return true;}function valHistory(form) {return true;}function valRelated(form) {return true;}/** * Common functions */ function trim(aStr) {  return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "");}function getSelectText(theOptionField) {return theOptionField.options[theOptionField.selectedIndex].text;}function getSelectValue(theOptionField) {var txt="";txt = theOptionField.options[theOptionField.selectedIndex].value;	if (txt=="") {	txt= getSelectText(theOptionField);	}return txt;}function getAllSelectValue(tmpObject) {var tmpArray = new Array();		for(i=0; i<tmpObject.length; i++) {		var val="";		val=tmpObject.options[i].value;			if (val=="") {			val=tmpObject.options[i].text			}		tmpArray[i] = val		}return tmpArray.join(';')}function isSelected(select, isMulti) {  // select is the select field  // isMulti is multiple attribute  	var checkNum = 0;  	if (isMulti) {		checkNum = -1;  	}    	if (checkNum == select.selectedIndex) {		return false;	} else {		return true;	}  }function getCheckValues(aCheckField) {  var returnArray = new Array();  var j = 0;  if (aCheckField.length == undefined && aCheckField.checked) {    returnArray[0] = aCheckField.value;    return returnArray;  }     for (var i = 0; i < aCheckField.length; i++) {    if (aCheckField[i].checked == true) {      returnArray[j++] = aCheckField[i].value;    }  }  return returnArray;}function getRadioValue(aRadioField) {  var valueChecked = "";  for (var i = 0; i < aRadioField.length; i++) {    if (aRadioField[i].checked == true) {      valueChecked = aRadioField[i].value;      break;    }  }  return valueChecked;}/** * Beginning Content Manager functions specific to Documents */function duplicateFileExists (p_strFileName) {	var AJAXRequest;	var strRequestServer = $('Server_Name').value	var strRequestArguments = "&FileName=" + p_strFileName + "&DID=" + $("DID").value;	var strRequestURL = "http://" + strRequestServer + "/" + g_dbFilePath + "/DoesDuplicateFileExist?OpenAgent" + strRequestArguments;		if (window.XMLHttpRequest) {		AJAXRequest = new XMLHTTPRequest();	} else if (window.ActiveXObject) {		AJAXRequest = new ActiveXObject("Microsoft.XMLHTTP");	}	AJAXRequest.open("GET", strRequestURL, false);	AJAXRequest.send();	if (AJAXRequest.readyState == 4) { // Only process once response is loaded completely		if (AJAXRequest.status == 200) { // Only process if no errors are encountered			if (eval(AJAXRequest.responseText)) {				return true;			} else {				return false;			}		} else {			window.status = "Error retrieving database information: " + AJAXRequest.statusText;		}	}	}function ConfirmDelete (title,url) {    if (confirm("Are you sure you want to delete '" + title.replace("&apos;", "\'") + "'?")) {       for (var i = 0; i < document.links.length; i++) {  		lin = document.links[i]		lin.href ="#"		lin.style.color='#cccccc'  	 }	 window.location.href = url;    }}function SetEditMode(id,args) {  window.location="/" + g_dbFilePath + "/0/" + id + "?editdocument" + args;}function HistoryMode(Id) {	var strURL=document.location.href	strURL=strURL.replace('&hist=app', '');	strURL=strURL.replace('&hist=push', '');		strURL=strURL.replace('&hist=rev', '');			if (Id=="app") {		strURL=strURL+'&hist=app';	} else if (Id == "push") {		strURL=strURL+'&hist=push';	} else {		strURL=strURL+'&hist=rev';	}	window.location.replace(strURL)}function exp(strExp, hist) {	var strURL=""	strLocation=window.location.href	n=strLocation.indexOf('!')	if(n==-1) {		n=strLocation.indexOf('?')	}	if(n==-1) {	newLocation=window.location.href	}else{	newLocation=strLocation.substring(0,n)	}	if(strExp == "more") {		strURL=newLocation+('?open&count=9999');	} else {		strURL=newLocation+('?open')	}	if (hist=="app") {	strURL=strURL+('&hist=app')	}	window.location.replace(strURL)}function setlinks(p, v, n) {      //This function takes a url paramater named p and appends the pair p=v to the end of a url string    //Also takes into account internal page links, preserves them, and moves to end of new url string    var alerted = false;    var lp = p.toLowerCase();    for (var i = n; i < document.links.length; i++) {        var strHost = location.hostname;        var strQuestion = '';        if (document.links[i].protocol == 'http:' && (document.links[i].hostname == strHost)) {            //Use the search property of the link object to append the view parameter            if (document.links[i].search.indexOf('?') == -1 && document.links[i].href.indexOf('!') == -1) {                strQuestion = '?Open';            }            if (document.links[i].href.toLowerCase().indexOf('&'+lp+'=') < 0) {                if (document.links[i].href.indexOf('#') > -1) {                    //The link has an internal reference, preserve it and put on end of url                    document.links[i].href = document.links[i].href  + strQuestion + '&'+lp+'=' + v + document.links[i].href.substr(document.links[i].href.indexOf('#')+1);                } else {				 document.links[i].href = document.links[i].href + strQuestion+ '&'+lp+'=' + v;                }            }        }    }}function loadinparent(url){self.opener.top.location = url;self.close();} function fixAlt() {var t='';var t1='';var t2 = '';var jspos = 0;var csnbr = '';var sep1 = ",";var sep2 = "~";x=window.document.images.length for (i=0; i<x; i++) { var altText = window.document.images[i].alt; //   if (window.document.images[i].alt.indexOf('Show details for [') == 0) {   if (altText.indexOf('Show details for [') == 0) {   t1 = altText.substr(0,altText.indexOf('</span>'));    t2 = altText.substr(0,altText.indexOf('>'));    t = 'Show details for ' + altText.substr(t2.length +1,t1.length-t2.length-1);   window.document.images[i].alt = t;   }   if (altText.indexOf('Hide details for [') == 0) {   t1 = altText.substr(0,altText.indexOf('</span>'));    t2 = altText.substr(0,altText.indexOf('>'));    t = 'Hide details for ' + altText.substr(t2.length +1,t1.length-t2.length-1);   window.document.images[i].alt = t;   }// check for next category alt text - - uses script tags if (altText.indexOf('Show details for') == 0) {   jsEndPos = altText.indexOf('</script>');   if (jsEndPos > 0) {      t1 = altText.substr(0,jsEndPos-3);    t2 = t1.charAt(t1.length-2);    if (t2 == "-") {   csnbr = t2 + t1.charAt(t1.length-1);    }   else {  csnbr = t1.charAt(t1.length-1);    } var jStat = getStatus(g_jsStatuses, sep1, sep2, csnbr)      t = 'Show details for ' + jStat;     window.document.images[i].alt = t;        }  } if (altText.indexOf('Hide details for') == 0) {   jsEndPos = altText.indexOf('</script>');   if (jsEndPos > 0) {      t1 = altText.substr(0,jsEndPos-3);    t2 = t1.charAt(t1.length-2);    if (t2 == "-") {   csnbr = t2 + t1.charAt(t1.length-1);    }   else {  csnbr = t1.charAt(t1.length-1);    } var jStat = getStatus(g_jsStatuses, sep1, sep2, csnbr.toString())      t = 'Hide details for ' + jStat;     window.document.images[i].alt = t;        }  } }}function getStatus(item, delimiter1, delimiter2, statKey){  tempArray=new Array(1);  var Count=0;  var found = false;  var tempString=new String(item);  var theStatus = "";      while (tempString.indexOf(delimiter1)>0) {    tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter1));    if (tempArray[Count].indexOf(statKey)>=0 ) {    //alert('stakey1= ' +statKey);     theStatus = tempArray[Count].substr(tempArray[Count].indexOf(delimiter2) + 1);        }       tempString=tempString.substr(tempString.indexOf(delimiter1)+1,tempString.length-tempString.indexOf(delimiter1)+1);     Count++  ;}// get the last value  tempArray[Count]=tempString;      if (tempArray[Count].indexOf(statKey)>=0 ) {    //alert('stakey2= ' +statKey);     theStatus = tempArray[Count].substr(tempArray[Count].indexOf(delimiter2) + 1); }  return theStatus}function detach(att) {	if (att.checked==true) {		if (!confirm("Delete " + att.value + "?")) {			att.checked = false;		} 	if($F('docType').toLowerCase() != "document") {		$('detAtt').value='true';		$('RequiredUploadAsterisk').style.display="block";	}		}		if (att.checked==false) {		if (!confirm("Keep " + att.value + "?")) {			att.checked = true;		}		if($F('docType').toLowerCase() != "document") {		$('RequiredUploadAsterisk').style.display="none";		$('detAtt').value='false';		}	}}function checkBack() {	if ($("CloseByButton")) {		if($("CloseByButton").value=="0") {			var strSaveButtonLabel = document.getElementById("savebutton").value;			var strCancelButtonLabel = document.getElementById("cancelbutton").value;			event.returnValue = "WARNING: You are trying to leave this page without using " + strCancelButtonLabel + " or " + strSaveButtonLabel  + ", which will lose any changes you have made. It will also lock this document and prevent others from accessing it. To avoid locking documents in the future, always use the " + strSaveButtonLabel + " or " + strCancelButtonLabel + " buttons to close a document you are editing."		}	}}function setCloseByButton (newValue) {$("CloseByButton").value = newValue;}function InteractiveFormValidate(form) {resetErrorValue(errorlist);resetErrorHighlights(form);window.status='validating file submission';var elements = form.elements;for (var i = 0; i < elements.length; i++) {var val="";var req = elements.item(i).getAttribute('errText');if(req) {if (req!="") {window.status='Required field identified';var label=elements.item(i).getAttribute('label');var type=elements.item(i).type;window.status='Required field - '+label;if (type=="text") {val=elements.item(i).value;var cn=elements.item(i).getAttribute('ClassName');window.status='Required field - '+cn;if (cn=="acinput") {if (val.length!=3){val="validated";insertErrorValue(label, "Area Code must have 3 digits");setFieldErrorHighlight(elements.item(i), type);} else if (isNaN(val)){val="validated";insertErrorValue(label, "Area Code must contain only digits");setFieldErrorHighlight(elements.item(i), type);}}if (cn=="pninput") {window.status='Required field - '+val;val=val.replace("-", "");if (val.length!=7){val="validated";insertErrorValue(label, "Phone Number must have 7 digits");setFieldErrorHighlight(elements.item(i), type);} else if (isNaN(val)){val="validated";insertErrorValue(label, "Phone Number must contain only digits");setFieldErrorHighlight(elements.item(i), type);}}}if (type=="radio") {val=getRadioValue(elements.item(i));}if (type=="select"){val=getSelectText(elements.item(i));}if (type=="textarea"){val=elements.item(i).value;}if (val=="") {insertErrorValue(label, req)setFieldErrorHighlight(elements.item(i), type)}}}}window.status='validations complete, display errors or submit'if (errorlist == "") {window.status='No errors'showErrorBlock(false, errorlist, form);window.status='submitting file'form.submit();} else {window.status='display all errors'showErrorBlock(true, errorlist, form);}}function checkTAOName(eVal) {	if (eVal.indexOf(".") < 0 || eVal.indexOf(".") == eVal.length-1) {		return false;	} else {		return true;	}		}function checkIDName(eVal) {	if (eVal.length<4) {		return	false;	} else {		return true;	}		}function strTrim(eVal) {//This function trims spaces before and after a stringfirstChar=eVal.substring(0,1)		while (firstChar==" ") {			eVal=eVal.substring(1,eVal.length)			firstChar=eVal.substring(0,1)		}			lastChar=eVal.substring(eVal.length-1, 1)		while (lastChar==" ") {			eVal=eVal.substring(eVal.length,eVal.length-1)			lastChar=eVal.substring(eVal.length-1,1)		}return eVal;	}function echeck(str) {var strListLength = str.length;var strArray = str.split(",");	if (listFlag == false) {		n = 0		listFlag = true		}		for (i = 0 ; i < strArray.length ; i++) {		if (!checkTAOName(strArray[i])) {		return false;		}			}	}function openNewPage(pageName) {   	var curURL = window.location.href		var dbIndex = curURL.indexOf(".nsf");	var newURL = curURL.substr(0,dbIndex+4);	newURL += pageName;	window.open(newURL,"window1","width=691,height=600,resizable=1,toolbar=1,scrollbars=1,location=1,status=1")}function calcUnlocks(form,us) {/*Confirms from end user that all selected document(s) from the document locked view are to be unlocked*/	var fname = "";	var fVal = "";	var unlArray = new Array();	var x=0;	for (i=0 ; i<form.elements.length ; i++) {		if (form.elements[i].type == "checkbox" && form.elements[i].name.substr(0,3)=='unl' && form.elements[i].checked) {			unlArray[x] = form.elements[i].value;			x++ 		}		}		if (unlArray.length==1) {		if (confirm("Are you sure you want to unlock this entry?")) {			window.location = us + unlArray.join(',');		} 		} else if (unlArray.length > 1) {		if (confirm("Are you sure you want to unlock these " + unlArray.length + " entries?")) {			window.location = us + unlArray.join(',');		}	} else {		alert('No entries selected.');	}}function hideAlt() {/*Hides from end user any alternate tags for images*/	for (i = 0; i < document.images.length; i++) {		imagename = document.images(i).alt;		if (imagename != "") {			document.images(i).alt = "";   		}	}}function writeInCombo (p_cmbTarget, p_varData, isMulti) {	var strItemValue = "";	p_cmbTarget.options.length = 0; // Clear existing entries	p_cmbTarget.options.length += 1;	if(isMulti) {	p_cmbTarget.options[0].text = "--Select All that Apply--";	} else{	p_cmbTarget.options[0].text = "--Please Choose One--";	}	for (var intItemCount = 0; intItemCount < p_varData.length; intItemCount++) {		p_cmbTarget.options.length += 1;		strItemValue = p_varData[intItemCount];		if (strItemValue != undefined && strItemValue != null) {				n=strItemValue.indexOf('|');						if(n==-1) {						strText=trim(strItemValue);						strValue=trim(strItemValue);						} else {						strValue=trim(strItemValue.substring(n+1,strItemValue.length));						strText=trim(strItemValue.substring(0,n));						}			p_cmbTarget.options[p_cmbTarget.options.length - 1].value = trim(strValue);			p_cmbTarget.options[p_cmbTarget.options.length - 1].text = trim(strText);		}	}	p_cmbTarget.selectedIndex = 0;}function DbLookup(p_strPath, p_strView, p_strKey, p_intColumn) {	var pos = 0;	var currURL = (document.location.href).toLowerCase();	pos = currURL.indexOf('://') + 3;	pos = currURL.indexOf('/', pos);	var strServer = currURL.substring(0, pos);	var strXMLPath = trim(strServer) + "/" + trim(p_strPath) + "/" + p_strView + "?ReadViewEntries&RestrictToCategory=" + p_strKey+'&count=1000';	if (window.XMLHttpRequest) {		AJAXRequest = new XMLHTTPRequest();		AJAXRequest.overrideMimeType('text/xml');	} else if (window.ActiveXObject) {		AJAXRequest = new ActiveXObject("Microsoft.XMLHTTP");	}	AJAXRequest.open("GET", strXMLPath, false);	AJAXRequest.send();	if (AJAXRequest.status == 200) { // Only process if no errors are encountered		return lookupResults(AJAXRequest.responseXML.documentElement);	} else {		window.status = "Error retrieving database information:" + AJAXRequest.statusText;	}}function processReqChange() {	if (AJAXRequest.readyState == 4) { // Only process once XML is loaded completely		if (AJAXRequest.status == 200) { // Only process if no errors are encountered			populateLookupResults(AJAXRequest.responseXML.documentElement);		} else {			window.status = "Error retrieving database information:" + AJAXRequest.statusText;		}	}}function lookupResults(p_strResponseXML) {	var NodeList = p_strResponseXML.getElementsByTagName("viewentry");	var strResult = "";	var strDelimiter = ""; // Left blank on first for iteration to avoid a null entry at split		for (var intNodeCount = 0; intNodeCount < NodeList.length; intNodeCount++) {		strResult += strDelimiter + NodeList[intNodeCount].getElementsByTagName("text")[0].childNodes[0].nodeValue;		strDelimiter = "#";	}	var varResultArray = strResult.split("#");	return varResultArray;}// this function is needed to work around a bug in IE related to element attributesfunction hasClass(obj) {    var result = false;    if (obj.getAttributeNode("class") != null) {        result = obj.getAttributeNode("class").value;    }    return result;}function stripe(id) {    // the flag we'll use to keep track of whether the current row is odd or even    var even = false;    // if arguments are provided to specify the colours of the even & odd rows, then use the them;    // otherwise use the following defaults:    var evenColor = arguments[1] ? arguments[1] : "#fff";    var oddColor = arguments[2] ? arguments[2] : "#eee";    // obtain a reference to the desired table if no such table exists, abort    var table = $(id);    if (! table) { return; }    // by definition, tables can have more than one tbody element, so we'll have to get the list of child    // <tbody>s     var tbodies = table.getElementsByTagName("tbody");    // and iterate through them...    for (var h = 0; h < tbodies.length; h++) {        // find all the &lt;tr&gt; elements...         var trs = tbodies[h].getElementsByTagName("tr");             // ... and iterate through them        for (var i = 0; i < trs.length; i++) {            // avoid rows that have a class attribute            // or backgroundColor style            if (! hasClass(trs[i]) && !trs[i].style.backgroundColor) {                // get all the cells in this row...                var tds = trs[i].getElementsByTagName("td");                // and iterate through them...                for (var j = 0; j < tds.length; j++) {                    var mytd = tds[j];                    // avoid cells that have a class attribute or backgroundColor style                    if (! hasClass(mytd) && ! mytd.style.backgroundColor) {                        mytd.style.backgroundColor = even ? evenColor : oddColor;                    }                }            }            // flip from odd to even, or vice-versa            even =  ! even;        }    }}function setViewLinks() {  var viewType = thisform.ViewType.value;    for (var i = 0; i < document.links.length; i++) {    // check for the view navigation    if ((document.links[i].search.indexOf('Expand') != -1) || (document.links[i].search.indexOf('Collapse') != -1)) {      document.links[i].search = document.links[i].search + '&view=' + viewType;    }  }}//******************* from buttons subform ********************function SendReview(sDocId, sType, sStat) {  var strQuery = '/ApprovalHistory?OpenForm&did=' + sDocId + '&ds=' + sStat+ '&sf=' + sType;  var sFeatures='width=675, height=600, status=0, help=0, toolbar=0, menubar=0, location=0, resizable=0, scrollbars=1'  newWin = window.open('/' + g_dbFilePath + strQuery, 'ApprovalHistory', sFeatures);  newWin.focus();}function WorkingEditMode(unid) {window.location='/' + g_dbFilePath+'/0/'+unid+'?EditDocument';}//******************* end from buttons subform ********************//******************* begin from Document form *******************function addToList(listField, newText, newValue) {   if ( ( newValue == "" ) || ( newText == "" ) ) {      alert("You cannot add blank values!");   } else {  	dup=false; 	i=0;      while (listField.options[i] != null && dup==false) {				if (listField.options[i].text == newText){				dup=true;				} 	i=i+1	}		if(dup==false) {		var len = listField.length ++		listField.options[len].value = newValue;	     listField.options[len].text = newText;	     listField.selectedIndex = len; // Highlight the one just entered (shows the user that it was entered)		}   } // Ends the check to see if the value entered on the form is empty}function addVal(from, to, otherFrom) {var f = document.forms[0]var from=$(from)var to=$(to)  if (from.options.selectedIndex > 0) {  dup=false  counter=0  n = from.length	while (counter < n ) {		if (from.options[counter].selected) {		dup=false;		i=0		tmpText=from.options[counter].text		if (tmpText=='Other') {					if($F(otherFrom)=="") {					dup=true;					alert('Please enter a value in the "Other" field.')					$(otherFrom).focus();				} else {					tmpText=$F(otherFrom)					tmpValue=$F(otherFrom)				}			$(otherFrom).value=""		} else{			tmpValue=from.options[counter].value		}					while (to.options[i] != null && dup==false) {				if (to.options[i].text == tmpText){				dup=true;				alert(tmpText+' has already been added.')				}						i=i+1			}			if (dup==false) {			to.options[i]=new Option(tmpText, tmpValue)			n = from.length		}	}	counter =  counter +1	}	from.options.selectedIndex=0  } else {  alert("You must select a value to add")   } }function rem(qry) {var f = document.forms[0]var from = $(qry)	if (from.options.selectedIndex >= 0) {	 counter =  0	 found = false	 n = from.length		 while (counter < n) {			  if (found) {			   counter =  0 }   if (from.options[counter].selected) {	  tmpFN= from.options[counter].value.substring(0,2)	from.options[counter] = null    	found = true    	n = from.length 	}   else{    counter =  counter +1    found=false } }     	} else {   alert("You must select a value to remove") }   }function doLookup(vLookup, vField, vCol, vReturn, depField, delim, isMulti, partial) {key=vField+delim+depField;page='doLookup'if (partial=='partial') {page='partialLookup'}new Ajax.Request('/'+$F('hiddenDBPath')+'/'+page+'?openpage&view='+vLookup+'&key=' + key + '&columns='+vCol, { onComplete: function (thisText) {  var queryResult = eval(thisText.responseText);  tmpvals = queryResult.columns[0].columnValues;	var  vals=new Array();		i=0		do {			o=tmpvals[i].indexOf("|")			n=tmpvals[i].indexOf("~");			 if (o > 0){			 	tmpv=tmpvals[i].substring(o+1,tmpvals[i].length);				tmpt=tmpvals[i].substring(0,o);			} else {				 if (n > 0){				tmpt=tmpvals[i].substring(n+1,tmpvals[i].length);				tmpv=tmpvals[i].substring(0,n);				} else {				tmpt=tmpvals[i];				tmpv=tmpvals[i];				}			}		if(tmpv != '') {			vals[i]=tmpt+'|'+depField+delim+tmpv		}	i++	}	while(i<tmpvals.length)	if (vals=='') {		vals=tmpvals.without(tmpvals.last())	}		if(isMulti==true) {	writeInCombo($(vReturn), vals, false)	} else {	$(vReturn).value=vals	}}});}function removeHierarchy(catType) {if (catType=="LS") {	var itmHierarchy = thisform.SortLSHierarchy;	var itmSortHierarchies = thisform.SortLSHierarchies;	} else {	var itmHierarchy = thisform.SortHierarchy;	var itmSortHierarchies = thisform.SortHierarchies;	}	var HierarchyOption = itmHierarchy.options[itmHierarchy.selectedIndex];	var strHierarchyChoice = HierarchyOption.text;	var strBeforeValue = itmSortHierarchies.value;		if (itmHierarchy.options.length == 1) {		HierarchyOption.text = '';	} else {		itmHierarchy.removeChild(HierarchyOption);	}	var strAfterValue = strBeforeValue.replace(strHierarchyChoice, '')	itmSortHierarchies.value = strAfterValue;	thisform.RemoveHierarchyButton.disabled = true;}function addHierarchy(catType) {if (catType=="LS") {	var intCategoryCount = parseInt(thisform.LSCategoryCount.value);	var itmSortHierarchies = thisform.SortLSHierarchies;	catType="LSCat"} else {	var intCategoryCount = parseInt(thisform.CategoryCount.value);	var itmSortHierarchies = thisform.SortHierarchies;	catType="Category"}	var strHierarchyText = '';	var strCategoryText = '';	var itmCategory = null;	var nextCategory = null;	resetErrorHighlights(thisform);		for (x = 1; x <= intCategoryCount; x++) {		itmCategory = $(catType + x );		nextCategory =$(catType+ (x+1));		strCategoryText = getSelectValue(itmCategory);		if($F('docType').toLowerCase()=="document" && catType=="Category") {		if (nextCategory) {			if (nextCategory.length > 2 && nextCategory.selectedIndex == 0) {				strHierarchyText=''				alert('You must select the next Category')				setFieldErrorHighlight(nextCategory, 'select')				break;			}  		} 				}				if(catType=="LSCat" && x<2) {		if (nextCategory) {			if (nextCategory.length > 2 && nextCategory.selectedIndex == 0) {				strHierarchyText=''				alert('You must select the next Category')				setFieldErrorHighlight(nextCategory, 'select')				break;			}  		} 				}				if (itmCategory.selectedIndex > 0 && strCategoryText != '') {			if (x > 1) {				strHierarchyText += '~';			}		strHierarchyText += strCategoryText;		}			}	if (strHierarchyText != '') {	if (catType=="LSCat") {		var itmHierarchy = thisform.SortLSHierarchy;	} else {		var itmHierarchy = thisform.SortHierarchy;		}			var intOptionCount = itmHierarchy.options.length;		if (itmHierarchy.options[0].text == '') {			intOptionCount = 0; // initially the field will have a single null value; this overwrites it		}		itmHierarchy.options[intOptionCount] = new Option(strHierarchyText);		if (itmSortHierarchies.value != '') {			itmSortHierarchies.value += ', ';		}		itmSortHierarchies.value += strHierarchyText;	}}function setDependentCategoryOptions(p_strParentID, p_strChildID, p_intCategoryCount, p_strView) {	var p_intParentID = p_strParentID.charAt(p_strParentID.length-1)*1;	var p_intChildID = p_strChildID.charAt(p_strChildID.length-1)*1;	var strParentName=p_strParentID.substring(0, p_strParentID.length-1);	var boolHasChildCategory = true;	var strChildCategoryID = null;	var itmChildCategory = null;	if(p_intCategoryCount==null) {		var intCategoryCount = $F('CategoryCount'); //Set the default category count	} else {		var intCategoryCount = p_intCategoryCount;	}		if(p_strView==null) {		var strLookupView = $F('KeywordViewName'); //Set the default lookup view	} else {		var strLookupView = p_strView;	}			if (intCategoryCount <= p_intParentID) {		boolHasChildCategory = false; // no more categories to return	}		var strParentCategoryID = p_strParentID;	var itmParentCategory = $(strParentCategoryID);	var strCategoryValue = $F('Category'+p_intChildID+'Label')+'~'+getSelectValue(itmParentCategory);	if (strCategoryValue == "--Please Choose One--" || strCategoryValue == "") {		for (x = p_intParentID; x <= intCategoryCount; x++) {				if (x > p_intParentID) {				thisform[strParentName+ x.toString()].selectedIndex = 0;				thisform[strParentName + x.toString()].disabled = true;			}		}		return;	}	if (boolHasChildCategory) {		itmChildCategory = $(p_strChildID);		itmChildCategory.disabled = false;		writeInCombo(itmChildCategory, DbLookup($F('DBPath'), strLookupView, strCategoryValue.toLowerCase(), 2));	}}function IsDocContainAttach (form) {		for (i = 0 ; i < form.elements.length ; i++) {		if (form.elements[i].name == "%%Detach") {			return true;											}	}	return false;}function removeAttach (form) {	if (IsDocContainAttach(form)) {		form.elements['%%Detach'].checked = true	}}function IsNewAttachPresent (form) {	for (i = 0 ; i < form.elements.length ; i++) {		if (form.elements[i].type == "file") {								if (form.elements[i].value != "") {				return true;			}								}	}	return false;}//*********************** end from Document form ************************//*********************** from Approval History form ************************function getUploadValues(requploads, FileID) {	var UploadControl = $(FileID);	g_strUploadField = UploadControl;	g_strUploadFileName = UploadControl.value.substr(UploadControl.value.lastIndexOf('\\') + 1);	//we're not requiring an upload, this is just to populate the variables	return true;}function openLookUp() {	$('AddButton').disabled=false;	var strQuery = '/UserIDSearch?OpenForm&namefld=editRec&idfld=NovellID';	var sFeatures = 'scrollbars=1, width=520, height=420, status=1, help=0, toolbar=0, location=0, resizable=0'; 	LDAPWin = window.open('/' + g_dbFilePath + strQuery, 'LDAP',sFeatures);	LDAPWin.focus();}function calcFields(){	calcRecipients();}function calcRecipients() {	var recArray = new Array()	for (i = 0 ; i < thisform.rec.length ; i++) {		recArray[i] = thisform.rec.options[i].value	}	thisform.strAppRecipientItem.value = recArray.join(",")		var idArray = new Array()	for (i = 0 ; i < thisform.id.length ; i++) {		idArray[i] = thisform.id.options[i].value		//idArray[i] = getAllSelectValue(thisform.id)	}	thisform.strAppIDItem.value = idArray.join(",")}function calcAttachments() {	var fname = ""	var fVal = ""	for (i=0 ; i<thisform.elements.length ; i++) {		if (thisform.elements[i].type == "file") {			fname = thisform.elements[i].name			break		}		}	fVal = thisform.elements[fname].value	thisform.attach1.value = fVal.slice(fVal.lastIndexOf('\\') +1)}function addRec(recVal, idVal) {	$('RemoveButton').disabled=false;	var recListLength = thisform.rec.options.length	var recArray = recVal.split(",");	var idArray = idVal.split(",");		var n = recListLength;					if (listFlag == false) {		n = 0		listFlag = true		}		for (i = 0 ; i < recArray.length ; i++) {		if (checkTAOName(recArray[i])) {			if (checkIDName(idArray[i])) {			TAOValue=strTrim(recArray[i])			TAOText=strTrim(recArray[i])			thisform.rec.options[n] = new Option(TAOValue, TAOText);								if (strTrim(idArray[i]).length=4) {				idVal=strTrim(idArray[i])				uid='uid='+idVal+'/ou=PGBA/o=bcbssc.com'				} else {				idVal=strTrim(idArray[i])				uid=strTrim(idArray[i])				}				thisform.id.options[n] = new Option(idVal, uid);					n = n + 1				thisform.editRec.value = "";				thisform.NovellID_cn.value="";			} else {				alert("Please enter a Novell ID")				thisform.NovellID_cn.focus()				}			} else {			alert("Please enter name in TAO format (i.e. Firstname.Lastname)")			thisform.editRec.focus()			}			}		//$('AddButton').disabled=true;}function remRec() {	var rec = thisform.rec;	var id = thisform.id;	var intSelectedIndex = rec.options.selectedIndex;		if (intSelectedIndex >= 0) {		var recOption = rec.options[intSelectedIndex];		var idOption = id.options[intSelectedIndex];		$('RemoveButton').disabled=true;		rec.removeChild(recOption);		id.removeChild(idOption);	} else {		alert("You must select an entry to remove")	}}function trim(aStr) {  return aStr.replace(/^\s{1,}/, "").replace(/\s{1,}$/, "");}//*********************** end from Approval History form ************************//*********************** from Keyword form ************************function addCategory () {y = (prompt("Please enter new category.", "Type new category here"));var currKwCats = thisform.KeywordCategory.options; var kwCatExists = false;var newKwCat = y; if (newKwCat != '' && newKwCat != 'Type new category here' && newKwCat!=null) {  if (currKwCats.length!= null) {   for ( n=0;n<currKwCats.length;n++){      if (currKwCats[n] == newKwCat) {      kwCatExists = true;      break;      }    }  }else { currKwCats.length +=1; currKwCats[currKwCats.length-1] = new Option(newKwCat, newKwCat, true, true);    }if (kwCatExists == false) {  currKwCats.length +=1;   currKwCats[currKwCats.length-1] = new Option(newKwCat, newKwCat, true, true)    }}if(y!=null){ if (y=='Type new category here' || y==''){ alert('Please enter a new category or choose one from the list'); } else { document.all['catbtn'].style.display='none'; }}}//*********************** end from Keyword form ************************//*********************** from File form ************************function checkRequiredUploads(requploads, FileID) {	var UploadControl = $(FileID);	g_strUploadField = UploadControl;	g_strUploadFileName = UploadControl.value.substr(UploadControl.value.lastIndexOf('\\') + 1);	if (g_strUploadFileName == "") {		return false;	} else {		return true;	}}function duplicateFileExists (p_strFileName) {	var AJAXRequest;	var strRequestServer = $('Server_Name').value	var strRequestArguments = "&FileName=" + p_strFileName + "&DID=" + $("DID").value;	var strRequestURL = "http://" + strRequestServer + "/" + g_dbFilePath + "/DoesDuplicateFileExist?OpenAgent" + strRequestArguments;		if (window.XMLHttpRequest) {		AJAXRequest = new XMLHTTPRequest();	} else if (window.ActiveXObject) {		AJAXRequest = new ActiveXObject("Microsoft.XMLHTTP");	}	AJAXRequest.open("GET", strRequestURL, false);	AJAXRequest.send();	if (AJAXRequest.readyState == 4) { // Only process once response is loaded completely		if (AJAXRequest.status == 200) { // Only process if no errors are encountered			if (eval(AJAXRequest.responseText)) {				return true;			} else {				return false;			}		} else {			window.status = "Error retrieving database information: " + AJAXRequest.statusText;		}	}	}//*********************** end from File form ************************//*********************** from Display form ************************function preview(sDocId) {  var strQuery = '/doc/' + sDocId + '?opendocument';  var sFeatures = 'scrollbars=1, width=800, height=600, status=1, help=0, toolbar=0, location=0, resizable=1';   newWin = window.open('/' + g_dbFilePath + strQuery, 'Preview', "");  newWin.focus();}function openNewWindow(strQuery) {  var sFeatures = 'width=400, height=300, status=1, help=0, toolbar=0, location=0, resizable=1';   newWin = window.open('/' + g_dbFilePath + '/' + strQuery, 'Preview', "");  newWin.focus();}//*********************** end from Display form ************************function InteractiveFormValidate(form) {resetErrorValue(errorlist);resetErrorHighlights(form);window.status='validating file submission';var elements = form.elements;for (var i = 0; i < elements.length; i++) {var val="";var req = elements.item(i).getAttribute('errText');if(req) {if (req!="") {window.status='Required field identified';var label=elements.item(i).getAttribute('label');var type=elements.item(i).type;window.status='Required field - '+label;if (type=="text") {val=elements.item(i).value;var cn=elements.item(i).getAttribute('ClassName');window.status='Required field - '+cn;if (cn=="acinput") {if (val.length!=3){val="validated";insertErrorValue(label, "Area Code must have 3 digits");setFieldErrorHighlight(elements.item(i), type);} else if (isNaN(val)){val="validated";insertErrorValue(label, "Area Code must contain only digits");setFieldErrorHighlight(elements.item(i), type);}}if (cn=="pninput") {window.status='Required field - '+val;val=val.replace("-", "");if (val.length!=7){val="validated";insertErrorValue(label, "Phone Number must have 7 digits");setFieldErrorHighlight(elements.item(i), type);} else if (isNaN(val)){val="validated";insertErrorValue(label, "Phone Number must contain only digits");setFieldErrorHighlight(elements.item(i), type);}}}if (type=="radio") {val=getRadioValue(elements.item(i));}if (type=="select"){val=getSelectText(elements.item(i));}if (type=="textarea"){val=elements.item(i).value;}if (val=="") {insertErrorValue(label, req)setFieldErrorHighlight(elements.item(i), type)}}}}window.status='validations complete, display errors or submit'if (errorlist == "") {window.status='No errors'showErrorBlock(false, errorlist, form);window.status='submitting file'form.submit();} else {window.status='display all errors'showErrorBlock(true, errorlist, form);}}//*********************** from Interactive subform ************************function appendInteractiveField() {var doc = document.forms[document.forms.length - 1];var RemoveFieldContainer = $('RemoveFieldLabel');var RemoveFieldHTML = RemoveFieldContainer.innerHTML;if (doc.FormFieldLabels.value == "") {RemoveFieldHTML = "";}var ctnt = $("formcontent").value;var req = '&nbsp;'var ThisOption = doc.FieldLabel.value;if (ThisOption == '' || doc.FieldName.value == '') {return alert('A field label and name must both be specified prior to adding a field.');}if (doc.FieldName.value.indexOf(' ') > 0) {doc.FieldName.value = doc.FieldName.value.replace(' ','');return alert('Field names may not contain spaces.');}if(getRadioValue(doc.FieldRequired)=="1") {if(doc.ErrorText.value=="") {return alert('Required fields must have Error Text to display.');}req="<SPAN class=IntRS>*</SPAN>"}if (ctnt.indexOf('name="' + doc.FieldName.value + '"') > -1) {return alert('Please enter a unique Field Name.');}if (ctnt.indexOf('label="' + doc.FieldLabel.value + '"') > -1) {return alert('Please enter a unique Field Label.');}var fieldList = doc.FormFieldLabels.value.split(',');var requiredFieldList = doc.RequiredFields.value.split(',');fieldList.push(ThisOption);doc.FormFieldLabels.value = fieldList.toString();if (doc.ErrorText.value != '') {requiredFieldList.push(ThisOption);doc.RequiredFields.value = requiredFieldList.toString();}			existCtnt=ctntexistCtnt = existCtnt + "<tr id=\"" + ThisOption + "\"><td class='fldlabel'>" + ThisOption+req+"</td><td class='flddata'>";var ft = doc.FieldType.options[doc.FieldType.selectedIndex].value;if (ft == "Txt") {existCtnt = existCtnt + "<input type=\"text\" name=\"" + doc.FieldName.value + "\" label=\""+ThisOption+"\" errText=\""+doc.ErrorText.value+"\"></td></tr>";} else if (ft == "TxtArea") {existCtnt = existCtnt + "<textarea name=\"" + doc.FieldName.value + "\" label=\""+ThisOption+"\" errText=\""+doc.ErrorText.value+"\"></textarea></td></tr>";} else if (ft == "D") {existCtnt = existCtnt + getInteractiveSelectValue() + "</td></tr>";} else if (ft == "R") {existCtnt = existCtnt + getInteractiveRadioValue() + "</td></tr>";} else if (ft == "P") {existCtnt = existCtnt + "(<input type=\"text\" name=\"^" + doc.FieldName.value + "AC\" maxlength=\"3\" class=\"acinput\" size=\"4\" label=\""+ThisOption+"\" errText=\""+doc.ErrorText.value+"\">) "existCtnt = existCtnt + "<input type=\"text\" name=\"^" + doc.FieldName.value + "PN\" maxlength=\"8\" class=\"pninput\" size=\"10\" label=\""+ThisOption+"\" errText=\""+doc.ErrorText.value+"\"></td></tr>";}doc.formcontent.value = existCtnt;doc.FieldLabel.value = '';doc.FieldName.value = '';doc.FieldRequired[0].checked=true;doc.ErrorText.value = '';$('errText').style.display='none';doc.FieldType.selectedIndex = 0;doc.FieldKeyword.selectedIndex = 0;RemoveFieldHTML += "<input type='radio' name='RemoveFieldChoice' value='" + ThisOption + "' onclick='processInteractiveRemoval();'>" + ThisOption + "<br/>"resetInteractiveRemoveChoice(RemoveFieldHTML);}function displayInteractiveFields() {var fieldsDiv = $("formFields");var newDiv = document.createElement("div");var fieldName = thisform.FieldLabel.value;newDiv.setAttribute("id", fieldName);var newSpan = document.createElement("span");newSpan.appendChild(document.createTextNode(fieldName));newDiv.appendChild(newSpan);fieldsDiv.appendChild(newDiv);}function getInteractiveRadioValue() {var result = ""; var fieldToUse = thisform.FieldKeyword.options[thisform.FieldKeyword.selectedIndex].text;var useVal = false;for (var val in fieldVals) {if (fieldVals[val] == fieldToUse) {useVal = true;} else if (isInteractiveFieldName(fieldVals[val])) {useVal = false;} else if (useVal) {result = result + "<input type=\"radio\" name=\"" + thisform.FieldName.value +"\" value=\"" + fieldVals[val] + "\" label=\""+thisform.FieldLabel.value+"\" errText=\""+thisform.ErrorText.value+"\">" + fieldVals[val] + "<br />";}}return result;}function getInteractiveSelectValue() {var result = "<select name=\"" + thisform.FieldName.value + "\" label=\""+thisform.FieldLabel.value+"\" errText=\""+thisform.ErrorText.value+"\">"; var fieldToUse = thisform.FieldKeyword.options[thisform.FieldKeyword.selectedIndex].text;var useVal = false;for (var val in fieldVals) {if (fieldVals[val] == fieldToUse) {useVal = true;} else if (isInteractiveFieldName(fieldVals[val])) {useVal = false;} else if (useVal) {result = result + "<option value=\"" + fieldVals[val] + "\">" + fieldVals[val] + "</option>";}}result = result + "</select>";return result;}function isInteractiveFieldName(testVal) {for (var fields in fieldNames) {if (fieldNames[fields] == testVal) {return true;}}return false;}function processInteractiveRemoval() {var boolRemovalConfirmed = confirm("Are you sure you want to remove this field?")var RemoveOptions = thisform.RemoveFieldChoice;var RemoveOption = '';var FieldHTML = '';if (RemoveOptions.length === undefined) {RemoveOption = RemoveOptions.value;} else {for (i = 0; i < RemoveOptions.length; i++) {var ThisOption = RemoveOptions[i].value;if (RemoveOptions[i].checked) {RemoveOption = ThisOption;RemoveOptions[i].checked = boolRemovalConfirmed;} else {FieldHTML += "<input type='radio' name='RemoveFieldChoice' value='" + ThisOption + "' onclick='processInteractiveRemoval();'>" + ThisOption + "<br/>"}}}if (boolRemovalConfirmed) {if (RemoveOption != '') {removeInteractiveField(RemoveOption);}resetInteractiveRemoveChoice(FieldHTML);}}function rebuildInteractiveFieldList() {if ($("formcontent")) {var ctnt = $("formcontent").value;var fieldsDiv = $("formFields");var marker = ctnt.indexOf("<tr id=");var newDiv;var fieldName;while (marker > -1) {marker = marker + 8;fieldName = ctnt.substring(marker, ctnt.indexOf("\"", marker));newDiv = document.createElement("div");newDiv.setAttribute("id", fieldName);var newSpan = document.createElement("span");newSpan.appendChild(document.createTextNode(fieldName));newDiv.appendChild(newSpan);fieldsDiv.appendChild(newDiv);marker = ctnt.indexOf("<tr id=", marker);}}}function removeInteractiveField(label) {	var ctnt = $("formcontent").value;	var startLoc = ctnt.indexOf("<tr id=\"" + label);	var endLoc = ctnt.indexOf("/tr", startLoc) + 4; 	var result = ctnt.substring(0, startLoc) + ctnt.substring(endLoc, ctnt.length);	thisform.formcontent.value = result;		var fieldValues;	var fieldList = thisform.FormFieldLabels.value;	if (fieldList.indexOf(",") > -1) {		fieldValues = fieldList.split(',');	} else {		fieldValues = new Array(fieldList);	}	fieldValues.removeValue(label);	thisform.FormFieldLabels.value = fieldValues.toString();	var requiredFieldList = thisform.RequiredFields.value;	if (requiredFieldList.indexOf(",") > -1) {		fieldValues = requiredFieldList.split(',');	} else {		fieldValues = new Array(requiredFieldList );	}	fieldValues.removeValue(label);	thisform.RequiredFields.value = fieldValues.toString();}function resetInteractiveRemoveChoice(newHTML) {var Wrapper = $('RemoveFieldOptions');var FieldContainer = $('RemoveFieldLabel');var strFieldList = thisform.FormFieldLabels.value;if (strFieldList != '') {FieldContainer.innerHTML = newHTML;Wrapper.style.display = "block";} else {Wrapper.style.display = "none";}}//*********************** end from Interactive subform ************************function removeValue(fld, savedfld) {	var itmProject = $(fld)	var itmSaved = $(savedfld);	var ProjectOption = itmProject.options[itmProject.selectedIndex];	var strProjectChoice = ProjectOption.text;	var strProjectValue = ProjectOption.value;	var strBeforeValue = itmSaved.value;	if (strProjectValue == '') {		strProjectValue = strProjectChoice;	}	if (itmProject.options.length == 1) {		ProjectOption.text = '';	} else {		itmProject.removeChild(ProjectOption);	}	var strAfterValue = strBeforeValue.replace(strProjectChoice+'|'+strProjectValue, '')	itmSaved.value=strAfterValue	}function addValue(fld, savedfld, tmpfld) {	var itmProject = $(fld);	var itmSelProject = $(tmpfld);	var itmSaved = $(savedfld);	var strSaved=itmSaved.value	var selOption = itmSelProject.options[itmSelProject.selectedIndex];	var strProjectText = selOption.text;	var strProjectValue = selOption.value;	if (strProjectValue == '') {		strProjectValue = strProjectText;	}	if (itmSelProject.selectedIndex == 0) {		alert('Please select a value to add.')	} else {		var dup='false';			var intOptionCount = itmProject.options.length;		if (intOptionCount>0) {			for  (i = 0; i < intOptionCount; i++) {				if (itmProject.options[i].text==strProjectText) {				dup='true';				alert('this value has already been added.')				break;				}			}		}					if (dup=="false") {			if (itmProject.options[0].text == '') {				intOptionCount = 0; // initially the field will have a single null value; this overwrites it			}			itmProject.options[intOptionCount] = new Option(strProjectText, strProjectValue);			strSaved += strProjectText+'|'+strProjectValue+";";			itmSaved.value = strSaved.split(";")		}	}}//@Left equivalentfunction strLeft(sourceStr, keyStr){return (sourceStr.indexOf(keyStr) == -1 | keyStr=='') ? '' : sourceStr.split(keyStr)[0];}//@Right equivalentfunction strRight(sourceStr, keyStr){idx = sourceStr.indexOf(keyStr);return (idx == -1 | keyStr=='') ? '' : sourceStr.substr(idx+ keyStr.length);}//@RightBack equivalentfunction rightBack(sourceStr, keyStr){arr = sourceStr.split(keyStr);return (sourceStr.indexOf(keyStr) == -1 | keyStr=='') ? '' : arr.pop()}//@LeftBack equivalentfunction leftBack(sourceStr, keyStr){arr = sourceStr.split(keyStr)arr.pop();return (keyStr==null | keyStr=='') ? '' : arr.join(keyStr)}//@Middle equivalentfunction middle(sourceStr, keyStrLeft, keyStrRight){ return strLeft(strRight(sourceStr,keyStrLeft), keyStrRight);}    