/* JavaScript: UI Commonfunctions:getCookie('name')checkCookie('name')setCookie('name',value, expiry in days)getServerView - not implemented yetsetServerViewResults - not implementedlogError(severityInt, string) - call logEvent + alertlogEvent(severityInt, string) - calls ajax to log event string in event log databasesay(priorityInt, string) - alert with time stamp if priority => runModedoNothing - call back for ajax that does nothing (got for POST only)$('id') - get the field value for youset$('id',value) - sets a field value for youhide(id)unHide(id)color(id, color)colorOff(id)highlight(id)hightlight(id, color)highlightOff(id)setStyle(id, style, value)trim('string') - removes spaces at the beginning and end of stringisSelected('id') - for selection dropdownsgetSelectedText('id')setSelected('id','value');appendSelectedText('id','text');getCheckededText('id')getText('id')setText('rd','text')makeArray(semicolon delimiter string)// not written yet protectunProtectisProtected*//* ********************************************************************** */// 2009-07-08 pb use this model when creating new functions in the javascript libraryfunction functionModel(thisStringPerhaps){  try  {  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *functionModel* ' + e.message);  }}//// use the above block as a function model///* ********************************************************************** */// these two functions are sort of depended on each otherfunction logError(thisSeverity, thisString){// 1 = critical, 2 = major, 3 = minor, 4 = info  try  {	// ajax call to write an error log document	/* the call goes here */	logEvent(thisSeverity, thisString)	say(priorityDebug, thisString);	window.status = thisString; // 2009-07-22 pb  }  catch(e)  {  	var msg = 'catch exception detected in *logError* ' + e.message+'\n'  	msg += 'original error message: ('+thisSeverity+') '+thisString+'\n';	alert(msg);  }}function logEvent(thisPriority, thisString){// 3 = basic// 5 = verbose// 9 = debug  try  {  	//alert(thisSeverity + ' ' + thisString);  	if (thisString == '') return false;	var url = pathDb + '/' + ajaxEventLogAgent; // define in sfrmCGIVars 	//alert(url);	var postArgs = '&priority=';		if (isNaN(thisPriority))	{ postArgs += '0'; }	else	{ postArgs += thisPriority; }		postArgs += '&session=';	postArgs += '';		postArgs += '&username=';	postArgs += userName;			postArgs += '&runmode=';	postArgs += runMode;		postArgs += '&docid=';	postArgs += docid;		postArgs += '&message=';	postArgs += escape(thisString);	postArgs += '&eventlogv2=1';	//alert(postArgs);		// this type of call sets the Ok and Failed response functions to doNothing (intentionally)		callServer('POST', url, true, 5000, doNothing, undefined, doNothing, 'application/x-www-form-urlencoded', undefined, postArgs)			return true;	  }  catch(e)  {	alert('catch exception detected in *logEvent* ' + e.message);    	// logError(intSeverity, 'catch exception detected in *logEvent* ' + e.message);  }}/* ************************************************************* */// these three functions are bound together /* ************************************************************* */// use this if you want to customize the JavaScript error logging (using the same Event Log Agent) (dynamic formatting)// this logging format is enabled if you use the following javascript command// when the page is loaded// window.onerror = trapError;  // use this to enable the onerror trapfunction logJsError(jsError){	try{	var url = pathDb + '/' + ajaxEventLogAgent; // define in sfrmCGIVars 	var postArgs = '&error=' + escape(jsError.name);	postArgs += '&message=' + escape(jsError.message);	postArgs += '&location=' + escape(jsError.location);	postArgs += '&referer=' + escape(location.href);	postArgs += '&appcodename=' + escape(navigator.AppCodeName);	postArgs += '&appname=' + escape(navigator.AppName);	postArgs += '&appversion=' + escape(navigator.AppVersion);	postArgs += '&cookieenabled=' + escape(navigator.cookieEnabled);	postArgs += '&language=' + escape(navigator.language);	postArgs += '&platform=' + escape(navigator.platform);	postArgs += '&useragent=' + escape(navigator.userAgent);//	postArgs += '&javaenabled=' + escape(navigator.javaEnabled);	postArgs += '&cookie=' + escape(document.cookie);	postArgs += '&username='+userName;		postArgs += '&eventlogv3=1';	callServer('POST', url, true, 5000, createCallFunctionWithTextHandler('errorLogged'), undefined, undefined, 'application/x-www-form-urlencoded', undefined, postArgs)		return true;	}	catch(e)	{ alert(e.message); }}function errorLogged(result){	try{		window.status = 'a javascript error has been trapped and logged';		return true;	}	catch(e)	{ alert(e.message); }	}function trapError(message, url, line){try{  var error = new Error(message);  error.location = url +', line:' + line;  logJsError(error);  }  catch(e)  { alert(e.message); }}// the above three functions are bound together /* ************************************************************* */function doNothing(){  try  {  	//alert('do nothing');  	return true;  	  }  catch(e)  {  	// severity, text	logError(severityMajor, 'catch exception detected in *doNothing* ' + e.message);    	return false;  }}function getServerView(thisViewName, thisViewResultType, thisViewTarget){  try  {	var url = '/' + $('WebDBName_').value + '/' + theViewName + '?ReadViewEntries';	callServer('GET', url, true, 5000, createCallFunctionWithTextHandler('setServerViewResults()'));  }  catch(e)  {    logError(intSeverity, 'catch exception detected in *getListOfMinistries* ' + e.message);  }}function setServerViewResults(thisResponse){  try  {	say('data returned'); // testing the response  }  catch(e)  {    logError(intSeverity, 'catch exception detected in *setListOfMinistries* ' + e.message);  }}function say(thisPriority, thisString){  try  {  	// if the runMode is higher than 'basic', then alert the message  	if (isNaN(thisPriority))   	{  		thisPriority = 9; // debug mode  	}  	if (runMode < thisPriority) return false;  		var currentTime = new Date();  	var hours = currentTime.getHours();  	var minutes = currentTime.getMinutes();  	if (minutes < 10)  	{  		minutes = "0" + minutes;  	}  	alert(hours+":"+minutes+"  -  "+thisString);  	return true;  }  catch(e)  {	// cannot call errorLog due to recussion recurssion    	alert('catch exception detected in *say* ' + e.message);    	return false;  }}function setStatus(thisString){  try  {  	window.status = thisString;  	return true;  }  catch(e)  {	logError(severityMajor, 'catch exception detected in *status* ' + e.message);    	return false;  }}function $(id){  try  {	return document.getElementById(id).value;  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *$* ' + e.message);  }}function set$(id, thisValue){  try  {	document.getElementById(id).value = thisValue;  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *set$* ' + e.message);  }}function getCookie(c_name){  try  {	if (document.cookie.length>0)  	{	  	c_start=document.cookie.indexOf(c_name + "=");  		if (c_start!=-1)    		{   	 		c_start=c_start + c_name.length+1;		    	c_end=document.cookie.indexOf(";",c_start);    			if (c_end==-1) c_end=document.cookie.length;				return unescape(document.cookie.substring(c_start,c_end));    		}  	}	return "";  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *getCookie* ' + e.message);  }}function setCookie(c_name,value,expiredays){  try	{	var exdate=new Date();	exdate.setDate(exdate.getDate()+expiredays);	document.cookie=c_name+ "=" +escape(value)+	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());	}	  catch(e)	{	    logError(severityMajor, 'catch exception detected in *setCookie* ' + e.message);	}}function checkCookie(c_name){  try	{		if (document.cookie.length>0)			{			c_val = getCookie(c_name);			if (c_val!=null && c_val!="")			{				  return true;			}			else			{		 	  	return false;			}		}		return false;	}  catch(e)  {    logError(severityMajor, 'catch exception detected in *checkCookie* ' + e.message);  }}function homePageJumpToTeleprompter(thisObject){  try  {	window.status = thisObject.value;	// set$('jumpToTeleprompter', thisObject.value)  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *homePageJumpToTeleprompter* ' + e.message);  }}function blockUnhide(id){	try	{	  setStyle(id,'display','block');		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *blockUnhide* ' + e.message + ' for Id:' + id);		}}function blockHide(id){	try	{	  setStyle(id,'display','none');		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *blockHide* ' + e.message);		}}function unHide(id){	try	{	  setStyle(id,'visibility','visible');		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *unHide* ' + e.message);		}}function hide(id){	try	{	  setStyle(id,'visibility','hidden');		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *hide* ' + e.message);		}}function moveOffScreen(id){	try	{		setStyle(id,'top','-1000');          setStyle(id,'left','-1000');	}	catch(e)	{		    logError(severityMajor, 'catch exception detected in *moveOffScreen* ' + e.message);		}}function getStyle(objId,theStyle){	return eval('document.getElementById(objId).style.'+theStyle);}function setStyle(objId, style, value) {    document.getElementById(objId).style[style] = value;}function setClassName(objId, className){	document.getElementById(objId).className = className;}function disableButton(Id){try{	getObject(Id).disabled = true;	return true;	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *disableButton* ' + e.message);	    return false;	}}function enableButton(Id){try{	getObject(Id).disabled = false;	return true;	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *enableButton* ' + e.message);	    return false;	}}function setClass(objId, className){	document.getElementById(objId).className = className;}function getClass(objId){	return document.getElementById(objId).className;}function clearClass(objId){	document.getElementById(objId).className = '';}function spanText(id, value){	try	{	    	document.getElementById(id).innerHTML = value;	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *spanText* ' + e.message);		}}function highlight(id, color){	try	{		if (color == undefined)		{ 	  setStyle(id,'backgroundColor','#FFFFDE');		  } else		{	  setStyle(id,'backgroundColor',color);		  }	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *highlight* ' + e.message);		}}function highlightOff(id){	try	{	  setStyle(id,'backgroundColor','');		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *highlightOff* ' + e.message);		}}function color(id, color){	try	{	  setStyle(id,'color', color);		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *color* ' + e.message);		}}function colorOff(id){	try	{	  setStyle(id,'color', '');		  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *colorOff* ' + e.message);		}}function protect(id){	try	{	  /* setStatus(id);		 	setStyle(id,'border-style', 'none');		  	  	 */	  setStyle(id,'borderColor', '#cccccc');		  	  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *protect* ' + e.message);		}}function unProtect(id){	try	{	  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *unProtect* ' + e.message);		}}function isProtected(id){	try	{	  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *isProtected* ' + e.message);		}}/* Function used to trim string */function trim(str){try	{//		return str.replace(/^s+/g, '').replace(/s+$/g, '');		fixedTrim = " ";		lastCh = " ";		for (x = 0; x < str.length; x++ )			{				ch = str.charAt( x );				if ( ( ch != " " ) || ( lastCh != " " ) )					{						fixedTrim += ch;					}				lastCh = ch;			}		if ( fixedTrim.charAt( fixedTrim.length - 1 ) == " " )			{				fixedTrim = fixedTrim.substring( 0, fixedTrim.length - 1 );			}		if ( fixedTrim.charAt( 0 ) == " " )			{				fixedTrim = fixedTrim.substring( 1, fixedTrim.length );			}		return ( fixedTrim );	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *trim* ' + e.message);		}} function isSelected(thisSelection){try{	if (thisSelection.constructor == String)	{		object = getObject(thisSelection);	}	else	{		object = thisSelection;	}			var size = object.length;//  var size = eval('document.forms[0].'+selectionId+'.length');  for (var i = 0; i < size; i++)  {//  if (eval('document.forms[0].'+selectionId+'[i].selected')== true)  if (object[i].selected == true)	{		//		if(eval('document.forms[0].'+selectionId+'[i].text') == '--Select--')		if(object[i].text == '--Select--')				{ return false; }						   return true;	}  }  return false;  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *isSelected* ' + e.message);		}}function getSelectedText(selectionId){try{  var size = eval('document.forms[0].'+selectionId+'.length'); for (var i = 0; i < size; i++)  {  if (eval('document.forms[0].'+selectionId+'[i].selected')== true)	{			if(eval('document.forms[0].'+selectionId+'[i].text') == '--Select--')			{ return ''; }					   return eval('document.forms[0].'+selectionId+'[i].value');		   	}  }  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *getSelectedText* ' + e.message);		}}function clearSelected(id){try{	if (id.constructor == String)	{		object = getObject(id);	}	else	{		object = id;	}		object.length = 0;	return true;	  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *clearSelection* ' + e.message);		    return false;	}}function setSelected(id, thisValue){try{		var idFound = false;				var size = eval('document.forms[0].'+id+'.length');		idFound = (size > 0) ? true : false;				for (var i = 0; i < size; i++)		{			  eval('document.forms[0].'+id+'[i].selected = false;');		}				for (var i = 0; i < size; i++)		{		if (eval('document.forms[0].'+id+'[i].text') == thisValue)  			{     			eval('document.forms[0].'+id+'[i].selected = true;');  			}		}				if (idFound) {}		else		{			alert('setSelected method failure ... your field "'+id+'" not found')			return false;		}		return true;  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *setSelection* ' + e.message);		    return false;	}}function appendSelectedText(id,thisText){try{		if (id.constructor == String)		{				object = getObject(id);		}		else		{				object = id;		}			var optn = document.createElement("OPTION");		optn.text = thisText;		optn.value = '';		object.options.add(optn);	  	}	catch(e)	{	    logError(severityMajor, 'catch exception detected in *appendSelectedText* ' + e.message);		}}function getText(id){  try  { 	if (id.constructor == String)	{		object = getObject(id);	}	else	{		object = id;	} 			return object.value;	    }  catch (e)  {	    logError(severityMajor, 'catch exception detected in *getText* for "' + id +'", ' + e.message);		    return '';  }}	function setText(fieldId, txt){  try  {  document.getElementById(fieldId).value = txt;    }  catch (e)  {	    logError(severityMajor, 'catch exception detected in *setText* ' + e.message + ' fieldId:'+fieldId);	    return false;  }}function clearText(id){try{ document.getElementById(id).value = ''; 	    }  catch (e)  {	    logError(severityMajor, 'catch exception detected in *clearText* ' + e.message);		    return '';  }}function getId(object){  try  {		return object.name;  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *getId* ' + e.message);  }}function getObject(objectId){  try  {		return document.getElementById(objectId);  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *getObject* ' + e.message);  }}function getHtml(id){  try  {	var fromObj =  document.getElementById(id)    	if (fromObj.nodeName == 'TEXTAREA')  	{  		stream = fromObj.value;  	  	}  	else  	{  		stream = fromObj.innerHTML;  	}	return stream	    }  catch (e)  {	    logError(severityMajor, 'catch exception detected in *getHtml* ' + e.message);		    return '';  }}	function setHtml(fieldId, txt){  try  {	  var toObj = document.getElementById(fieldId);	  if (toObj.nodeName == 'TEXTAREA')	  {		toObj.value = txt;	  }	  else	  {	  	toObj.innerHTML = txt;	  }    }  catch (e)  {	    logError(severityMajor, 'catch exception detected in *setHtml* ' + e.message);	    return false;  }}function clearHtml(id){try{ document.getElementById(id).innerHTML = ''; } catch(e) {    logError(severityMajor, 'catch exception detected in *clearHtml* ' + e.message);	    return false; }}function copyHtml(toId, fromId){  try  {  	var fromObj = document.getElementById(fromId)  	var toObj = document.getElementById(toId)  	var stream;  		if (fromObj.nodeName == 'TEXTAREA')  	{  		stream = fromObj.value;  	  	}  	else  	{  		stream = fromObj.innerHTML;  	}  	  	if (toObj.nodeName == 'TEXTAREA')  	{  		toObj.value = stream;	  	}  	else  	{  		toObj.innerHTML = stream;  	}  	return;  	  	var fromString = escape(fromObj.innerHTML);  	var toObj = document.getElementById(toId)  	// alert(toObj.nodeType);  	toObj.value = fromString;    }  catch (e)  {	    logError(severityMajor, 'catch exception detected in *copyHtml* ' + e.message);	    return false;  }}function isChecked(id){  try  {  var selectionString = '';  var selectionIndex = -1;  	obj = document.forms[0];	hit = 0; 	for (var i=0; i<obj.length; i++)	{		var objType = obj.elements[i].type;		if (objType == 'checkbox' || objType == 'radio')			{			if (obj.elements[i].name == id)				{          					if (obj.elements[i].checked)					{						return true;					}				}			}	}	return false;	  }  catch (errorcondition)  {    alert(errorcondition.message);    return false;  }} function getCheckedText(id){  try  {  var selectionString = '';  var selectionIndex = -1;  	obj = document.forms[0];	hit = 0; 	for (var i=0; i<obj.length; i++)	{		var objType = obj.elements[i].type;		if (objType == 'checkbox' || objType == 'radio')			{			if (obj.elements[i].name == id)				{					if (obj.elements[i].checked)					{			            	selectionIndex++;            				selectionString += obj.elements[i].value;					}				}			}	}	return selectionString;	  }  catch (errorcondition)  {    alert(errorcondition.message);    return false;  }} function setChecked(haystack, needle){var size = eval('document.forms[0].'+haystack+'.length');for (var i = 0; i < size; i++){  eval('document.forms[0].'+haystack+'[i].checked = false;');}for (var i = 0; i < size; i++){  if (eval('document.forms[0].'+haystack+'[i].value')== needle)  {     eval('document.forms[0].'+haystack+'[i].checked = true;');  }}}function clearChecked(id){try	{	if (id.constructor == String)	{ }	else	{		alert('clearChecked method failure ... your field "'+id+'" must be a string name')		return false;	}	     var object = document.forms[0];     var objType;         	for (var i=0; i<object.length; i++)		{		objType = object.elements[i].type;		if (objType == 'checkbox')			{			if (object.elements[i].name == id)				{					object.elements[i].checked = false; 				}			}		}				return true;	}	catch(errorCondition)	{	     logError(severityMajor, 'catch exception detected in *clearChecked* ' + e.message);  		return false;	}}function clearRadio(id){try	{	if (id.constructor == String)	{ }	else	{		alert('clearChecked method failure ... your field "'+id+'" must be a string name')		return false;	}	     var object = document.forms[0];     var objType;     var msg='';              	for (var i=0; i<object.length; i++)		{		msg += object.elements[i].name + ' : ' + object.elements[i].type + '\n';		objType = object.elements[i].type;		if (objType == 'radio')			{			if (object.elements[i].name == id)				{					object.elements[i].checked = false; 				}			}		}		return true;	}	catch(errorCondition)	{	     logError(severityMajor, 'catch exception detected in *clearRadio* ' + e.message);  		return false;	}}function setFocus(field){try{	if(field.constructor == String)	{		getObject(field).focus();	}	else	{		field.focus();	}  }  catch(e)	{	     alert(severityMajor + 'catch exception detected in *setFocus* ' + e.message);	}	}function parseValue(haystack, needle){	if (haystack == '' || needle == '') {return false;}	var lStart = haystack.indexOf(needle);	if (lStart < 0 || lStart > haystack.length) {return false;}	var returnValue = haystack.substr(lStart+needle.length+1);	if (returnValue.indexOf('&') > 0)	{		returnValue = returnValue.substr(0,returnValue.indexOf('&'))	}	return returnValue;}var iOffset = 0;var dragapproved=false;var z,x,y;document.onmousedown=drags;document.onmouseup=new Function("dragapproved=false");var xx = 0;var yy = 0;var globalObjectId = '';var transitionOpacityCtr = 0;function move()  {    if (event.button==1&&dragapproved)        {            z.style.pixelLeft=temp1+event.clientX-x;            z.style.pixelTop=temp2+event.clientY-y;            return false ;        }   }function drags()  {    if (!document.all) return;    if (event.srcElement.className=="drag" || event.srcElement.className=="dragpassive")        {            dragapproved=true;            z=event.srcElement;            temp1=z.style.pixelLeft;            temp2=z.style.pixelTop;            x=event.clientX;            y=event.clientY;           releaseDragClasszIndex();           z.style.zIndex = 1;           z.className = "drag";           if (event.srcElement.childNodes[0].className == 'popupTitlePassive')	{	event.srcElement.childNodes[0].className = 'popupTitle';	}           document.onmousemove=move;        }  }function initCursorLoc(){  document.attachEvent('onmousemove',cursorLoc);}function cursorLoc(e){// keep track of current curson location for popups.xx = event.clientX;yy = event.clientY;//self.status = xx + " " + yy; // used for debugging, pb}function dragWidth(object, newWidth){// 2006-07-06 pbdocument.getElementById(object).style.width = newWidth;}function releaseDragClasszIndex(){ var tds = document.getElementsByTagName("TD"); for (var i = 0; i < tds.length; i++) {   myObj = tds[i];   if (myObj.className == "drag" && myObj.style.visibility == "visible") // it is case sensitive  {    myObj.style.zIndex = 0;    myObj.className = "dragpassive";    if (myObj.childNodes[0].className == 'popupTitle')	{	myObj.childNodes[0].className = 'popupTitlePassive';    	}  } }}function visible(object){  setStyle(object,'visibility','visible');  }function fadeOut(){try{	while(transitionOpacityCtr >0)	{       transitionOpacityCtr--;	  document.getElementById(globalObjectId).filters.item("DXImageTransform.Microsoft.Alpha").Opacity = transitionOpacityCtr;	  var timeThis = setTimeout("fadeOut()",100);	}	if (transitionOpacityCtr < 1)		{ 			moveOffScreen(globalObjectId);		}     }  catch(e)  {    alert('A javascript error has been detected in *fadeOut*\n\n'+e.message);  }}function fadeIn(){try{	clearTimeout(timeThis);	while(transitionOpacityCtr < 91)	{	       transitionOpacityCtr++;       opacityProgress += '|';	  document.getElementById(globalObjectId).filters.item("DXImageTransform.Microsoft.Alpha").Opacity = transitionOpacityCtr;	  timeThis = setTimeout("fadeIn()",50);	//window.status = opacityProgress;	 	}    }  catch(e)  {    alert('A javascript error has been detected in *fadeIn*\n\n'+e.message);  }}function hideHelp(objectId){    transitionOpactiyCtr = 90;    timeThis = setTimeout("fadeOut()",50);  }function showHelp(objectId){try{    prePosition(objectId);    globalObjectId = objectId;    //visible(globalObjectId);      transitionOpactiyCtr = 0;    opacityProgress = '';    timeThis = setTimeout("fadeIn()",50);        }  catch(e)  {    alert('A javascript error has been detected in showHelp\n\n'+e.message);  }}function showDialog(objectId){try{	positionCentre(objectId);//	prePosition(objectId);    globalObjectId = objectId;    //visible(globalObjectId);      transitionOpactiyCtr = 0;    opacityProgress = '';    timeThis = setTimeout("fadeIn()",50);        }  catch(e)  {    alert('A javascript error has been detected in showHelp\n\n'+e.message);  }}function hideDialog(objectId){	hideHelp(objectId);}function prePositionTitle(objectId){ document.getElementById(objectId+'Title').style.position = 'absolute'; document.getElementById(objectId+'Title').style.left = 0; document.getElementById(objectId+'Title').style.top =  1;}function positionCentre(objectId){try{    releaseDragClasszIndex();	wWidth = getWindowWidth();	wHeight = getWindowHeight();	popupWidth = forceNumeric(getStyle(objectId,'width'));	popupHeight = forceNumeric(getStyle(objectId,'height'));		popupHeight = 200; // the height of the dialog box		//alert(wHeight + ' ' + popupHeight);	leftPos = (wWidth / 2) - (popupWidth/2);	topPos = (wHeight / 2) - (popupHeight/2) +  getScrollOffset();	setStyle(objectId,'left',leftPos);	setStyle(objectId,'top',topPos);	setStyle(objectId,'position','absolute');	setStyle(objectId,'zIndex',1);	if (getStyle(objectId,'className') == "dragpassive" &&  getStyle(objectId,'visibility') == "visible")    {      setStyle(objectId,'className','drag');    }    prePositionTitle(objectId)        document.detachEvent('onmousemove',cursorLoc);}catch(e){ alert('A javascript error has been detected in function positionCentre()\n\n'+e.message);}}function prePosition(objectId){  try  {    releaseDragClasszIndex();    sWidth =document.body.clientWidth;    oWidth = parseFloat(document.getElementById(objectId).style.width);    if (isNaN(oWidth))    { oWidth=460;}    yyy = yy+iOffset;    document.getElementById(objectId).style.position = 'absolute';    // 2006-08-08 pb    document.getElementById(objectId).style.zIndex = 1;    if (document.getElementById(objectId).className == "dragpassive" &&  document.getElementById(objectId).style.visibility == "visible")    {      document.getElementById(objectId).className = "drag";    }    prePositionTitle(objectId)    //alert('xx:' + xx + ' oWidth:' + oWidth + ' sWidth:'+sWidth);    if ((xx + oWidth) > sWidth)    {      document.getElementById(objectId).style.left = sWidth - oWidth;    }    else    {      document.getElementById(objectId).style.left = xx;    }    document.getElementById(objectId).style.top = yyy;    document.detachEvent('onmousemove',cursorLoc);// used when debuggingself.status = 'prePosition:  x='+xx+' , y='+yyy;  }  catch(e)  {    alert('A javascript error has been detected\n\n'+e.message);  }}function releaseDrag(){document.detachEvent('onmousemove',move);document.attachEvent('onmousemove',cursorLoc);}function makeList(source){try	{	  // convert an array into a string LIST	   var newString = source.join(';');	   return newString;	   	}	catch(e)	{	  alert('catch exception: makeList ' + e.message);	  return '';	}}function makeArray(source, separator){try{  // convert comma, semicolon delimited string to an array of strings   var needle = new String(source);   var delimiter = '';   if (needle.indexOf(";") > -1) delimiter = ';'; // check for semicolun first   if (delimiter != '' && needle.indexOf(",") > -1) delimiter = ','; // then a comma   if (delimiter =='')   { // no delimiter present, an array of one element   	newArray = new Array(needle);//   	alert('1d array: '+newArray);   	return newArray;   }   newArray = needle.split(delimiter);      return newArray;   }catch(e){  alert('catch exception: makeArray ' + e.message);  return '';}}/* 2009-07-21 pb */function theMsg(msg){try{if (isEditMode == 1)	{		var q_String = getText('returnOrigin');		   		 if (q_String.indexOf("]") > -1)  		{			q_String = q_String.substr(0,q_String.indexOf("]"))  		}   	 	setText('returnOrigin',q_String += "&msg="+swapBlanksWithChar(msg,'+')+"]"); 	 	  	}    }  catch(e)  {    logError(severityMajor, 'catch exception detected in *theMsg* ' + e.message);  }}function softDelete(){try{	setText('isSoftDelete','1');  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *softDelete* ' + e.message);  }}function submit(){	document.forms[0].submit();}function swapBlanksWithChar(strText, swapChar){try{  re = new RegExp("\\s+","g");  return strText.replace(re,swapChar);  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *swapBlanksWithChar* ' + e.message);  }}function editDocument(docid){try{  	location.href = fullPath + '/0/' + docid + '?editDocument&msg=document+is+open+for+edit';   }  catch(e)  {    logError(severityMajor, 'catch exception detected in *editDocument* ' + e.message);  }}function displayResults(thisString){ try{	alert(thisString);  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *displayResults* ' + e.message);  }}function returnResults(docObj) { try{	var obj = docObj.forms[0];		var htmlString = '<table>';	var selectionIndex = -1;	var totEstimatedCeilCost = 0;	var roleCeilingArray = new Array;	var roleCeilingDurArray = new Array;	var durationArray = new Array;	var roleNums = new Array;	roleNums = roleTable.getRowNums()	for (z=0; z<roleNums.length; z++) {		durationArray[z] = top.getText('txtDuration'+roleNums[z]);	}	// Need to figure out what the MIN number of vendors is and put a VAR in here to be checked by the code.	var minVendors = 1;	htmlString = htmlString + '<tr>';	venTagObj = docObj.getElementById('venTag');				htmlString = htmlString + "<td><span class='titleCss'>" + venTagObj.innerHTML + "</span></td>";			for (var j = 1; j < 11; j++)	{		rolTagObj = docObj.getElementById('rolTag'+j);		if (rolTagObj != null)		{			htmlString = htmlString + "<td style='text-align: center; '><span class='titleCss'>" + '&nbsp;&nbsp;Per Diem Rate for<br>'+rolTagObj.innerHTML + "&nbsp;&nbsp;</span></td>";				roleCeilingArray.splice(roleCeilingArray.length, 0, 0)  // Initialize the role Ceiling cost so we can calculate each time around			roleCeilingDurArray.splice(roleCeilingDurArray.length, 0, 0)  // Initialize the role Ceiling*Duration cost so we can calculate each time around			roleCeilingArray[j] = 0;			roleCeilingDurArray[j] = 0;		}	}	ceilTagObj = docObj.getElementById('ceilTag');	if (ceilTagObj != null)	{		htmlString = htmlString + "<td style='text-align: center; '><span class='titleCss'''>&nbsp;&nbsp;" + removeText(ceilTagObj.innerHTML,'<br>') + "&nbsp;&nbsp;</span></td>";		}			htmlString = htmlString + '</tr>';		for (var i=0; i<obj.length; i++) 	{		var objType = obj.elements[i].type;				if (objType == 'checkbox') 		{			if (obj.elements[i].checked) 			{				selectionIndex++;				htmlString = htmlString + '<tr>';				venId = obj.elements[i].id				venNameValue = obj.elements[i].value;				htmlString = htmlString + '<td><span class="labelCss">' + venNameValue + '</span></td>';								rowNumber = forceNumeric(venId.substr(6)); // drop 'vendor'				//alert(rowNumber);						// loop through up to 10 roles than could have been selected				for (var j = 1; j < 11; j++)				{					roleId = 'role'+rowNumber+j; // format of role item is role+rowNumber+columnNumber							//alert(roleId);					// get the roleID object					roleIdObj = docObj.getElementById(roleId);							//alert(roleIdObj);					if (roleIdObj == null) {}					else					{						if (roleId != '')						{							roleString = roleIdObj.innerHTML;							//alert(roleString);							if (roleString != '')							{								htmlString = htmlString + '<td style="text-align: center; "><span class="labelCss">' + roleString + '</span></td>';								if ( forceNumeric(roleString) > roleCeilingArray[j] )								{									roleCeilingArray[j] = forceNumeric(roleString)									roleCeilingDurArray[j] = forceNumeric(roleString) * durationArray[j-1]								}							}						}					}				}								estCostId = 'estCost'+rowNumber;				estCostObj = docObj.getElementById(estCostId);						if (estCostObj == null) {}				{					htmlString = htmlString + '<td style="text-align: center; "><span class="labelCss">' + estCostObj.innerHTML + '</span></td>';															//alert('cost for '+estCostId + '='+ forceNumeric(estCostObj.innerHTML));//					totEstimatedCeilCost +=  forceNumeric(estCostObj.innerHTML);				}				htmlString = htmlString + '</tr>';				//obj.getElementByiD('role'+(i+1))+			}		}			}	htmlString = htmlString + '</table>';	minVendors = docObj.getElementById('minVendors').value	if (selectionIndex+1 < forceNumeric(minVendors)) {		alert('You must select at least '+minVendors+' vendors based on your ceiling cost.');	} else {		window.top.document.getElementById('vendorResults').innerHTML = htmlString;		for (i=1; i<roleCeilingDurArray.length; i++) 		{			totEstimatedCeilCost += roleCeilingDurArray[i];		}		var delimiter='\u00A5'		roleCeilingArray.splice(0, 1)    // the array was built starting at 1.   Need to remove the null element 0 before converting to a string.		temp = roleCeilingArray.join(delimiter);		window.top.document.getElementById('txtPerDiemList').value = temp;		totEstimatedCeilCostString = totEstimatedCeilCost.toString();		//alert(totEstimatedCeilCostString);		var maxCeiling = docObj.getElementById('maxCeilingCost').value;//		alert(maxCeiling);		if ( maxCeiling != '0' ) {//			window.top.blockUnhide('blockEstCeilingCost');			window.top.document.getElementById('txtMaxEstCeilingCost').value = formatCurrency(maxCeiling);			window.top.document.getElementById('txtMaxEstCeilingCost').className = 'fieldProtectedBoldCss';		}		window.top.document.getElementById('txtActualEstCeilingCost').value = formatCurrency(totEstimatedCeilCostString);		window.top.document.getElementById('txtActualEstCeilingCost').className = 'fieldProtectedBoldCss';		window.top.hideHelp('VendorSelect')		window.top.blockUnhide('blockVendorSelection');		window.top.blockUnhide('blockRolesSummary');	}  }  catch(e)  {	logError(severityMajor,'catch exception detected in *returnResults* ' + e.message);  }}function callbackVendors(response){  try  {     var iFrame = document.getElementById("VendorList");	var doc = iFrame.contentDocument;	if (doc == undefined || doc == null)		doc = iFrame.contentWindow.document;	doc.open();	doc.write(response);	doc.close();  }  	catch(e)	{	    logError(severityMajor, 'catch exception detected in *callbackVendors* ' + e.message);	}}function callbackVendorsTimeout(request, timeout, url){try{	alert("Search for vendor's not completed in a timely manner")	helpHide('VendorSelect');  }  	catch(e)	{	    logError(severityMajor, 'catch exception detected in *callbackVendorsTimeout* ' + e.message);	}}function callbackVendorsError(request, url){try{	alert("Search for vendor's has an error")	helpHide('VendorSelect');  }  	catch(e)	{	    logError(severityMajor, 'catch exception detected in *callbackVendorsError* ' + e.message);	}}function logAllDomElements() // for debug only{  try  {  var selectionString = '';  var selectionIndex = -1;  	obj = document.forms[0];	hit = 0; 	for (var i=0; i<obj.length; i++)	{		var objType = obj.elements[i].type;		logEvent(priorityDebug, obj.elements[i].name + '=' + obj.elements[i].value);					}	return selectionString;	  }  catch (errorcondition)  {    alert(errorcondition.message);    return false;  }}  /******************************************************************************************** The following function is used to store our dynamic fields to a solid Notes field* that can be later used to recreate the editable Web Dynamic fields.   We need* to pass the field name with a suffix of List.   The function strips off the 'List'* at the end and uses the remaining name for the dynamic field it is to collect.* The second parm is the rowList that was created by the web page.   This has the* real sequence numbers of the fields that remain on the form after all the add/delete* actions performed by the user********************************************************************************************/function setTableList(id, rowList){	try	{		var delimiter='\u00A5'		var obj, temp;		var tmpArray = new Array;		var name = id.slice(0, id.length-4);		for (var i=0; i<rowList.length; i++) {			obj = document.getElementById(name+rowList[i]);			if (obj.type == 'select-one') {				tmpArray[i] = getSelectedText(name+rowList[i]);			} else if ( obj.type == 'text') {				tmpArray[i] = getText(name+rowList[i]);							} else if ( obj.type =='textarea' ) {				tmpArray[i] = hideLineFeeds(getText(name+rowList[i]));			}		}				temp = tmpArray.join(delimiter);		setText(id, temp)	}	catch(e)	{	}}function getTableList(strList){	try	{		var delimiter='\u00A5'				  newArray = strList.split(delimiter);    		  return newArray; 	}	catch(e)	{	}	}/******************************************************************************************** The following function is the same as above but a special scenario due to the fact * that we have 2 fields that are used to store this information.********************************************************************************************/function setAreaTableList(id, dept, ppe, key, rowList){	try	{		var delimiter='\u00A5'		var obj, obj1, obj2, temp;		var tmpArray = new Array;		for (var i=0; i<rowList.length; i++) {			if (getSelectedText(key+rowList[i]) == 'Department') {				tmpArray[i] = getText(dept+rowList[i]);							} else {					tmpArray[i] = getSelectedText(ppe+rowList[i]);						}		}				temp = tmpArray.join(delimiter);		setText(id, temp)	}	catch(e)	{	}}function removeText(thisString, thisText){  try  {	return thisString.replace(eval('/'+thisText+'/gi'), ""); // note, replace uses a regExp  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *removeText* ' + e.message);  }}function forceNumeric(needle){try  {  var data = needle;  var scanned = 0;  while (scanned == 0)    {	   scanned = 1; // there might be nothing to scan	   for(var i = 0 ;i < data.length; i++ )	   {		    if (data.substr(i,1) < '0' || data.substr(i,1) > '9')		    {			     data = data.substr(0,i) + data.substr(i+1);			     scanned = 0;			     break;		     }		     if (scanned == 0 ) break;  	 }     }  return isNaN(parseInt(data,10)) ? -1 : parseInt(data,10); // 2007-01-25 pb, when time permits, substitute the above code with this (after debugging it)/* if (needle == '') { return -1; } var returnString = '';  for (var i = 0; i < needle.length; i++)  {        if (needle.substr(i,1) => '0' && needle.substr(i,1) =< '9')	{	  returnString = returnString + needle.substr(i,1);	}  }	  return isNaN(parseInt(returnString,10)) ? -1 : parseInt(returnString,10); */  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *forceNumeric* ' + e.message);  }}function formatCurrency(num) {try{	num = num.toString().replace(/\$|\,/g,'');	if(isNaN(num)) num = "0";		sign = (num == (num = Math.abs(num)));	num = Math.floor(num*100+0.50000000001);	cents = num%100;	num = Math.floor(num/100).toString();	if(cents<10) cents = "0" + cents;		for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));		return (((sign)?'':'-') + '$' + num + '.' + cents);  }  catch(e)  {    logError(severityMajor, 'catch exception detected in *formatCurrency* ' + e.message);  }}function translate(cellName,msg){try{  var name = cellName;  var oNode;  oNode = document.getElementById(name);  if (oNode.innerHTML == '<H2>No documents found</H2>')	{		oNode.innerHTML = msg;	}	  }  catch(e)  {      alert(severityMajor + 'catch exception detected in *translate* ' + e.message);  }}function openView(viewName){try{		var msg ='';	     msg = (isEditMode) ? parseValue(getText('returnOrigin'),"&msg=") : '';		location.href = (msg == '') ? fullPath + '/' + viewName + '?openView' : fullPath + '/' + viewName + '?openView&msg='+msg;  }catch(e)  {      alert(severityMajor + 'catch exception detected in *openView* ' + e.message);  }}function openForm(formName, parameters){try{            var msg = parseValue(getText('returnOrigin'),"&msg=");            // note, parameters MUST be pre-ESCAPED            location.href = (msg == '') ? fullPath + '/' + formName + '?openForm' + parameters : fullPath + '/' + formName + '?openForm' + parameters + '&msg='+msg;  }catch(e)  {      alert(severityMajor + 'catch exception detected in *openForm* ' + e.message);  }}function checkBudget(){try{	var budgetNum = forceNumeric(getText('txtApprovedFunding'));	var ceilingNum = forceNumeric(getText('txtEstCeilingCost'));		if ( budgetNum < ceilingNum ) {		spanText('errApprovedFunding' , 'lower than ceiling cost');		spanText('errEstCeilingCost' , 'higher than approved funding');	    	unHide('errApprovedFunding');	    	unHide('errEstCeilingCost');	    	color('lblApprovedFunding', 'red');	    	color('lblEstCeilingCost', 'red');		highlight('txtApprovedFunding'); 		highlight('txtEstCeilingCost'); 	} else {		spanText('errApprovedFunding' , '');		spanText('errEstCeilingCost' , '');	    	hide('errApprovedFunding');	    	hide('errEstCeilingCost');	    	colorOff('lblApprovedFunding');	    	colorOff('lblEstCeilingCost');		highlightOff('txtApprovedFunding'); 		highlightOff('txtEstCeilingCost'); 	}   }catch(e)  {      alert(severityMajor + 'catch exception detected in *checkBudget* ' + e.message);  }}function checkDuration(varArray){try{	var returnVal = true;		for (i=0; i<varArray.length; i++) {		returnVal = (validator.check('minvalue','txtDuration'+varArray[i], 0)) ? returnVal : false;	}		if ( returnVal ) {		enableButton('vendorButton');	} else {		disableButton('vendorButton');	} // end of returnVal if  }catch(e)  {      alert(severityMajor + 'catch exception detected in *checkDuration* ' + e.message);  }}function updatePointWeight(varArray){try{	var returnVal = true;	var totalPoints = 0;		for (i=1; i<varArray.length; i++) {		if (validator.check('number','numEvalPoints'+varArray[i])) {			returnVal = (validator.check('maxvalue','numEvalPoints'+varArray[i], 69)) ? returnVal : false;		} else {			returnVal = false;		}	}		if ( returnVal ) {		totalPoints += 30;			for (i=0; i<varArray.length; i++) {			tmp = getText('numEvalPoints'+varArray[i])			totalPoints += forceNumeric(tmp);		}		document.forms[0].numTotalPoints.value = totalPoints		if (totalPoints == 100) {			for (i=0; i<varArray.length; i++) {				highlightOff('numEvalPoints'+varArray[i])			}		    	spanText('errTotalPoints' , '');			    	hide('errTotalPoints');		} else {			for (i=0; i<varArray.length; i++) {				highlight('numEvalPoints'+varArray[i])			}		    	spanText('errTotalPoints' , '<br>Total points must be 100');		    	unHide('errTotalPoints');	//	    		highlight('numTotalPoints') // possibly add this in a look to highlight all the entry fields		}	} // end of returnVal if  }catch(e)  {      alert(severityMajor + 'catch exception detected in *updatePointWeight* ' + e.message);  }}function clearVendor(){try{	blockHide('blockVendorSelection'); 		blockHide('blockRolesSummary'); 	clearHtml('vendorResults'); //	roleSumTable.clearTable();	clearHtml('roleResults');	copyHtml('roleResults', 'txtRoleSumNewTable');	roleSumTable.initTable('tblRoleSummary', 3);	blockHide('blockRolesSummary');	checkDuration(roleTable.getRowNums())		 }catch(e)  {      alert(severityMajor + 'catch exception detected in *clearVendor* ' + e.message);  }}function getWindowWidth() {try{  var myWidth = 0  if( typeof( window.innerWidth ) == 'number' ) {    //Non-IE    myWidth = window.innerWidth;  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {    //IE 6+ in 'standards compliant mode'    myWidth = document.documentElement.clientWidth;  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {    //IE 4 compatible    myWidth = document.body.clientWidth;  }  return myWidth;    }catch(e)  {      alert(severityMajor + 'catch exception detected in *getWindowWidth* ' + e.message);  }}function getWindowHeight() {try{  var myHeight = 0;  if( typeof( window.innerHeight ) == 'number' ) {    //Non-IE    myHeight = window.innerHeight;  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {    //IE 6+ in 'standards compliant mode'    myHeight = document.documentElement.clientHeight;  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {    //IE 4 compatible    myHeight = document.body.clientHeight;  }  return myHeight;    }catch(e)  {      alert(severityMajor + 'catch exception detected in *getWindowHeight* ' + e.message);  }}function getScrollOffset() {try{  var scrOfY = 0;  if( typeof( window.pageYOffset ) == 'number' ) {    //Netscape compliant    scrOfY = window.pageYOffset;  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {    //DOM compliant    scrOfY = document.body.scrollTop;  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {    //IE6 standards compliant mode    scrOfY = document.documentElement.scrollTop;  }  return scrOfY;      }catch(e)  {      alert(severityMajor + 'catch exception detected in *getScrollOffset* ' + e.message);  }}function removeLineFeeds(source) {try	{		return source.replace(/[\r\n]+/g, "");      }catch(e)  {      alert(severityMajor + 'catch exception detected in *removeLineFeeds* ' + e.message);  }}function removeUnwantedChars(source){ try	{		var returnString = '';		var character;		  for (var i = 0; i < source.length; i++)		  {		      character = source.substr(i,1);		      if (isValidChar(character))			{			  returnString = returnString + character;			}		  }			  return returnString;	        }catch(e)  {      alert(severityMajor + 'catch exception detected in *removeUnwantedChars* ' + e.message);  }}function isValidChar(character){try	{		  re = new RegExp("[^A-Za-z0-9]");	  if (re.test(character))    		{ return false; }    		else { return true; }            }catch(e)  {      alert(severityMajor + 'catch exception detected in *isValidChar* ' + e.message);  }}function openFormInWindow(formName, parameters, window_name,win_height,win_width){try{	var msg = (isEditMode) ? parseValue(getText('returnOrigin'),"&msg=") : '';	// note, parameters MUST be pre-ESCAPED     url = (msg == '') ? fullPath + '/' + formName + '?openForm' + parameters : fullPath + '/' + formName + '?openForm' + parameters + '&msg='+msg;     window_name = removeUnwantedChars(window_name);    	anchor=window.open(url,window_name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+win_width+',height='+win_height);	anchor.focus();              }catch(e)  {      alert(severityMajor + 'catch exception detected in *openFormInWindow* ' + e.message);  }}  function hideLineFeeds(source) {try	{		return source.replace(/[\r\n]+/g, '\u00A7');      }catch(e)  {      alert(severityMajor + 'catch exception detected in *hideLineFeeds* ' + e.message);  }}function showLineFeeds(source) {try	{		return source.replace(/[\u00A7]+/g, '<br>');      }catch(e)  {      alert(severityMajor + 'catch exception detected in *showLineFeeds* ' + e.message);  }}function showLineFeedsEdit(source) {try	{		return source.replace(/[\u00A7]+/g, '\n');      }catch(e)  {      alert(severityMajor + 'catch exception detected in *showLineFeedsEdit* ' + e.message);  }}
