	<!--

var popupTarget;
var popupID;
var popupModifier;
var lastPopup = 0;
var PWindow;
var onload_actions = new Array();
var default_actions = new Array();
var delete_actions = new Array();
var kb_actions = new Object();
var save_conditions = new Array();
var versaITRequiredFields = [];
var onresize_actions = [];
				

var nonDataSuffix;

//regCodes = new Array(/\\\\d/ig,/\(/ig,/\)/ig, /\?/ig, /\*/ig);
//myCodes = new Array("#", "", "", "", "", "");

//checkRegCodes = new Array(/\\\\d/ig, /\?/ig, /\*/ig);
//checkMyCodes = new Array("#", "", "", "");

var calcItems;
var regColsRows = /(SUM\(|=)*\s*(\w+[\s\w]*)\[([^!\d#\s]*)(#?)([!\d]*)(:?)([^!\d#\s]*)(#?)([!\d]*)\]\)*/i;
var valColsRows = new Array('all', 'operation', 'tableName', 'column', 'numberSign', 'row', 'colon', 'column2', 'numberSign2', 'row2');

var newStyleUpdate=false;
var ssError = false;
var start, end;
var frmUpdate;
var inputCatalog;
//onload_actions.push("alert('!' + getElementByName('Display All Text'))");

var regExp_removetags = /<\/?[^>]+>/gi;

//var framePages = [];
//var frameList = [framePages];
//debugger;
//assist with portal back button
var frameList = new Array();
frameList[0] = new Array();
//assist with refreshing parent window from a portal modal popup
var currFrame;

function getdoc(name) {
			var obj = document.getElementById(name);
			if (obj && obj.contentDocument) return obj.contentDocument;
			return document.frames[name].document;
	}
	
function RemoveTags(xStr){
	xStr = xStr.replace(regExp_removetags,"");
	return xStr;
}

function inc_back_count() {
	var bc = parseInt(getURLParm('bc', 0));
	return '&bc=' + ++bc;
}
function go_back_count() {
	var bc = parseInt(getURLParm('bc', 0));
	setTimeout("history.go(" + -bc + ");", 1);
}

function getContentDocument(obj) {
	if (obj.contentDocument) {
		//alert('w3c');
		return obj.contentDocument;
	}	else if (obj.contentWindow) {
		//alert('ie5.5-6p');
		return obj.contentWindow.document;
	}	else if (obj.document ) { //&& !failed
		//alert('ie5m');
		return obj.document;
	} else {
		alert('Houston we have an IE 5.0 PC.');
		return null;
	}
}

function urlReplace(obj, url) {	//JS2FIREFOX [added]:	
	var io;
	if (obj.contentDocument) {
		//alert('w3c');
		io = obj.contentDocument;
	}	else if (obj.contentWindow) {
		//alert('ie5.5-6p');
		io = obj.contentWindow.document;
	}	else if (obj.document && !failed) {
		//alert('ie5m');
		io = obj.document;
	} else {
		alert('Houston we have an IE 5.0 PC.');
	}
  io.location.replace(url);
}
function submit_bg_form(form) {
	form.submit();
}
function handPointer(obj) { // JS2FIREFOX [added]: utility function added for mouseovers 
			obj.style.cursor =  'hand';
			if (obj.style.cursor != 'hand') obj.style.cursor = 'pointer';
			//if (obj.getAttribute('title')) setStatus( obj.getAttribute('title') );
		}
function getElementByName(name) {
	if (!name || name == '') return null;
	// the inputs aren't cataloged, until an element is requested (no reason to add load time if it's not used)
	if (!inputCatalog) catalogAllInputs();
	
	var obj = inputCatalog[name];
	return (obj ? obj : document.getElementById(name)); 
}
var regGetField = new RegExp();
regGetField.compile("f=([^@]*)", "i");
function catalogAllInputs() {
	//var startTime = new Date();
	inputCatalog = new Object();
	catalogItems('INPUT');
	catalogItems('SELECT');
	catalogItems('TEXTAREA');
	//window.status = 'Catalog time:' + ((new Date()).valueOf() - startTime.valueOf())/1000 + 'ms'; 
}
function catalogItems(type) {
	var objs = document.getElementsByTagName(type);
	var len = objs.length;
	for (var j=0; j < len; j++) {
		//if (type == 'SELECT') alert('found select');
		if ((type == 'INPUT' && objs[j].type == 'hidden') || !objs[j].getAttribute('name') || objs[j].getAttribute('name').substr(0, 3) != 'Val') continue;
		//if (type == 'SELECT') alert('doing select');
		catalogItem(objs[j]);
	}
}
function catalogItem(obj) {
	var name = null;
	var	pkg = obj.getAttribute('pkg');
		if (pkg && pkg != '') {
			// if this is a package based item, look for field name in pkg attribute
			var search = regGetField.exec(pkg);
			if (search && search[1]) name = search[1];
		}
		if (!name) {
			// if we didn't find a name earlier, then look for the 'Label' hidden input in the same cell as the input
			var inner_inputs = (obj.parentNode ? obj.parentNode.getElementsByTagName('INPUT') : null);
			var innerlen = inner_inputs.length
			if (inner_inputs && innerlen < 10) // if there are too many inputs, something is fishy and I don't trust the situation
			for (var i=0; i < innerlen && !name; i++) {
				if (inner_inputs[i].getAttribute('name') && inner_inputs[i].getAttribute('name') == 'Label') name = inner_inputs[i].getAttribute('value');
			}
		}
		if (!name) {
			name = obj.getAttribute('name');
		}
		if (name && name != '') inputCatalog[name] = obj;
}

function showFirstTab() {
	var tabs = divTabRow.getElementsByTagName('TD');
	//alert(tabs.length);
	tabs[0].onclick();
}

function load_help(template) {
	var tabname = '';
	var tab;
	try {
		if (selected_tab) tab = document.getElementById('divTab' + selected_tab);
		if (tab) tabname = tab.firstChild.innerHTML;
	} catch (e) {}
	if (template=='') template = PageName;
	window.open('help/help.asp?template=' + template + '#' + tabname, 'Help','toolbar=no,status=no,scrollbars=yes,menubar=no,resizable=yes,width=640,height=500'); return false;
}

function doUpdate() {
	alert('Error: The FastUpdate_v2 update code waS not loaded. Cannot save.');
	/*start = new Date();
	readform();
	end = new Date();
	alert('done:' + (end.getTime()-start.getTime())/1000);
	return false;*/
}
function writeRadioBtns(val_id,btnstr,curval,style) {
   var oRadio=document.getElementById(val_id);
   if (oRadio) {
	var optsArray = btnstr.split(',');
	document.write('<span style="font-size:9pt">');
	for (var i3=0; i3<optsArray.length; i3++) {
		var optsVals = optsArray[i3].split('|');
		if (style='right') {
		   if (optsVals[0]==curval || ((optsVals[0]=='0'||optsVals[0]=='No') && curval=='False') || ((optsVals[0]=='1'||optsVals[0]=='Yes') && curval=='True')) 
			 document.write('<input type="radio" name="'+val_id+'" checked value="'+optsVals[0]+'" onClick="document.getElementById(\''+val_id+'\').value=this.value;document.getElementById(\''+val_id+'\').setAttribute(\'Changed\',1)"/>'+optsVals[1]+' &nbsp; ')
		   else
			 document.write('<input type="radio" name="'+val_id+'" value="'+optsVals[0]+'" onClick="document.getElementById(\''+val_id+'\').value=this.value;document.getElementById(\''+val_id+'\').setAttribute(\'Changed\',1)"/>'+optsVals[1]+' &nbsp; ')
		}
		else {
		   if (optsVals[0]==curval) 
			 document.write(''+optsVals[1]+':<input type="radio" name="'+val_id+'" checked value="'+optsVals[0]+'" onClick="document.getElementById(\''+val_id+'\').value=this.value;document.getElementById(\''+val_id+'\').setAttribute(\'Changed\',1)"/> &nbsp; ')
		   else
			 document.write(''+optsVals[1]+':<input type="radio" name="'+val_id+'" value="'+optsVals[0]+'" onClick="document.getElementById(\''+val_id+'\').value=this.value;document.getElementById(\''+val_id+'\').setAttribute(\'Changed\',1)"/> &nbsp; ')
		}
	}
	document.write('</span>');
   }
}
function queue_for_update() {
}
function versait_back() {
	var back = -1;
	if (document.frmSelections.iframe_hits.value) back = back - eval(document.frmSelections.iframe_hits.value);
	setTimeout("history.go(" + back + ");", 1);
}
//document.onback = versait_back;
function doOnloadActions() {
//alert(5)
	//debugger;
	while (onload_actions.length > 0) {
		act = onload_actions.shift();
		//act = act.replace("'", "'");		
		//alert('onload_action: '+act);
		//if (document.getElementById('debugstuff')){
		//	var startTime = new Date();
		//	eval(act);
		//	document.getElementById('debugstuff').innerHTML = document.getElementById('debugstuff').innerHTML + '<br/> onload ' +  ((new Date()).valueOf() - startTime.valueOf())/1000 + 'ms' + ' = ' +  act; 
		//}else{	
		eval(act);
		if (document.getElementById('debugstuff')){debug('onload done ' + act  );}
		//}
	}
	window.onresize = doOnresizeActions;
	doOnresizeActions();
}

function doOnresizeActions () {
	//debugger;
	var resizeAction;
	for (var i=0;i<onresize_actions.length;i++) {
		resizeAction = onresize_actions[i];	
		eval(resizeAction);
	}
}

function subMatch(regName, matchName) {
	var localArray = eval('val' + regName);
	for (var looper = 0; looper < localArray.length; looper++) {
		if (localArray[looper] == matchName) return looper;
	}
	return null;
}

function FlagChange(ElementID)
{
	try {
	  document.frmSelections.Saved.value=0;
	  eval("document.frmSelections.Changed" + ElementID +".value=0");
	  
	}
	
	catch (error) {
		return;
	}
	
	var possibleSS = document.getElementById('calc' + ElementID);
	if (possibleSS != null) {
		calcAll();
	}
	return true;
}
function FlagChangeV2(InputElement)
{
	try {
		//if (document.getElementById('debugstuff')){debug('InputElement id = ' + InputElement.id );}
		//if (document.getElementById('debugstuff')){debug('InputElement changed = ' + InputElement.getAttribute('Changed') );}

		if(typeof(readform_array) != "undefined" && null != readform_array && InputElement.getAttribute('Changed')=='0'){
			readform_array.push(InputElement);
		}
		//if (document.getElementById('debugstuff')){debug('readform_array len = ' + readform_array.length );}
		document.frmSelections.Saved.value=0;
		InputElement.setAttribute("Changed",1);

		if (InputElement.getAttribute("flagrow")) {
			//alert('flagrow');
			//find parent TR
			var oParent = InputElement.parentNode;

			//alert(oParent.nodeName);
			while ( (oParent.nodeName !='BODY' && oParent.nodeName != 'TR') ) {
				oParent = oParent.parentNode;
				//alert(oParent.nodeName);
		      }

			if (oParent.nodeName=='TR') {
				//alert('TR');
				oParent.setAttribute("Changed",1);
				Elements = oParent.getElementsByTagName("input");
				for (var i=0; i<Elements.length; i++) {
				if(Elements.item(i).getAttribute("Changed")) {			
					//alert(Elements.item(i).tagName);
					Elements.item(i).setAttribute("Changed",1);
					 }
				}
							
				Elements = oParent.getElementsByTagName("select");
				for (var i=0; i<Elements.length; i++) {
				if(Elements.item(i).getAttribute("Changed")) {			
					Elements.item(i).setAttribute("Changed",1);
					 }
				}

				Elements = oParent.getElementsByTagName("textarea");
				for (var i=0; i<Elements.length; i++) {
				if(Elements.item(i).getAttribute("Changed")) {			
					Elements.item(i).setAttribute("Changed",1);
					 }
				}
			}
	    }
	//else
	  //if (queue_for_update) {
	  //		queue_for_update(InputElement, true);
	}
	
	catch (error) {
		return;
	}
	
	return true;
}
function getURLParm(str, default_) {
	if ((window.location.href.indexOf(str+'=') > 0)) {
		str = str+'=';
		var temp = window.location.href.substr( window.location.href.indexOf(str)+str.length);
		//alert(temp.indexOf('&'));
		if (temp.indexOf('&') > -1) return temp.substr (0, temp.indexOf('&') );
		else return temp;
	}
	else if((window.location.href.indexOf(encodeURI(str)+'=') > 0)) {
		str = encodeURI(str)+'=';
		var temp = window.location.href.substr( window.location.href.indexOf(str)+str.length);
		//alert(temp.indexOf('&'));
		if (temp.indexOf('&') > -1) return decodeURI(temp.substr (0, temp.indexOf('&') ));
		else return decodeURI(temp);
	}
	else {
		return default_;
	}
}
function calcAll() {
	subMatch ('ColsRows', 'column');
	if (ssError) return;
	if (calcItems == null)
		calcItems = document.getElementsByName("calc");
		
	for (var i=0; i < calcItems.length; i++) {
		if (calcItems[i].formula.charAt(0) == '=') {
			calcCell(calcItems[i]);
		}
	}	
}

function calcCell(calcItem) {
	var oldval;
	var resolvedFormula = resolveRefs(calcItem);
	if (resolvedFormula != null) {
		var valItem = document.getElementsByName("Val" + calcItem.value);
		try {
			oldval = valItem[0].value;
			if (valItem[0] != null) valItem[0].value = eval(resolvedFormula);
			valItem[0].value = Math.round(valItem[0].value*100)/100  
			if (oldval != valItem[0].value) eval("document.frmSelections.Changed" + calcItem.value +".value=0");
		}
		catch (e) {
			ssError = true;
			alert('Error calculating spread sheet');
		}
	}
}

function resolveRefs(calcItem) {
	var looper, tRow, colNum, rowNum, replacementVal, strTemp;
	var re = new RegExp(regColsRows);
	var formula = calcItem.formula.substr(1);
	var references = formula.match(re);
	var currRow = getParentElem(calcItem, 'TR');
	var tBody = getParentElem(currRow, 'TBODY');
	var regReplace;
	
	
	
	while (references != null) {
		var operation = references[subMatch('ColsRows', 'operation')];
		
		if (references[subMatch('ColsRows', 'numberSign')] == '#') {
			tRow = currRow;
			rowNum = null;
		} else if (references[subMatch('ColsRows', 'row')] != '') {
			rowNum = references[subMatch('ColsRows', 'row')];
			tRow = null;
			//go get specified row
		} else { // no row or '#' specified, must need whole column
			rowNum = null;
			tRow = null;
		}
		
		
		if (references[subMatch('ColsRows', 'column')] != null) {
			colNum = references[subMatch('ColsRows', 'column')].charCodeAt(0) - 64;			
		}
		
		if (colNum != null && tRow != null) 
			replacementVal = getCellValue(tRow, colNum);
		else if (colNum != null && rowNum != null) {
			if (references[subMatch('ColsRows', 'tableName')] == 'this') {					
					replacementVal = getCellValueFromTable(tBody, rowNum, colNum);
				}			
			else 
				replacementVal = getCellValueFromTableName(references[subMatch('ColsRows', 'tableName')], rowNum, colNum);
		}
		else if (tRow == null) { // working on all rows in a single column
			replacementVal = propagateOnColumn(currRow, colNum, operation);
		}
		
		if (replacementVal == null || replacementVal == '') replacementVal = 0;
		
		strTemp = references[0]
		strTemp = strTemp.replace(/\[/, "\\\[");
		strTemp = strTemp.replace(/\]/, "\\\]");
		strTemp = strTemp.replace(/\)/, "\\\)");
		strTemp = strTemp.replace(/\(/, "\\\(");
		regReplace = new RegExp(strTemp,"gi")
		
		formula = formula.replace(regReplace, replacementVal);
		
		// find the next 'tablename[]' set
		references = RegExp.rightContext.match(re);
	}
	return(formula);
	
}
function propagateOnColumn(tRow, colNum, operation) {
	var tBody = getParentElem(tRow, 'TBODY');
	var op;
	var cVal, sReturn;
	switch (operation.toLowerCase()) {
		case 'sum(':
			op = ' + ';
			break;
		case 'prod(':
			op = ' * ';
			break;
		case 'sub(':
			op = ' - ';
			break;
	}

	sReturn = null;
	for (var looper = 1; looper < tBody.childNodes.length; looper ++) {
		if (tBody.childNodes[looper] != tRow) //make sure we don't include current row
			if ((cVal = getCellValue(tBody.childNodes[looper], colNum)) != null) {
				if (looper == 1)
					sReturn = cVal;
				else
					sReturn = sReturn + op + cVal;
			}
	}

	return sReturn;
	
}


function getCellValueFromTableName(tableName, rowNum, colNum) {
	//alert(tableName);
	var tBody = document.getElementById('tb' + tableName);
	if (tBody == null) return null;
	
	tBody = tBody.childNodes[0];
	return getCellValueFromTable(tBody, rowNum, colNum);
}

function getCellValueFromTable(tBody, rowNum, colNum) {
	if (rowNum == '!')
		var tRow = tBody.childNodes[tBody.childNodes.length - 1];
	else
		var tRow = tBody.childNodes[rowNum];
	return (getCellValue(tRow, colNum));
}

function getCellValue(tRow, colNum) {
	var looper = 0;
	var column = tRow.childNodes[colNum];
	var targetCell = column.childNodes[looper++];
		
	while ( (targetCell !=null && targetCell.name != null && targetCell.name.substr(0,3) != 'Val') || (targetCell != null && targetCell.name == null) ) {
		
		targetCell = column.childNodes[looper++];
	}
	if (targetCell != null && targetCell.name != null && targetCell.name.substr(0,3) == 'Val')
		return targetCell.value;
	return null;
}

function getParentElem(item, elem) {
	var tElem;
	tElem = item.parentNode;
	while (tElem.nodeName != elem && tElem.nodeName != 'BODY') {
		tElem = tElem.parentNode;
	}
	if (tElem.nodeName == elem) {
		return tElem;
	}
	return null;
}


function getTable(tableName, calcItem) {
	// probably should add caching here for tables
	var tBody;
	if (tableName == 'this')
		tBody = calcItem.parentNode;
	while (tBody.nodeName != 'TBODY') {
		tBody = tBody.parentNode;
	}
	if (tBody.nodeName == 'TBODY') {
		alert('got it');
	}
}

function ValidateMask(item, mask)
{
	var required = item.mask;
	if (mask != "") {
		var re = new RegExp(mask);
		var matches = item.value.match(re);
		
		if (matches == null) {
			alert("Item: " + item.name + " must be of the form: " + required + ". Please correct this and resubmit.");
			return false;
		}
	}
	return true;
}

function HandleSpecial(item, e)
{
	//krish 08/14/08 document.selection is not compatible with firefox. Possibly implement using window.getSelection
	item.selection=document.selection.createRange();
	var currMask = item.mask;
	
	if (isMaskValid(item.value, currMask)) {
		var dup = item.selection.duplicate();
		var pos = 0-dup.move("character",-255);
		
		var dup = item.selection.duplicate();
		dup.move("character",1);
		
		var modPos = 0;
		
		if (pos < currMask.length) {
			switch (e.keyCode) {
			case 8: 
				// backspace key
				if (item.selection.text.length > 0) { // clear out any selected text 
					// if dealing with an actual selection
					var data = stripOutData(item.value, currMask, pos+item.selection.text.length);
					var newText = applyMask(data, currMask, pos);
					document.selection.clear();
					while (dup.expand("character"));
					dup.text = nonDataSuffix + newText;// + nonDataSuffix;
					
					return false;
					break;
				}
				
				if (currMask.charAt(pos-1) != '#' && currMask.charAt(pos-1) != '&') {
					// if trying to delete a non data character, skip over it
					dup.text = item.value.charAt(pos-1) + item.value.charAt(pos)
					item.selection.expand("character");
					item.selection.text = "";
					
					return true;
				}
				
				while (dup.expand("character"));
				var data = stripOutData(item.value, currMask, pos);
				var newText = applyMask(data, currMask, pos-1);
				dup.text = newText;// + nonDataSuffix;
				
				item.selection.expand("character");
				
				item.selection.text = "";
				return true;
				break;
				
			case 46:
				// delete key
				if (item.selection.text.length > 0) { // clear out any selected text 
					var data = stripOutData(item.value, currMask, pos+item.selection.text.length);
					var newText = applyMask(data, currMask, pos + modPos);
					document.selection.clear();
					while (dup.expand("character"));
					dup.text = nonDataSuffix + newText;// + nonDataSuffix;
					
					return true;
					break;
				}
				
				while (currMask.charAt(pos) != '#' && currMask.charAt(pos) != '&') {
					if (pos == item.value.length) return false; // jump out if no data left to delete
					pos++;
					modPos = -1;
				}
				while (dup.expand("character"));
				
				//alert(item.value);
				var data = stripOutData(item.value, currMask, pos+1);
				//alert(data);
				var newText = applyMask(data, currMask, pos + modPos);
				//alert(newText);
				dup.text = nonDataSuffix + newText;// + nonDataSuffix;
					
				return true;
				break;
			}
		}
	}
	return true;
}

function CheckMask(item, e)
{
	var passThrough = false;
	var currMask = item.mask;
	var newChar = String.fromCharCode(e.keyCode)
	var modPos = 1;
	
	item.selection=document.selection.createRange();
	if (item.selection.text.length > 0) {
		document.selection.clear(); // clear out any selected text
	}
	//item.selection.text = "" // clear out any selected text
		
	if (isMaskValid(item.value, currMask)) {
		var dup = item.selection.duplicate();
		var pos = 0 - dup.move("character",-255);
		var dup = item.selection.duplicate();
		dup.move("character", 1);
		while (dup.expand("character"));
		if (pos < currMask.length) { // if we're within the confines of the mask
			var data = stripOutData(item.value, currMask, pos);
			var tempString = "";
			var looper = pos;
			if (currMask.charAt(looper) != '#' && currMask.charAt(looper) != '&' && item.value.charAt(looper) != '' && currMask.charAt(looper) != newChar) {
				while (looper < currMask.length && looper < item.value.length && currMask.charAt(looper) != '#' && currMask.charAt(looper) != '&' && item.value.charAt(looper) != '' && currMask.charAt(looper) != newChar) {
					tempString = currMask.charAt(looper);
					looper++;
				}
				passThrough = true;
				modPos = tempString.length + 1;
				newChar = tempString + newChar;
			}
			if ((currMask.charAt(pos) == '#' && (newChar >= '0' && newChar <= '9')) || (currMask.charAt(pos) == newChar) || passThrough) { // at somepoint, when we do letter only mask, we will need some of this stuff //&& (currMask.charAt(pos) = '&' || (newChar > '0' || newChar < '9'))) {
				passThrough = false;
				// mask wants number and we got a number
				if (isMaskFilled(item.value, currMask)) {
					// if mask is filled up, we throw a
					data = data.substr(1);
				}
				var newText = applyMask(data, currMask, pos+modPos); // modPos will usually be 1, but will be 0 when entering prior to a non-data char
				
				if (pos < item.value.length) {
					// adding numbers in middle of text
					dup.text = newText				
					item.selection.expand("character");
				} else {
					// if appending numbers on end of text
					dup.text = newText				
				}
				
				item.selection.text = newChar + nonDataSuffix;
			}
			return false;
		} else {
			// we're outside mask, they can do whatever they want
		}
	}
	else {
		// mask isn't valid, they can do whatever they want

	}
	return true;
}

function applyMask(data, mask, startPos)
{
	var output="";
	var dataCount=0;
	nonDataSuffix="";
	// consume all data
	for (var looper=startPos; dataCount < data.length; looper++) {
		//alert('maskchar' + mask.charAt(looper));
		if (looper > mask.length || mask.charAt(looper) == '#' || mask.charAt(looper) == '&') {
			output = output + data.charAt(dataCount);
			dataCount++;
		} else {
			if (dataCount > 0) {
				// never want lead character to be a dash (non data)
				output = output + mask.charAt(looper);
			} else {
				nonDataSuffix = nonDataSuffix + mask.charAt(looper);
			}
			//if (looper == mask.length) return output;
		}
		
	}
	// append any non-data mask stuff
	for (var looper = looper; looper < mask.length; looper++) {
		if (mask.charAt(looper) != '#' && mask.charAt(looper) != '&') {
			output = output + mask.charAt(looper)
		} else {
			return output;
		}
	}
	return output;
}

function stripOutData(input, mask, startPos)
{
	var output="";
	for (var looper=startPos; looper < input.length; looper++) {
		if (looper >= mask.length || mask.charAt(looper) == '#' || mask.charAt(looper) == '&') {
			output = output + input.charAt(looper);
		}
	}
	return output;
}

function isMaskValid(input, mask)
{
	for (var looper=0; looper < mask.length; looper++) {
		if (looper >= input.length) {
			return true;
		}
		else {
			if (mask.charAt(looper) == '#' && (input.charAt(looper) < '0' || input.charAt(looper) > '9')) {
				//if (mask.charAt(looper) == ' ')	return true;
				// if there is a space at end of current valid text, then ignore remainder of text.
				return false;
			} else {	
				//if (mask.charAt(looper) != '&') {	// need checking here later
				//	return false;
				//} else {
					if (mask.charAt(looper) != '#' && mask.charAt(looper) != input.charAt(looper)) {
						//if (mask.charAt(looper) == ' ')	return true;
						return false;
					}
				//}
			}
		}
	}
	return true;
}

function isMaskFilled(input, mask)
{
	if (mask.length > input.length) return false;
	return true;
}

/*
var regGetRequired = new RegExp();
regGetRequired.compile("Required=([^@]*)", "i");
function verifyRequired(prehighlight) {
	if (typeof verifyRequiredFlag == 'undefined' || !verifyRequiredFlag) return true;
	var proceed = true;
	inputs = document.frmSelections.getElementsByTagName("INPUT");
	proceed = RequiredItemProcess(inputs);
	//alert('about to process SELECTs');
	inputs = document.frmSelections.getElementsByTagName("SELECT");
	proceed = (RequiredItemProcess(inputs) && proceed);
	if (!proceed) {
		if (!prehighlight) alert('Fields highlighted in yellow must have a value.');
		return false;
	}
	return true;
}
function RequiredItemProcess(inputs) {
	var proceed=true;
	//alert('RequiredItemProcess:'+inputs[0].tagName);
	//alert(inputs.length);
	for (j = 0; j < inputs.length; j++) {
		//alert(inputs[j].getAttribute('pkg'));
		if (!inputs[j].getAttribute('pkg') || inputs[j].getAttribute('pkg') == '') continue; 
		var search = regGetRequired.exec(inputs[j].pkg);
		//alert(inputs[j].getAttribute('pkg'));
		if (search && search[1]) {
			//alert(search[1]);
			for ( var i2=0; i2 < inputs[j].parentNode.parentNode.childNodes.length; i2++) {
				for ( var i=0; i < inputs[j].parentNode.parentNode.childNodes[i2].childNodes.length; i++) {
					var sibling = inputs[j].parentNode.parentNode.childNodes[i2].childNodes[i];
					try {
						if ((!sibling.getAttribute('old_bg') || sibling.getAttribute('old_bg').length == 0) && inputs[j].value == '') {
							sibling.setAttribute('old_bg', sibling.style.backgroundColor);
							sibling.style.backgroundColor = 'FFFFCC'
							proceed = false;
						} else if (sibling.getAttribute('old_bg')  && inputs[j].value != '') {
							sibling.style.backgroundColor = sibling.getAttribute('old_bg');
							sibling.setAttribute('old_bg', '');
						} else if ( inputs[j].value != '') {
							sibling.style.backgroundColor = '';
						}	else  proceed = false;
					} catch (e) {}
					if (sibling == inputs[j]) break;
				}
			}
			try {
			if (proceed && inputs[j].getAttribute("type") !='hidden') inputs[j].focus();
			} catch (e) {}
		
		}
	}
	return proceed;
}
*/

function VerifySave(dont_wait, target_obj)	//JS2FIREFOX [changed] - added target_obj param
{
	//following specifically for Testgate, question page.
	/*
	try {
		SaveHTML(selectedEditObj);
	} catch (e) {}*/
	
	if (newStyleUpdate && outstandingUpdates()) {
		if (confirm("Changes have been made to this page. Press OK if you wish to save these changes and continue")) {
			//if (confirm("Changes have been made to this page. Press OK if you wish to discard these changes and continue"))
			if (verifyRequiredFields()) {
				doUpdate(dont_wait);
				return true;
			} else { return false; }
		} else {
			return (confirm("Do you wish to continue with requested action without saving?"));
		}
	}
	
	if (document.frmSelections.Saved.value==-1)
	{               
		document.frmSelections.Saved.value=0;
		return true;
	}
	
	if (document.frmSelections.Saved.value==0)
	{
		//For FastUpdate, cookie requested action, call "Save" onclick, then check for "nextaction" cookie afterwards.
		//Assume there is a "Save" button with an "onclick"
		if(document.getElementById('Save')) {
			if(document.getElementById('Save').getAttribute('onclick'))
				var savecmd = document.getElementById('Save').getAttribute('onclick');
			else
				var savecmd = document.getElementById('Save').parentNode.getAttribute('onclick');
			//alert('Save: '+document.getElementById('Save').nodeName+':'+savecmd);
			
			var srcEl = (window.event && window.event.srcElement) ? window.event.srcElement : target_obj;			//JS2FIREFOX [changed]

			if(srcEl) {
				var cmd=srcEl.getAttribute('cmd');
				//alert('1' + cmd);
				if(srcEl.tagName=='DIV')
					if(srcEl.getAttribute('cmd')) {
						cmd = srcEl.getAttribute('cmd');
						//alert('2' + cmd);
				
					}
					if(cmd==null && srcEl.tagName!='A' && srcEl.parentNode.tagName=='A') { 
					cmd = srcEl.parentNode.getAttribute('onclick');
					//alert('3' + cmd);
				
					} 
					else {
					cmd = srcEl.getAttribute('onclick');
					//alert('4' + cmd);
				
					}

				if(cmd==null) cmd='';
				cmd = cmd.toString().replace(/function anonymous\(\)/,"")
				cmd = cmd.toString().replace(/return false/,"")
				cmd = cmd.toString().replace(/VerifySave\(([^\)]*)\)/,"true")
				//alert('cmd: '+cmd); 

				//document.frmUpdate['nextaction'].value = cmd;
				//alert('nextaction: '+document.frmUpdate['nextaction'].value); 
			}
		}
		else savecmd=''

			if (confirm("Changes have been made to this page. Do you wish to save and continue?"))
		{
			if (verifyRequiredFields()) {
				//alert(savecmd.toString().indexOf('readform'));
				if(savecmd.toString().indexOf('readform')>0) {	//Does the Save button have "readform" in it?
					//set frmUpdate.nextaction
					if(cmd) {
						//alert('test:' + cmd);
						setCookie('checknextaction', '1');		
						setCookie('nextaction', escape(cmd) );
					}
					else	setCookie('checknextaction', '0');
					try {
						//document.getElementById('Save').onclick();	//execute Save
						if(document.getElementById('Save').getAttribute('onclick'))
							document.getElementById('Save').onclick();
						else
							document.getElementById('Save').parentNode.onclick();
					}
					catch (error) {
						var errorstuff = error;
					return false;}

				} else {
					document.frmSelections.Saved.value=-1;
					return true;
				}
			} else {
				return false;
			}
		}
		else
		{
			return (confirm("Do you wish to continue with requested action without saving?"));
		}
	}
	else
		return true;
}

function verifyRequiredFields() {
	var missingRequiredFields = '';
	var returnVal = true;

	if (versaITRequiredFields!='undefined') {
		
		/* --------------------------------------- */
			//Cross-browser Compliance: Complete
			//Notes: Added line of code below to
			//		 verify that the form element,
			//		 document.getElementById(versaITRequiredFields[i][0])
			//		 exists before trying to examin
			//		 its value.
		/* --------------------------------------- */	
		
		for (var i=0;i<versaITRequiredFields.length;i++) {		
			if (document.getElementById(versaITRequiredFields[i][0]) && //Cross-browser compliance
				(document.getElementById(versaITRequiredFields[i][0]).value=='' || 
					document.getElementById(versaITRequiredFields[i][0]).value.toLowerCase()=='all')) 
					missingRequiredFields += versaITRequiredFields[i][1] + ', ';
		}
		
		/* --------------------------------------- */
			//End of Cross-browser Compliance
		/* --------------------------------------- */
		
		if (missingRequiredFields!=''){
			alert('Values must be set for the following fields before you can save this record: ' + missingRequiredFields.substring(0,missingRequiredFields.length-2));
			returnVal = false;
		}
	}
	return returnVal;
}

function VSaveButton(url)
{

	document.frmSelections.action = url;

	if (document.frmSelections.Saved.value==-1)
	{	
		document.frmSelections.Saved.value=0;
		return true;
	}	
	if (document.frmSelections.Saved.value==0)
	{	


		var pattern = /Save(\w+)/g;
		var saveFound;
		var buttons = document.getElementsByTagName('a');
		var num = buttons.length;
		var currItem; 
		var SaveButton = 'no';
		var j = 1;
		while (j < num) {
			currItem = buttons[j];
			if (currItem.innerText.substr(0, 4) == 'Save') {
				SaveButton = 'yes';
				j = num;
			}
		j++;
		}

		if (SaveButton == 'yes')
		{
			//alert('SaveButton onclick=' + currItem.onclick);

			if (confirm("Changes have been made to this page. Do you wish to save and continue?"))
			{
				document.frmSelections.Saved.value=-1;
				//merge urls
				var DisplayURLParts = url.split('&');
				var SaveURL = "" + currItem.onclick;
				var SaveURLParts = SaveURL.split("'");
				var NewURL = SaveURLParts[1].split("&")[0];
				NewURL = NewURL + '&' + SaveURLParts[1].split("&")[3];
				NewURL = NewURL + '&' + DisplayURLParts[0].split("?")[1];
				NewURL = NewURL + '&mergedurl=y';
				var num2 = DisplayURLParts.length;
				var k = 1;
				while (k < num2) {
					NewURL = NewURL + '&' + DisplayURLParts[k];

				k++;
				}
				
				//alert('NewURL=' + NewURL);
				document.frmSelections.action = NewURL;



				return true;
			}
			else
			{
				if (confirm("Do you wish to continue with requested action without saving?"))
				{
					return true;
				}
				else
				{
					return false;
				}
			}
		}
		else
		{
			return true;
		
		}	
	}
	else
		return true;
}

function PotentialRefresh()
{
 	/*
	This is code created on 7/11/02. It looked in the URL for a modifier, found the first file in
	the html (hidden control) and redirected to it. We decided to do this a different way to avoid
	the flash of the intermediate page showing up.

	var intNumFiles
	var filePath
 	var urlString = document.frmSelections.CurrURL.value;
	var pattern = /skipToFile=(\w+)/;
	var skipToFile = urlString.match(pattern);
	if (skipToFile[1] == "true") {
		document.frmSelections.CurrURL.value = urlString.replace(pattern, "");
		intNumFiles = eval("document.frmSelections.fileLink.length");
		if (typeof(intNumFiles) != "undefined")
		{
			filePath = document.frmSelections.fileLink[0].value;
		} else {
			filePath = document.frmSelections.fileLink.value;
		}
		if (filePath != null) {
			window.location = filePath;
			return true;
		}
	}*/
	

	// original stuff, pre June 2002
	              var endstr = document.cookie.indexOf ("checknextaction=1");
								 if (endstr > -1 && document.frmSelections.EndAction)
                {
								                 var nextaction = getCookie('nextaction');
                                nextaction = unescape(nextaction);
                                //alert('Cookie nextaction='+nextaction);
                                setCookie('checknextaction', '0');
                                setCookie('nextaction', '');
                                document.frmSelections.Saved.value=-1;
																	eval(nextaction);
																	//setTimeout('alert("ok");' + nextaction, 5000);
                }
                
                endstr = document.cookie.indexOf ("backreload");
                if (endstr > -1)
                {
                                document.cookie = "EndAction=none";
                                //window.location.reload(true);
                                setTimeout("window.location.reload(true);", 1);
																	//window.location.replace(window.location.href);
																	//alert('here');
                }
                document.frmSelections.Saved.value=1;
                return true;
}

function PotentialBackNavigation()
{
	if (document.frmSelections.EndAction.value ==1)
	{
		document.frmSelections.EndAction.value = 0;
		setTimeout("history.go(-2);", 1);
	}
	if (document.frmSelections.EndAction.value == 2)
	{
		document.frmSelections.EndAction.value = 0;
		document.cookie = "EndAction=backreload";
		setTimeout("history.go(-2);", 1);
	}
	
	return true;
}


function FlagChangeMulti(isChecked,ElementID)
{
	// this is used for both Reverse PV selection changes, as well as attendance page changes for the Tech Connect 2 application.
	// Note, ElementID cannot contain a colon.
	var intNumBoxes;
	document.frmSelections.Saved.value=0;
	
	intNumBoxes = eval("document.frmSelections." + ElementID +".length");
	
	if (typeof(intNumBoxes) != "undefined")
	{
		ElementID = ElementID + "[0]"
	}
	if (isChecked) {
		eval("document.frmSelections." + ElementID +".value=1");
	}
	else {
		eval("document.frmSelections." + ElementID +".value=0");
	}
		
	return true;
}
/*
function RevPVChange(isChecked,ElementID)
{
	var intNumBoxes;
	document.frmSelections.Saved.value=0;
	
	intNumBoxes = eval("document.frmSelections." + ElementID +".length");
	
	if (typeof(intNumBoxes) != "undefined")
	{
		ElementID = ElementID + "[0]"
	}
	if (isChecked) {
		eval("document.frmSelections." + ElementID +".value=1");
	}
	else {
		eval("document.frmSelections." + ElementID +".value=0");
	}
	return true;
}*/

function EntryIsChecked()
{
	var Checked; //as Boolean
	var intNumBoxes, x; // as integer
	
	Checked=false;
	
	intNumBoxes = document.frmSelections.chkPage.length;
	if (typeof(intNumBoxes) == "undefined")
	{
		// if only entry checked, true otherwise false
		Checked = document.frmSelections.chkPage.checked;
	}
	else
	{
		x=0;
		while (x<intNumBoxes)
		{
			if (document.frmSelections.chkPage[x].checked)
			{
				Checked = true;
			}
			x++;
		}
	}
	if (!Checked) alert("You must select at least 1 entry for this function.");
	return Checked;
}

function ItemIsChecked()
{
	var Checked; //as Boolean
	var intNumBoxes, x; // as integer
	
	Checked=false;
	
	intNumBoxes = document.frmSelections.chkItem.length;
	if (typeof(intNumBoxes) == "undefined")
	{
		// if only entry checked, true otherwise false
		Checked = document.frmSelections.chkItem.checked;
	}
	else
	{
		x=0;
		while (x<intNumBoxes)
		{
			if (document.frmSelections.chkItem[x].checked)
				Checked = true;
			x++;
		}
	}
	if (!Checked) alert("You must select at least 1 item for this function.");
	return Checked;
}


function PopUp(ID, popupPage, IDmodifier, initValue) {
	var openURL = 'display.asp?formatoption=popup&retrievemode=page&pagetype=POPUP+PAGE&key=' + popupPage + '&' + initValue;
	//var w = 330, h=270;
	var w = 640, h=480;
	//var openParms = 'location=no,scrollbars=yes,resizable=yes,width='+w+',height='=h;
	var openParms = 'location=no,scrollbars=yes,resizable=yes,width='+w+',height='+h;
	popupID = ID;

//alert(openParms);
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	openParms = openParms+',top='+TopPosition+',left='+LeftPosition
//alert(openParms);

	if (IDmodifier == null) {
		popupModifier = '';
	} else {
		popupModifier = IDmodifier;
	}
		
	try {
		if (popupModifier.substr(0,2) == '??') 
			popupTarget = document.frmSelections[popupModifier];
		else {
			popupTarget = eval("document.frmSelections.Val" + popupModifier + ID);
			if (!popupTarget) popupTarget = eval("document.frmSelections.TargetLink" + popupModifier + ID);
			if (!popupTarget) popupTarget = document.getElementById(ID);
		}
		
	}
	catch (error) {
		return;
	}
	
	if (popupPage.indexOf('.') > -1) {
		openURL = popupPage;
	}

	if (popupPage.indexOf('lookup.asp') > -1) {
		//alert(popupPage);
	    if (document.location.href.indexOf('xID=') > -1) {
		pos = document.location.href.indexOf("xID=")
		if (pos > -1)	{
		    xID = document.location.href.substring(pos + 3, document.location.href.length)
		    if (xID.indexOf("&") >= 0)
			xID = unescape(xID.substring(1, xID.indexOf("&")))	
		    openURL = openURL+'&xID='+xID;
		}
	    }
	}

	if (lastPopup != popupPage || typeof(PWindow) == 'undefined') {
		// if window has never been opened, or this is a different popup, open it
		PWindow=open(openURL,'PWindow',openParms);
		if (PWindow.opener == null) PWindow.opener = self;
		PWindow.focus();
		lastPopup = popupPage;
	}
	else {
		// if this popup is already open, or already opened and closed.
		try {
			// reapply focus
			PWindow.focus();
		} catch (error) {
			// if the popup had been closed, reopen it
			PWindow=open(openURL,'PWindow',openParms);
			if (PWindow.opener == null) PWindow.opener = self;
			lastPopup = popupPage;
		}
	}
}

function DatePopUp(ID,IDmodifier) {
	var openURL = 'datepopup.htm';
	var openParms = 'location=no,scrollbars=no,resizable=no,width=250,height=230';
	popupID = ID;
	if (IDmodifier == null) {
		popupModifier = '';
	} else {
		popupModifier = IDmodifier;
		//alert(popupModifier.charAt(0));
		//if (popupModifier.charAt(0)=='?') alert('Parm');
		//alert(document.frmSelections.elements[IDmodifier].value);
	}
	try {
		if (popupModifier.charAt(0)=='?' && document.frmSelections.elements[IDmodifier]) {
			popupTarget = document.frmSelections.elements[IDmodifier];
			}
		else {
			popupTarget = eval("document.frmSelections.Val" + popupModifier + ID);
			if (!popupTarget) popupTarget = eval("document.frmSelections.TargetLink" + popupModifier + ID);
			if (!popupTarget) popupTarget = eval("document.getElementById('"+popupModifier + ID+"')");
		}
	}
	
	catch (error) {
		if (!popupTarget) popupTarget = eval("document.getElementById('"+popupModifier + ID+"')");
		if (!popupTarget) return;
	}
	
	var PWindow;
	if (typeof(PWindow) == 'undefined') {
		// if window has never been opened, or this is a different popup, open it
		PWindow=open(openURL,'PWindow',openParms);
		if (PWindow.opener == null) PWindow.opener = self;
		PWindow.focus();
	}
	else {
		// if this popup is already open, or already opened and closed.
		try {
			// reapply focus
			PWindow.focus();
		} catch (error) {
			// if the popup had been closed, reopen it
			PWindow=open(openURL,'PWindow',openParms);
			if (PWindow.opener == null) PWindow.opener = self;
		}
	}
}



var changedLinkText = "alert('test2');";
function changedLink() {
	var temp = new Function(changedLinkText);
	temp();
	return false;
}

function RPV(Value) {
	return returnPopupValue(Value);
}
function returnPopupValue(Value) {
	//alert(Value);
		var sets;
		
		var loop;
		if (Value.indexOf("=") == -1) {
			// simple assignment (no ='s)
			
			try {
				opener.popupTarget.value = Value;
				//alert(opener.popupID);				
				opener.popupTarget.onchange();//the onchange event is not called upon setting the value, and so has to be fired here
				//opener.FlagChange(opener.popupID);
			} catch (error) {
				if (popupTarget)
					popupTarget.value = Value;
			}
		}
		else {
			if (Value.indexOf("&&") == -1) {
				handleReturn(Value)			
			} else {
				sets = Value.split("&&");
				for(loop = 0; loop < sets.length; loop++) {
					handleReturn(sets[loop])
				}
			}
		}
		/*try {
			opener.FlagChangeV2(opener.document.getElementById(opener.popupID))
			//alert('id: ' + opener.popupID);
			//alert('el: ' + opener.document.getElementById(opener.popupID));
		} catch (error) {}
		try {
			opener.FlagChange(opener.popupID);
		} catch (error) {
		}*/
	
	window.close();
}

function handleReturn(text) {
	var pairs;
	var target;
	var j=1;
	var finders;
	
	pairs = text.split("=");
	if (pairs[0].substr(0,14) == 'AttributeVal!!') {
		var temp = 'AttributeLabel' + opener.popupID;
		finders = pairs[0].split("!!");
		var num = opener.document.getElementsByTagName('input').length;
		var currItem; 
		while (j < num) {
			currItem = opener.document.getElementsByTagName('input')[j];	
			if (currItem.value == finders[1] && currItem.name.substr(0,temp.length) == temp) {
				target = eval("opener.document.frmSelections.AttributeVal" + opener.popupID + currItem.name.substring(temp.length));
				j = num;
			}
		j++;
		}
		target.value = pairs[1];
		return false;
	}
	if (pairs[0].substr(0,10) == '@@linkpage' || pairs[0].substr(0,4) == '@@lp') {
		var pattern = /key=[\d]*/i;
		
		var temp = opener.document.getElementById('link' + opener.popupID).onclick.toString();
		temp = temp.substring(temp.indexOf('{') + 2, temp.length - 3) + ';'; // rip out function text
		// this line of code removes the return false found at start of onclick when there is no selected value already ('None')
		if (temp.substring(0, 13) == 'return false;') temp = temp.substring (14);
		temp = temp.replace(pattern, "key=" + pairs[1]); // change key value
		// set function text into hidden javascript variable in calling page
		opener.changedLinkText = temp;
		// change onclick to point to a function in the calling page, which invokes the text set above
		opener.document.getElementById('link' + opener.popupID).onclick = opener.changedLink;
		opener.popupTarget.value = pairs[1]; // set new link value
		opener.FlagChange(opener.popupID);
		return false;
	}
	if (pairs[0].substr(0,10) == '@@linktext' || pairs[0].substr(0,4) == '@@lt') {
		opener.document.getElementById('link' + opener.popupID).innerText = pairs[1]; // change link text
		return false;
	}
	
	try {
		target = eval("opener.document.frmSelections." + pairs[0] + opener.popupID);
		target.value = pairs[1];
	} catch (error) {
		alert('Error finding target.');
		return false;
	}
	
	
}

// *************************************************************
// This area deals with cursor positioning and pressing enter
firstElement = 0;
netscape = "";
ver = navigator.appVersion; len = ver.length;
for(iln = 0; iln < len; iln++) if (ver.charAt(iln) == "(") break;
netscape = (ver.charAt(iln+1).toUpperCase() != "C");

var default_actions_return = true;

function keyDown(DnEvents) { // handles keypress
	//debugger;
	// determines whether Netscape or Internet Explorer
	var event = (DnEvents) ? DnEvents : window.event					// JS2FIREFOX [changed]
	var k = event.keyCode;																			// JS2FIREFOX [changed]
	var action = kb_actions[k + '_'];
	if (k == 13 && !action) { // enter key pressed
		var src = (event.target) ? event.target : event.srcElement;		// JS2FIREFOX [changed]
		if (src.name && src.name.substr(0,3)=='Val') {
			eval('FlagChange('+src.name.substr(3,9)+')');
		}
		//alert(document.getElementById('QuickSearch').value);
		if((document.frmDefaultAction && document.frmDefaultAction.DefaultAction)){
			//following line is to ensure that onchange event occurs for textbox
			try {
				document.frmSelections.elements[firstElement].focus();
				document.frmSelections.elements[firstElement].blur();
			} catch (e) {}
				intEnterActions = document.frmDefaultAction.DefaultAction.length;
				if (typeof(intEnterActions) == "undefined")
				// if only 1
					eval(document.frmDefaultAction.DefaultAction.value);
				else
				// if more than 1
					eval(document.frmDefaultAction.DefaultAction[0].value);
		}

		for (var j=0; j < default_actions.length; j++) {
			eval(default_actions[j]);
			}
		
	} else if (k == 46 && !action) { // del key pressed
		for (var j=0; j < delete_actions.length; j++) {
			eval(delete_actions[j]);
			
		}
	} else if (action) {
		if (eval(action['ctrl']) == event.ctrlKey && eval(action['shift']) == event.shiftKey && eval(action['alt']) == event.altKey)   {
			eval(action['action']);
		}
	}
	if(!default_actions_return){
		default_actions_return = true;
		return false;
	}

}

document.onkeydown = keyDown; // work together to analyze keystrokes
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);
//if (document.addEventListener)
 // document.addEventListener('keydown', keyDown, true);
//document.attachEvent('onkeydown', function(){keyDown();});

function attachKeyPress(action, code, ctrlkey, altkey, shiftkey) {
	var temp = new Object;
	temp['ctrl'] = (ctrlkey ? 'true' : 'false');
	temp['alt'] = (altkey ? 'true' : 'false');
	temp['shift'] = (shiftkey ? 'true' : 'false');
	temp['action'] = action;
	
	kb_actions[code + '_'] = temp;
	
}


// *************************************************************

function keypress_number(decimal) {
	var keypressed = window.event.keyCode;
	var ElementText  = window.event.srcElement.value ;
	if (keypressed == 45){
		if (ElementText.length!=0) {
			window.event.keyCode = 0;
		}
	
	}
	else {
		if (decimal) {
			var Reg = /\./g;
			if (Reg.test(ElementText)) {
				if( (keypressed >= 48 && keypressed <= 57) == false) {
					window.event.keyCode = 0;
				}
			}
			else {
				if ((keypressed >= 48 && keypressed <= 57 || keypressed == 46) == false) {
					window.event.keyCode = 0;
				}
			}
		}

		else {
			if ((keypressed >= 48 && keypressed <= 57) == false) {
				window.event.keyCode = 0;
			}
		}
	}
}

function keypress_date() {
	var keypressed = window.event.keyCode;
	var ElementText  = window.event.srcElement.value ;
	if (keypressed == 45){
		if (ElementText.length!=0) {
			window.event.keyCode = 0;
		}
	}
	else {
		if ((keypressed >= 48 && keypressed <= 57 || keypressed == 45 || keypressed == 47) == false) {
			window.event.keyCode = 0;
			}
	}
}

function setCursor() {
	
//alert(document.frmDefaultAction.newLoad.value);
//document.frmDefaultAction.newLoad.value = 0;
//alert(document.frmDefaultAction.newLoad.value);

	var dontrefresh = getCookie('dontrefresh');
	setCookie('dontrefresh', 'false');
	if (dontrefresh == 'true') return;
	for (x = 0; x < document.frmSelections.length; x++) {
		if (document.frmSelections.elements[x].type == "text" || document.frmSelections.elements[x].type=="password") {
			try {
				document.frmSelections.elements[x].focus();
				firstElement = x;
			} catch (error) {}
			return;
		}
	}
}


// *************************************************************

function openwin(url,wintype)
{

 if (wintype=="screen1") window.open(url, wintype,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width=250,height=500');
 if (wintype=="screen2") window.open(url, wintype,'');
}


// Cookie Functions
function setStrData(instr, name, value) {
	var pattern = new RegExp(name + "=([^;])*","gi");
	var str;
	instr = unescape(instr);
	if (!instr || instr=='null' || instr=='' || instr=='undefined') {
		str = name + "=" + escape(value) + '; ';
		return escape(str);
	}
	/*alert(instr);
	alert(pattern.test(instr));*/
	if (pattern.test(instr)) {
		instr = instr.replace(pattern, name + "=" + escape(value));
	} else {
		instr = instr + name + '=' + value + '; ';
	}
	return escape(instr);
	//alert(inst.replace(pattern, "key=" + pairs[1]); // change key value
}
function getStrData(instr, name) {
	var pattern = new RegExp(name + "=([^;])*","gi");
	if (!instr || instr=='null' || instr=='' || instr=='undefined') {
		return instr;
	}
	var results = pattern.exec(instr);
	if (results && results.length > 0) {
		return (unescape(unescape(results[0]))).substr(name.length+1);
	}
	return instr;
}
// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current session)
// [path] - path for which the cookie is valid (defaults to path of calling document)
// [domain] - domain for which the cookie is valid (defaults to domain of calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure, subname) {
    //alert(name + ' | ' + value + ' | ' + expires + ' | ' + path + ' | ' + domain + ' | ' + secure + ' | ' + subname);
	if (subname) {
			var value_str = getCookie(name);
			//value_str = value_str.replace(/\?/gi, '\\\?');*/
			//alert('before :' + value_str);
			value = setStrData(value_str, subname, value);
			//alert('after: ' + value);
	}
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie does not exist
function getCookie(name, subname) {
	var dc = document.cookie;
	//alert('Running getCookie\nname: ' + name + '\nsubname: ' + subname);
	if (subname) {
			//alert('before g: ' + dc);
			dc = getStrData(dc, name);
			name = subname;
			//alert('after g, subname=' + subname  + ': ' + dc);
	}
  var prefix = name + "=";
  var begin;
  if (dc.substring(0,prefix.length)==prefix) {
    //alert(dc.substring(0,prefix.length));
    begin = 0;
  }
  else {
     begin = dc.indexOf("; " + prefix);
     if (begin == -1) {
       begin = dc.indexOf(prefix);
       if (begin != 0) return null;
     } else
       begin += 2;
  }
  var end = dc.indexOf(";", begin);
  if (end == -1)
    end = dc.length;

  return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create cookie)
// * path and domain default if assigned null or omitted if no explicit argument proceeds
function deleteCookie(name, path, domain) {
  if (getCookie(name)) {
    document.cookie = name + "=" + 
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

var expdate = new Date(); 
expdate.setTime(expdate.getTime() + 20*24*60*60*1000); 

function setVersaCookie(page, name, value) {
	var newStr;
	name = name.replace(/\?/gi, '\\\?');
	var re = new RegExp(name + "=([^&]*)","gi");
	
	newStr = getCookie('page' + page);
	if (newStr == null)			 // if no cookies for this page, set this one as only one
		newStr = name + '=' + value;
		
	else if (newStr.match(re))	// if this name value, already set, update
		newStr.replace(re, name + '=' + value);
	else						// if this name value not present in cookie, add it to end
		newStr = newStr + '&' + name + '=' + value;
	
	var expdate = new Date(); 
	expdate.setTime(expdate.getTime() + 20*24*60*60*1000); 

	setCookie('page' + page, newStr, expdate);
}

function deleteVersaCookie(page, name) {
	var newStr;
	var re = new RegExp(name + "=[^&]*","gi")

	newStr = getCookie('page' + page);
	if (newStr.match(re)) {	// if this name value, already set, delete it
		newStr = newStr.replace(re, '');
		newStr = newStr.replace(/&&/gi, '&');
	}
	setCookie('page' + page, newStr, expdate);
	
}
function openFullScreen() {
					var width, height;
					if (screen.availHeight) { 
						width = screen.availWidth-5;
						height = screen.availHeight-60;
					} else if (window.outerWidth) {
						width = window.outerWidth;
						height = window.outerHeight;
					}
					//alert(height);
			
			var win = window.open(window.location, 'FullScreen', 'top=0, left=0, location=no, titlebar=yes, menubar=no, width=' + width + ', height=' + height + ', resizable=yes, scrollbars=yes, status=yes, toolbar=no');
			win.resizeTo( screen.availWidth, screen.availHeight );

}
// *************************************************************
// Persist Search Values
// add 'onchange="base_persistSearchValues(this);"' to any fields that you want the values to persist for
// add 'onload_actions.push('base_initSearchValues();');' to the page
// values will be stored in the 'saved_criteria' cookie
// *************************************************************
function base_persistSearchValues(obj){
    var objID = obj.id;
    var objValue = obj.value;
    setCookie('saved_criteria', objValue, null, null, null, null, objID);
}

function base_initSearchValues(){
	//debugger;
	if (getCookie('saved_criteria')){
		var cookieVals = unescape(getCookie('saved_criteria')).substring(0, unescape(getCookie('saved_criteria')).length-2).split(';')
		for (var i=0; i < cookieVals.length; i++){
			var currentCookie=cookieVals[i].split('=')
			while(currentCookie[0].charAt(0)==' ') currentCookie[0]=currentCookie[0].substring(1,currentCookie[0].length);
			//modified by krish 06/09/08 to account for currentCookie[1] =  null
			if (document.getElementById(currentCookie[0]) && !(null == currentCookie[1] || null === currentCookie[1] || 'null' == currentCookie[1] || 'null' === currentCookie[1])) {
				document.getElementById(currentCookie[0]).value = unescape(currentCookie[1]);
				//modified by krish 06/09/08 to account for missing values in dropdownlists
				if(document.getElementById(currentCookie[0]).value == '' && document.getElementById(currentCookie[0]).tagName == 'SELECT' && document.getElementById(currentCookie[0]).length > 0)
					document.getElementById(currentCookie[0]).selectedIndex = 0;
			}
		}
	
	if (document.getElementById('UDFStore')) 
		logUDFVals();
	}
}



/*--krish--
enable auto-run-search if stickies exist in 2-pane search pages
*/
function checkExistStickies(){
//debugger;
	if (getCookie('saved_criteria')){
		var cookieVals = unescape(getCookie('saved_criteria')).substring(0, unescape(getCookie('saved_criteria')).length-2).split(';')
		for (var i=0; i < cookieVals.length; i++){
			var currentCookie=cookieVals[i].split('=')
			while(currentCookie[0].charAt(0)==' ') currentCookie[0]=currentCookie[0].substring(1,currentCookie[0].length);
			if (document.getElementById(currentCookie[0]) && currentCookie[1] != 'All' && currentCookie[1].replace('/^\s+|\s+$/g', '') != '' 
				&& !(null == currentCookie[1] || null === currentCookie[1] || 'null' == currentCookie[1] || 'null' === currentCookie[1])) {
				return true;
				break;
			}
		}
		return false;
	}
}
// *************************************************************
// Clear and Collapse/ Expand Criteria
// Used to clear out the search criteria on the page and to hide or show search criteria
// to use, add the following menu to the page
//	<menucontent key="main">
//		<menubar>
//			<menuitem display="Criteria" menuID="66" action="add"/>
//		</menubar>
//		<menu key="criteria" ID="66" action="add">
//			<menuitem ID="menuccriteria" action="add" display="Clear Criteria" title="Clear Criteria" pfx="21" cmd="clear_criteria();"/>
//			<menuitem ID="menuhscriteria" action="add" display="Hide Criteria" title="Hide Criteria" pfx="21" cmd="collapse_expand();"/>
//		</menu>
//	</menucontent>
//
// and wrap the criteria that is to be hidden in the following
//	<div id="collapse_expand_criteria">
//		<div>
//		</div>
//	</div>
// *************************************************************
var c='0';
var searchIFrame;
var searchIFrameInfo;

function clear_criteria(){
//debugger;
	selectElements = document.getElementsByTagName('select');
	for (var i=0; i < selectElements.length; i++){

	if((selectElements[i].getAttribute('def')) && 
		selectElements[i].getAttribute('def') != 'undefined' && 
		selectElements[i].getAttribute('def') !=null && 
		selectElements[i].getAttribute('def') !=''){
			selectElements[i].value = selectElements[i].getAttribute('def')
		}
		else{
			//Updated: Jeremy 10 July 2009
			if(selectElements[i].options.length == 1)
				selectElements[i].options[0].selected = true;
			else if(!selectElements[i].disabled)
				selectElements[i].value = 'All';
		}
		
		// special case for text word search options
		if(selectElements[i].getAttribute('id') == 'opt_textwords')
			selectElements[i].value = 'any';
			
		// special case for item bank options
		if(selectElements[i].getAttribute('id') == 'input_owner')
			selectElements[i].value = '00|All';

			if(selectElements[i].getAttribute('size')>1){
			var opts = selectElements[i].options
			opts[0].selected = true
			for (var j=1; j < opts.length; j++){
				opts[j].selected = false;
			}
		}
		}
	
	textElements = document.getElementsByTagName('input');
	for (var i=0; i < textElements.length; i++){
		if (textElements[i].type == 'text' && textElements[i].id.substring(0,6) == 'input_')	{
			textElements[i].value = '';
		}
		
	}
	
	setCookie('saved_criteria', '');
	setCookie('SGSC', '');
	/*selectElements = document.getElementsByTagName('select');
	for (var i=0; i < selectElements.length; i++){
		if(selectElements[i].getAttribute('def')!='')
			selectElements[i].value = selectElements[i].getAttribute('def')
		else
			selectElements[i].value = 'All';
		if(selectElements[i].getAttribute('size')>1){
			var opts = selectElements[i].options
			opts[0].selected = true
			for (var j=1; j < opts.length; j++){
				opts[j].selected = false;
			}
		}
	}
	
	textElements = document.getElementsByTagName('input');
	for (var i=0; i < textElements.length; i++){
		if (textElements[i].type == 'text' && textElements[i].id.substring(0,6) == 'input_')	textElements[i].value = '';
	}
	
	setCookie('saved_criteria', '');
	setCookie('SGSC', '');*/
}

function collapse_expand()
			{
				switch(c)
				{
				case '0':
					new Effect.SlideUp('collapse_expand_criteria', {duration: 0.5});
					c = '1';
					document.getElementById('menuhscriteria').innerHTML = '<span class="menuItemText">Show Criteria</span>';
					document.getElementById('menuhscriteria').setAttribute('title', 'Show Criteria');
					doOnresizeActions();
					break;
				case '1':
					new Effect.SlideDown('collapse_expand_criteria', {duration: 0.5});
					setTimeout("c = '0';", 500);
					var temp_str = "document.getElementById('menuhscriteria').innerHTML = '<span class="+"menuItemText"+">Hide Criteria</span>';";
					setTimeout(temp_str, 500);
					setTimeout("document.getElementById('menuhscriteria').setAttribute('title', 'Hide Criteria');", 500);
					setTimeout("doOnresizeActions();", 510);
					break;
				}
			}
			
			function collapse_expand_portal()
			{
				switch(c)
				{
				case '0':
					new Effect.SlideUp('collapse_expand_criteria', {duration: 0.5});
					//$j("#collapse_expand_criteria").slideUp(1000);
					c = '1';
					document.getElementById('imgCollapseSearchCriteria').src = 'images/downarrow.gif';
					document.getElementById('imgCollapseSearchCriteria').alt = 'Show Search Criteria';
					doOnresizeActions();
					break;
				case '1':
					new Effect.SlideDown('collapse_expand_criteria', {duration: 0.5});
					//$j("#collapse_expand_criteria").slideDown(1000);
					setTimeout("c = '0';", 500);
					var temp_str = "document.getElementById('imgCollapseSearchCriteria').src = 'images/uparrow.gif';";
					setTimeout(temp_str, 500);
					document.getElementById('imgCollapseSearchCriteria').alt = 'Collapse Search Criteria';
					setTimeout("doOnresizeActions();", 510);
					break;
				}
			}
			
			function collapse_expand_menu()
			{
				switch(c)
				{
				case '0':
					new Effect.Fade('collapse_expand_criteria', {duration: 0.5});
					document.getElementById('menu_x').style.width = '0px';
					
					c = '1';
					document.getElementById('imgCollapseSearchCriteria').src = 'images/rightarrow.gif';
					document.getElementById('imgCollapseSearchCriteria').alt = 'Show Menu';
					setTimeout("doOnresizeActions();", 510);
					break;
				case '1':
					
					new Effect.Appear('collapse_expand_criteria', {duration: 0.5});
					//document.getElementById('menu_x').style.width = '300px';
					//document.getElementById('collapse_expand_criteria').style.width = '300px';
					
					setTimeout("c = '0';", 500);
					var temp_str = "document.getElementById('imgCollapseSearchCriteria').src = 'images/leftarrow.gif';";
					setTimeout(temp_str, 500);
					document.getElementById('imgCollapseSearchCriteria').alt = 'Hide Menu';
					setTimeout("doOnresizeActions();", 510);
					break;
				}
			}
			function collapse_expand_menu_modal()
			{
				switch(c)
				{
				case '0':
					new Effect.Fade('collapse_expand_criteria_modal', {duration: 0.5});
					c = '1';
					document.getElementById('imgCollapseModalCriteria').src = 'images/rightarrow.gif';
					document.getElementById('imgCollapseModalCriteria').alt = 'Show Menu';
					setTimeout("doOnresizeActions();", 510);
					break;
				case '1':
					new Effect.Appear('collapse_expand_criteria_modal', {duration: 0.5});
					setTimeout("c = '0';", 500);
					var temp_str = "document.getElementById('imgCollapseModalCriteria').src = 'images/leftarrow.gif';";
					setTimeout(temp_str, 500);
					document.getElementById('imgCollapseModalCriteria').alt = 'Hide Menu';
					setTimeout("doOnresizeActions();", 510);
					break;
				}
			}
// *************************************************************
// resizeSearchIFrame
// Used to resize the search results IFrame  whenever the window is resized 
// as well as when the search criteria is hidden or shown with the above function
// *************************************************************
function resizeSearchIFrame(searchIFrame) {
//debugger;
	if(document.getElementById(searchIFrame)){
		var searchIFrameInfo;
		if(document.getElementById('collapse_expand_criteria')){searchIFrameInfo=[findPos(document.getElementById(searchIFrame)), [document.getElementById('collapse_expand_criteria').offsetHeight,0]];}
		else {searchIFrameInfo=[findPos(document.getElementById(searchIFrame)), [0,0]];}

		windowHeight = findWindowSize();
		if(c=='1'){
			//alert('Open\nCalculated Height: ' + (windowHeight[1]-searchIFrameInfo[0][1]+searchIFrameInfo[1][0]-5));
			if((windowHeight[1]-searchIFrameInfo[0][1]+searchIFrameInfo[1][0]-5)>100) {document.getElementById(searchIFrame).style.height = windowHeight[1]-searchIFrameInfo[0][1]+searchIFrameInfo[1][0]-5;} 
			else {document.getElementById(searchIFrame).style.height = 100;}
			//alert('iframe height: ' +document.getElementById(searchIFrame).style.height);
		}
		if(c=='0'){
			//alert('Closed\nCalculated Height: ' + (windowHeight[1]-searchIFrameInfo[0][1]-5));
			if((windowHeight[1]-searchIFrameInfo[0][1]-5)>100){document.getElementById(searchIFrame).style.height = windowHeight[1]-searchIFrameInfo[0][1]-5;} 
			else {document.getElementById(searchIFrame).style.height = 100;}
			//alert('iframe height: ' +document.getElementById(searchIFrame).style.height);
			
			//begin krish 06/11 to resize the frame width along with the frame height above
			//if((windowHeight[0]-searchIFrameInfo[0][0]-5)>100){document.getElementById(searchIFrame).style.width = windowHeight[0]-searchIFrameInfo[0][0]-5;} 
			//else {document.getElementById(searchIFrame).style.width = 100;}
			//end krish 06/11 to resize the frame width along with the frame height above
		}
	}
}
// *************************************************************
// resizeportaliframe
// Used to resize the portal iframe  whenever the window is resized 
// *************************************************************
//var portalIFrame;
//var portalIFrameInfo;
function resizePortalIFrame() {
	var portalFrameList = ['Main_Panel','home_Panel','curriculum_Panel','instruction_Panel','assessment_Panel','utilization_Panel','support_Panel'];
	
	for(var i =0; i<portalFrameList.length; i++)
	{
		var portalIFrame = portalFrameList[i];
		if(document.getElementById(portalIFrame)&&portalIFrame==frameList[frameList.length-1][0])
		{
			var portalIFrameInfo = findPos(document.getElementById(portalIFrame));
			var windowHeight = findWindowSize();
			
			if((windowHeight[1]-portalIFrameInfo[1]-30)>100) {document.getElementById(portalIFrame).style.height = windowHeight[1]-portalIFrameInfo[1]-30;} 
			
			/*if(c=='1'){
				if((windowHeight[1]-portalIFrameInfo[0][1]+portalIFrameInfo[1][0]-30)>100) {document.getElementById(portalIFrame).style.height = windowHeight[1]-portalIFrameInfo[0][1]+portalIFrameInfo[1][0]-30;} 
				else {document.getElementById(portalIFrame).style.height = 100;}
			}
			if(c=='0'){
				if((windowHeight[1]-portalIFrameInfo[0][1]-30)>100){document.getElementById(portalIFrame).style.height = windowHeight[1]-portalIFrameInfo[0][1]-30;} 
				else {document.getElementById(portalIFrame).style.height = 100;}
			}*/
		}
	}
}
//onload_actions.push("resizePortalIFrame();");
//window.onresize=resizePortalIFrame;

// *************************************************************
// resizedivmenu
// Used to resize the portal menu div  whenever the window is resized 
// *************************************************************
var menuDiv;
var menuDivInfo;
function resizemenuDiv() {
//alert('hi');
	menuDiv = 'divmenu';
	if(document.getElementById(menuDiv))
	{
		menuDivInfo=[findPos(document.getElementById(menuDiv)), [0,0]];
		windowHeight = findWindowSize();
		//if(c=='1'){
			if((windowHeight[1]-menuDivInfo[0][1]+menuDivInfo[1][0]-30)>100) {document.getElementById(menuDiv).style.height = windowHeight[1]-menuDivInfo[0][1]+menuDivInfo[1][0]-30;} 
			else {document.getElementById(menuDiv).style.height = 100;}
		/*}
		if(c=='0'){
			if((windowHeight[1]-menuDivInfo[0][1]-30)>100){document.getElementById(menuDiv).style.height = windowHeight[1]-menuDivInfo[0][1]-30;} 
			else {document.getElementById(menuDiv).style.height = 100;}
		}*/
	}
}

// *************************************************************
// Ajax Functions
// *************************************************************

function AjaxSave() {
      //alert('AjaxSave');
	  //debugger;
      divMessage.innerHTML='Saving...please wait.';
      readform();
      if (document.BeforeBGSave)   {
	BeforeBGSave();	//author can create this function in the Page Template 
   	}
	else try {if(BeforeBGSave) BeforeBGSave();} catch(e) {}   //needed try-catch after finding AfterBGSave dynamically added via subpage
								//not visible with document.AfterBGSave but otherwise this check throws an error.

      //var posturl = 'pageactions.asp?action=update2&amp;formatoption=refresh&amp;retrievemode=page';
      var posturl = 'bgsave.asp';
      var pars = Form.serialize('frmUpdate'); 
      //var myAjax = new Ajax.Request(posturl, { method: 'post', postBody: pars, onFailure: function (){SaveFailed();}, onSuccess: function (){SaveComplete();}});
      var myAjax = new Ajax.Updater('divMessage', posturl, { method: 'post', parameters: pars, onComplete: function (){if($('spin')) {$('spin').style.display='none';} AfterSave(); } });
      return true;
}

function AfterSave() {
 
 if (document.AfterBGSave) { 	
	AfterBGSave(); //author can create this function in the Page Template
 } 
 else 
 {
	try 
	{		
		if(AfterBGSave) 
		{			
			AfterBGSave();
		}
	} catch(e) {}  //needed try-catch after finding AfterBGSave dynamically added via subpage
				   //not visible with document.AfterBGSave but otherwise this check throws an error.
}

 AutoAdjustElementTitle();
 //if (document.AutoAdjustElementTitle) {AutoAdjustElementTitle(); }

 if (document.frmSelections) document.frmSelections.Saved.value = '1';

 PotentialRefresh();
}

function AutoAdjustElementTitle() {
 //alert('AutoAdjustElementTitle in Javascript.js');
 var DivTitle = document.getElementById('divPageNameFirst');
 var PageTitle = getElementByName('Title');
 if (DivTitle && PageTitle){
	DivTitle.innerHTML = getElementByName('Template').value + ': ' + PageTitle.value;
	}
 /*
 if (Page && Page=='3201') { //Instructor
   var fname = (getElementByName('firstname').value);
   var lname = (getElementByName('lastname').value);
   var DivTitle = document.getElementById('divPageNameFirst');
   if ((DivTitle)&&(fname)){
	DivTitle.innerHTML = getElementByName('Template').value + ': ' + fname+' '+lname;
	}
 }
 */

}

function ajaxRefresh(url,target,SQLID)
{	
	//alert(url);
	//$(target).innerHTML = '<span>Loading...Please Wait</span>';
	//$(target).innerHTML = url;
	
	url =  url + '&ajaxrnd='+ (Math.random() * Date.parse(new Date())) ;
	
	if ( $('spin_'+SQLID) ) $('spin_'+SQLID).style.visibility = 'visible';
	
	var myAjax = new Ajax.Updater(target, url, { method: 'get', parameters: "", 
	                              onComplete: function (r) 
								  {													  
									if ( $('XMLRequestJava_'+SQLID) )
									{
										//alert($('XMLRequestJava').value );
									    eval( $('XMLRequestJava_'+SQLID).value );
									}
									
									if ( $('spin_'+SQLID) ) $('spin_'+SQLID).style.visibility = 'hidden';
									
								  } });
}

function ajaxRefreshExecute(executeID, optParms, runOnComplete)
{ 
//debugger;
	if(optParms==null) optParms = '';
	var url = 'fastsql_v2_direct.asp';
	//var originalUrl = window.location.href.substr(window.location.href.indexOf("?")+1)//modified krish 08/08/08
	var originalUrl = window.location.href;
	originalUrl = originalUrl.replace('?id=', '?originalId=')
	originalUrl = originalUrl.replace('&id=', '&originalId=')
	originalUrl = originalUrl.replace('?ID=', '?originalId=')
	originalUrl = originalUrl.replace('&ID=', '&originalId=')
	
	//modified krish 08/08/08
	originalUrl = originalUrl.substr(originalUrl.indexOf("?")+1)
	
	var pars = 'id=' + executeID + '&' + originalUrl
			 + optParms
			 + '&ajaxrnd='+ (Math.random() * Date.parse(new Date()));
	
	pars = replaceAll(pars,"&&","&");
	pars = replaceAll(pars,"&amp;","&");
	
	var target = "Execute"+executeID;
	
	url = url + '?' + pars; 
	//alert(url.indexOf("xID"));
	if(url.indexOf("xID") == -1)
	{
		if(window.location.href.indexOf("xID") != -1)
		{
			url = url + '&xID='+getURLParm('xID', '');
		}
	}
	//debugger;
	//document.write('','target ' + target + '\nurl: ' + url + '\npars: ' + pars);
	//response.end;

	document.body.style.cursor = "wait";
	if ( $('spin_'+executeID) ) $('spin_'+executeID).style.visibility = 'visible';
	if ($('displayLoadingMessage')) $(target).InnerHTML = $('displayLoadingMessage').value;
	var myAjax2 = new Ajax.Updater(target, url, { method: 'get', //asynchronous: async,//parameters:'',
	                              onComplete: function (r) 
								  {
								  //debugger;
									//alert(r.responseText);
									document.body.style.cursor = "";
									if ( $('spin_'+executeID) ) $('spin_'+executeID).style.visibility = 'hidden';
									if (runOnComplete) eval(runOnComplete);
								  }
								  });
}

function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );
    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }
    return str;
}

//function ajaxPageActions(url,tablenames,async,optParms)
function ajaxPageActions(url,tablenames,async,refreshOptParms,refreshOnComplete)
{	

	if(async==null) async = true;
	if(async==false && tablenames){
		var updatetables = tablenames.split(",");
		for( var k=0; k< updatetables.length; k++ ){
			if(updatetables[k].indexOf('Execute') > - 1){
				document.getElementById(updatetables[k]).innerHTML = ' Loading... ';
			}
		}
	}
	
	var extraPars = (document.getElementById('frmSelections')) ? Form.serialize('frmSelections') : ''; 
	
	//var extraPars = url.substring(url.indexOf("?")+1);
			
	//extraPars = extraPars + '&FormatOption=' + escape(getElementByName('FormatOption').value) + '&CurrURL=' + escape(getElementByName('CurrURL').value) + '&Saved=' + escape(getElementByName('Saved').value) + '&EndAction=' + escape(getElementByName('EndAction').value) + '&iframe_hits=' + escape(getElementByName('iframe_hits').value) + '&newLoad=' + escape(getElementByName('newLoad').value) + '&Page=' + escape(getElementByName('Page').value) + '&PageID=' + escape(getElementByName('PageID').value) + '&LastUpdated=' + escape(getElementByName('LastUpdated').value) + '&AddEntryOnLinkPaste=' + escape(getElementByName('AddEntryOnLinkPaste').value);
	extraPars = extraPars + '&ajaxrnd='+ (Math.random() * Date.parse(new Date())) ;
	url = url + "&" + extraPars;
	
	url = replaceAll(url,"&amp;","&");
	url = replaceAll(url,"&&","&");
	
	//$('divMessage').innerHTML = url;
	//return;
	var target = 'divMessage'	

	var myAjax = new Ajax.Updater(target, url, { method: 'post', //asynchronous: async, //parameters: '',
	                              onComplete: function (d) 
								  {
								  //debugger;
									//alert(d.responseText);
									if ( tablenames )
									{
										var tables = tablenames.split(",");
										
										for( var k=0; k< tables.length; k++ )
										{
											//alert(tables[k]);
											if(tables[k].indexOf('Execute') > - 1)
											{
												ajaxRefreshExecute(tables[k].substring(7),refreshOptParms,refreshOnComplete);
											}
											else
											{
												RefreshTable(tables[k]);
											}
										}
									}								
								  },
								  onException: function(d, e)
								  {
									// Added to fix a Firefox bug - Reload the whole page when there is an exception
									//alert('Ajax Pageactions Error\n\n' + e);
									$(target).innerHTML = 'Updates applied.';
									//window.location.reload();
									if ( tablenames )
									{
										var tables = tablenames.split(",");
										
										for( var k=0; k< tables.length; k++ )
										{
											//alert(tables[k]);
											if(tables[k].indexOf('Execute') > - 1)
											{	
												var t = setTimeout('ajaxRefreshExecute(\''+ tables[k].substring(7) + '\');',2000);
											}
											else
											{   
												RefreshTable(tables[k]);											
											}
										}
									}								
								  }
								  });

}

function RefreshTable(tablename)
{
	var tableObj;
	var tbls = document.getElementsByTagName("TABLE");
	
	for( var i=0; i < tbls.length; i++ )
	{
		if (tbls[i].getAttribute("TableName"))
		{
			if (tbls[i].getAttribute("TableName") == tablename)
			{
				tableObj = tbls[i];
				break;
			}
		}
	}
	
	//Now we have the table-- lets find the Refresh Link in previousSibling (center)
	if (tableObj) 
	{
		var aTags = (tableObj.previousSibling).getElementsByTagName("A");
		
		for( var j=0; j < aTags.length; j++ )
		{		
			if (aTags[j].getAttribute("title"))
			{
				if (aTags[j].getAttribute("title") == "Refresh Results")
				{
					aTags[j].click();
					break;
				}
			}
		}
	}
}

function changecss(myclass,element,value) {
	var CSSRules
	if (document.all) {
		CSSRules = 'rules'
	}
	else if (document.getElementById) {
		CSSRules = 'cssRules'
	}
	
	for (var j = 0; j < document.styleSheets.length; j++ )
	{
		if ( document.styleSheets[j] )
		{
			for (var i = 0; i < document.styleSheets[j][CSSRules].length; i++) {
				var classText = document.styleSheets[j][CSSRules][i].selectorText;
				if (classText.toLowerCase().indexOf(myclass.toLowerCase()) > -1) {					
					document.styleSheets[j][CSSRules][i].style[element] = value
				}
			}	
		}
	}
}


// *************************************************************
// Positioning and Size Functions
// *************************************************************
function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function findWindowSize(){
	var x = y = 0;
	if (self.innerHeight) { // all except Explorer
		x = self.innerWidth;
		y = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight){ // Explorer 6 Strict Mode
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	return [x,y]
}

function findPageSize(){
	var x = y = 0;
	if (window.innerHeight && window.scrollMaxY) {// Firefox
		x = window.innerWidth + window.scrollMaxX;
		y = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		x = document.body.scrollWidth;
		y = document.body.scrollHeight;
	} else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
		x = document.body.offsetWidth;
		y = document.body.offsetHeight;
	}
	return [x,y];
}

function findScrollOffset(){
	var x = y = 0;
	if (self.pageYOffset){ // all except Explorer
		x = self.pageXOffset;
		y = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
		x = document.documentElement.scrollLeft;
		y = document.documentElement.scrollTop;
	} else if (document.body){ // all other Explorers
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}
	return [x,y]
}

// *************************************************************
// *************************************************************

// Highlights search labels when the input tag is not set to its default value
function highlightLabels(){
	
	// Checks all select tags
	var sel = document.getElementsByTagName('select');
	for(var i=0; i<sel.length; i++){
		var labelID = 'lbl_' + sel[i].getAttribute('id').substring(6);
		
		if(sel[i].value != sel[i].getAttribute('def')) {
			if (document.getElementById(labelID))
				document.getElementById(labelID).style.backgroundColor = '#99FF99';
		}
		else {
			if (document.getElementById(labelID))
				document.getElementById(labelID).style.backgroundColor = '';
		}
	}
	
	// Checks all input tags
	var txt = document.getElementsByTagName('input');
	for(var i=0; i<txt.length; i++){
		// TEXT INPUT
		if (txt[i].getAttribute('type') == 'text') {
			var labelID = 'lbl_' + txt[i].getAttribute('id').substring(6);
			
			if(txt[i].value != txt[i].getAttribute('def')) {
				if (document.getElementById(labelID))
					document.getElementById(labelID).style.backgroundColor = '#99FF99';
			}
			else {
				if (document.getElementById(labelID))
					document.getElementById(labelID).style.backgroundColor = '';
			}
		}
		// CHECKBOX INPUT
		if (txt[i].getAttribute('type') == 'checkbox') {
			var labelID = 'lbl_' + txt[i].getAttribute('id').substring(6);
			
			if(txt[i].getAttribute('checked')) {
				if (document.getElementById(labelID))
					document.getElementById(labelID).style.backgroundColor = '#99FF99';
			}
			else {
				if (document.getElementById(labelID))
					document.getElementById(labelID).style.backgroundColor = '';
			}
		}
	}
	
}

function disableInputs(){
	
	if (document.getElementById('input_resultview') && document.getElementById('input_resultview').checked){
		// Disable all select tags
		var sel = document.getElementsByTagName('select');
		for(var i=0; i<sel.length; i++){
			if(sel[i].getAttribute('dis')=='yes')
				sel[i].disabled=true;
		}
		
		// Disable all input tags
		var txt = document.getElementsByTagName('input');
		for(var i=0; i<txt.length; i++){
			// TEXT INPUT
			if (txt[i].getAttribute('type') == 'text') {
				if(txt[i].getAttribute('dis')=='yes')
					txt[i].disabled=true;
			}
			// CHECKBOX INPUT
			if (txt[i].getAttribute('type') == 'checkbox' && txt[i].getAttribute('id') != 'input_resultview') {
				if(txt[i].getAttribute('dis')=='yes')
					txt[i].disabled=true;
			}
		}
	}
	else {
		// Enable all select tags
		var sel = document.getElementsByTagName('select');
		for(var i=0; i<sel.length; i++){
			if(sel[i].getAttribute('dis')=='yes')
				sel[i].disabled=false;
		}
		
		// Enable all input tags
		var txt = document.getElementsByTagName('input');
		for(var i=0; i<txt.length; i++){
			// TEXT INPUT
			if (txt[i].getAttribute('type') == 'text') {
				if(txt[i].getAttribute('dis')=='yes')
					txt[i].disabled=false;
			}
			// CHECKBOX INPUT
			if (txt[i].getAttribute('type') == 'checkbox' && txt[i].getAttribute('id') != 'input_resultview') {
				if(txt[i].getAttribute('dis')=='yes')
					txt[i].disabled=false;
			}
		}
	}
}

function getURLVariable( name )
{  
	var regexS = "[\\?&]"+name+"=([^&#]*)";  
	var regex = new RegExp( regexS );  
	var tmpURL = window.location.href;  
	var results = regex.exec( tmpURL );  
	if( results == null )    
		return "";  
	else    
		return results[1];
}


function getWeekStartDate()
{
	var now = new Date();
	var nowMonth = now.getMonth();
	var nowYear = now.getUTCFullYear();
	nowYear += (nowYear < 2000) ? 1900 : 0;
	var nowDayOfWeek = now.getDay();
	var nowDay = now.getDate();
	var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
	var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
	return formatDate(weekStartDate);
}

function getWeekEndDate()
{
	var now = new Date();
	var nowMonth = now.getMonth();
	var nowYear = now.getUTCFullYear();
	nowYear += (nowYear < 2000) ? 1900 : 0;
	var nowDayOfWeek = now.getDay();
	var nowDay = now.getDate();
	var weekStartDate = new Date(nowYear, nowMonth, nowDay - nowDayOfWeek);
	var weekEndDate = new Date(nowYear, nowMonth, nowDay + (6 - nowDayOfWeek));
	return formatDate(weekEndDate); 
}

function formatDate(date) 
{
	var mymonth = date.getMonth()+1;
	var myweekday = date.getDate();
	var myyear = date.getYear();
	return (mymonth + "/" + myweekday + "/" + myyear);
}

function pageactionWithResponse(url){
	//var url = '';
	//debugger;
	url = url + '&ajaxrnd='+ (Math.random() * Date.parse(new Date()));
	url = replaceAll(url,"&amp;","&");
	url = replaceAll(url,"&&","&");
	var target = 'divMessage'	
	var myAjax = new Ajax.Updater(target, url, { method: 'post', asynchronous: false, //parameters: '',
	                              onComplete: function (d) 
								  {	//alert(document.getElementById('divMessage').innerHTML);
									//parent.currSLID = document.getElementById('divReturnMessage').innerHTML;								
								  },
								  onException: function(d, e)
								  {
									// Added to fix a Firefox bug - Reload the whole page when there is an exception
									//alert('Ajax Pageactions Error\n\n' + e);
									$(target).innerHTML = 'Updates applied.';
									//window.location.reload();
																	
								  }
								  });

	myAjax.updateContent(); //This line is workaround to error in prototype.  When run sync, the target is not getting updated without this.

	var returnMessage= document.getElementById('divMessage').innerHTML.toString();
	//alert(returnMessage.indexOf('Error'));
	if(returnMessage.indexOf('Error') != -1)
		return false;
	else
		return true;
}
//document.getElementById('element').disabled does not work in firefox. Use below
function disableElements(obj, disable){
if(obj)
{
  if(disable){
	obj.disabled=true;
    var onclick = obj.getAttribute("onclick");
    if(onclick && onclick != "" && onclick != null){
       obj.setAttribute('onclick_bak', onclick);
    }
    obj.removeAttribute('onclick');
    obj.style.color="gray";
  }
  else{
	obj.disabled=false;
	if(obj.getAttribute("onclick_bak"))
	{
		obj.setAttribute('onclick', obj.attributes['onclick_bak'].nodeValue);
	}
	obj.style.color="";
  }
  }
}
// *************************************************************
// TABLE SORT FUNCTIONS
// *************************************************************

var ua = navigator.userAgent.toLowerCase()
var isIE = ( (ua.indexOf('msie') != -1) && (ua.indexOf('opera') == -1) && (ua.indexOf('webtv') == -1) ); 
var css_offset_ff = isIE ? 0 : 1;
var css_offset_ie = isIE ? 1 : 0;
			
// -->
//document.write('<SCRIPT LANGUAGE="JavaScript" SRC="js/date.js"></SCRIPT>');
//document.write('<SCRIPT LANGUAGE="JavaScript" SRC="js/button_gen.js"></SCRIPT>');
//document.write('<SCRIPT LANGUAGE="JavaScript" SRC="js/simple_server_comm.js"></SCRIPT>');
//document.write('<SCRIPT LANGUAGE="javascript1.1" SRC="JavascriptSpellCheck/Include.js" TYPE="text/javascript"></SCRIPT>');


// ******** pulled in javascriptspellcheck/include.js **********************************
/*///////////////////////////////////////////////////////// 
JAVASCRIPT SPELL CHECK (C)2006  JAVASCRIPTSPELLCHECK.COM  
/////////////////////////////////////////////////////////*/
function JavaScriptSpellCheck(strName) {
	/* Default Values - May be ammended */
	var setupPath = "javascriptspellcheck/";
	var languages = "English (International)";
	var windowLanguage = "EN";
	var useServerSession = true;
	var hideSummary = false;
	var ignoreAllCaps = true;
	var ignoreWebAddresses = true;
	var ignoreNumbers = true;
	var newSentanceOnEachNewLine = false;
	var checkGramar = true;
	var caseSensitive = true;
	var externalCSS = "";
	/* End of Default Values          */
	/* Do Not Edit Below This Line*/
	this.uid = uid;
	this.setupPath = setupPath;
	this.languages = languages;
	this.useServerSession = useServerSession;
	this.hideSummary = hideSummary;
	this.ignoreAllCaps = ignoreAllCaps;
	this.ignoreWebAddresses = ignoreWebAddresses;
	this.ignoreNumbers = ignoreNumbers;
	this.newSentanceOnEachNewLine = newSentanceOnEachNewLine;
	this.checkGramar = checkGramar;
	this.caseSensitive = caseSensitive;
	this.externalCSS = externalCSS;
	this.windowLanguage = windowLanguage;
	this.dataMode = 'normal';
	var uid = UID();
	function ajaxTest() {
		var xmlhttp = false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		 	try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		 } catch (e) {
		  try {
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) {
		   xmlhttp = false;
		  }
		 }
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			try {
				xmlhttp = new XMLHttpRequest();
			} catch (e) {
				xmlhttp = false;
			}
		}
		if (xmlhttp) {
			return true;
		}
		return false;
	}
	function ajaxCallBack(result) {
		//
	}
	function spellCheckWindowTest() {
		if (!ajaxEnabled) {
			return null;
		}
		var strword = '';
		
		for (var i=0; i<arguments.length; i++) {
			var testArg = arguments[i].replace('window.', '');
			strword += window.JavaScriptSpellCheck__PostForward_API(testArg)+' ';
		}
	    	
		var ajaxURL = spellURL('', this)+"&ajax=true&word="+escape(strword);
		var result = getXMLFromURL(ajaxURL, false);
		return result;
	}
	getXMLFromURL;
	function spellCheckWindow() {
		var strFields = '';
		for (i=0; i<arguments.length; i++) {
			if (strFields) {
				strFields = strFields+",";
			}
			arguments[i] = arguments[i].replace('window.', '');
			strFields = strFields+arguments[i];
		}
		window['FN'+this.uid] = this.callBack;
		window.JS_SpellWin_ID = window.open(spellURL(strFields, this), 'JS_SpellWin', 'width=510, height=330, scrollbars=no');
		return true;
	}
	function spellCheckWindowIsOpen(){
		if(!window.JS_SpellWin_ID){return false ; }
		if (!window.JS_SpellWin_ID.closed && window.JS_SpellWin_ID.location){return true ; }
		return false ; 
		}
	function callBack() {
		/*empty function object*/
	}
	function UID() {
		return uid=new Date().getTime()+"X"+(Math.random()+'').replace('.', '');
	}
	function getXMLFromURL(strURL, binAsync) {
		binAsync = (binAsync == true);
		var xmlhttp = false;
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		         try {
		          xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		         } catch (e) {
		          try {
		           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		          } catch (E) {
		           xmlhttp = false;
		          }
		         }
		        @end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			xmlhttp = new XMLHttpRequest();
		}
		arrURL = strURL.split("&word=");
		strURL = arrURL[0];
		arrURL[1]=arrURL[1].replace(/\+/g,"%2B")
		var strPOST = 'word='+arrURL[1];
		xmlhttp.open("POST", strURL, binAsync);
		xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		var response_text;
		xmlhttp.onreadystatechange = function() {
			if (xmlhttp.readyState == 4) {
				responseXML = (xmlhttp.responseXML);
				if (binAsync) {
					if (!responseXML.getElementsByTagName('id')[0]) {
						if (xmlhttp.responseText.indexOf('<script') != -1) {
									var op=xmlhttp.responseText.split('<?x')
						var opp=op[0].replace(/(<([^>]+)>)/ig,""); 
						eval(opp) ; 
						op[0]="" ;	responseXML.loadXML(op.join("<?x"))
								} else {
							
							if (document.location.href.toLowerCase().indexOf('http')==-1){
								strMessage='Javascript SpellCheck must be used on a Microsoft Web-Server.'
								}else{
								var strMessage='Javascript SpellCheck Ajax Instalation Error'	
									}
							
							return false;
						}
				
					}
					ajaxuid = responseXML.getElementsByTagName('id')[0].firstChild.nodeValue;
					window['FN_JavaScriptSpellCheck__AJAX_API'+ajaxuid](parseXMLDoc(responseXML));
					window['FN_JavaScriptSpellCheck__AJAX_API'+ajaxuid] = null;
				}
			}
		};
		try{xmlhttp.send(strPOST);}catch(e){ return null}
		if (!binAsync) {
			
		
			
			var responseXML = (xmlhttp.responseXML);
			
					if (!responseXML.getElementsByTagName('ajaxspell')[0]) {
					
						if (xmlhttp.responseText.indexOf('<script') != -1 ) {
							
							if(arrURL[1].length<1){return true}
							
								var op=xmlhttp.responseText.split('<?x')
								var opp=op[0].replace(/(<([^>]+)>)/ig,""); 
								eval(opp)
								op[0]="" ;	responseXML.loadXML(op.join("<?x"))
									
						} else {
							alert('Javascript SpellCheck Ajax Instalation Error');
							return false;
						}
					
				}
			
			return parseXMLDoc(responseXML);
		}
	}
	function spellURL(strFields, objCaller) {
		if (!strFields) {
			strFields = '';
		}
		var arrfields=strFields.split(",")
		for (var strItt = 0; strItt < arrfields.length; strItt++) { //(var strItt in arrfields){
			arrfields[strItt]="js:"+arrfields[strItt].replace(" ","").replace(" ","")
			}
		strFields = 	arrfields.join(",")

		languages= objCaller.languages
		var url = setupPath+'/ServerEngine.asp?fields='+strFields;
		if ((languages+'').length>0) {
			url += "&Langs="+languages;
			if (languages.indexOf(",")>-1) {
				url += "&multiLang=True";
			}
		}
		arrCharictaristics = new Array("dataMode|Mode","useServerSession|Session", "windowLanguage|dialogLanguage", "hideSummary|AutoClose", "checkGramar|Grammar", "caseSensitive|CaseSensitive", "externalCSS|CSS", "windowLanguage|UILang", "ignoreAllCaps|AllCaps", "ignoreWebAddresses|Web", "ignoreNumbers|Numeric", "newSentanceOnEachNewLine|NewLine", "uid|uid");
		for (var strItterand = 0; strItterand < arrCharictaristics.length; strItterand++) { // (strItterand in arrCharictaristics) {
			var arrSplit = arrCharictaristics[strItterand].split("|");
			url += "&"+arrSplit[1]+"="+eval('objCaller.'+arrSplit[0]);
		}
		return url;
	}
	function spellCheck(strInput) {
		if (!ajaxEnabled) {
			return null;
		}
		var ajaxURL = spellURL('', this)+"&ajax=true&suggest=true&word="+escape(strInput);
		return getXMLFromURL(ajaxURL, false);
	}
	function ajaxSpellCheck(strInput) {
		if (!ajaxEnabled) {
			return null;
		}
		var ajaxuid = UID();
		window['FN_JavaScriptSpellCheck__AJAX_API'+ajaxuid] = this.ajaxCallBack;
		var ajaxURL = spellURL('', this)+"&ajax=true&id="+ajaxuid+"&suggest=true&word="+escape(strInput);
		getXMLFromURL(ajaxURL, true);
		return true;
	}
	function parseXMLDoc(mydoc) {
		if (mydoc.getElementsByTagName('word').length == 0) {
			return null;
		}
		if (mydoc.getElementsByTagName('spellcheck')[0].firstChild.nodeValue.toUpperCase() == "TRUE") {
			return true;
		}
		if (mydoc.getElementsByTagName('suggestion').length<1) {
			return false;
		}
		var suggestions = new Array();
		for (i=0; i<mydoc.getElementsByTagName('suggestion').length; i++) {
			suggestions[i] = unescape (mydoc.getElementsByTagName('suggestion')[i].firstChild.nodeValue);
		}
		return suggestions;
	}
	ajaxEnabled = ajaxTest();
	// Public Functions
	
	this.ajaxEnabled = ajaxEnabled;
	this.spellCheckWindow = spellCheckWindow;
	this.spellCheckWindowTest = spellCheckWindowTest;
	this.spellCheckWindowIsOpen = spellCheckWindowIsOpen;
	this.spellCheck = spellCheck;
	this.ajaxSpellCheck = ajaxSpellCheck;
	this.callBack = callBack;
	this.ajaxCallBack = ajaxCallBack;
}
function JavaScriptSpellCheck__Postback_API(strObj, strValue, i) {
	var objName = strObj
	if (strObj.substring(0,3) == 'qna') {
		var strOld = escape(jQuery.trim(q_text_array[i])).replace(/%0D/g,'');
	} else {
		strObj = JavaScriptSpellCheck__DOM_API(strObj);
		var strOld = escape(jQuery.trim(eval(strObj))).replace(/%0D/g,'');
	}
	//modified to flag change correctly
	// Standpoint WSH 7/7/10: code buried in the encrypted spell check code is removing trailing spaces on questions and answers which makes it look like question was updated
	
	var strNew = escape(jQuery.trim(strValue)).replace(/%0D/g,'');
	if (strOld!=strNew){ 
		if (objName.substring(0,3) == 'qna') {
			var myObj = q_obj_array[i];
			//eval(strObj+' = unescape("'+escape(strValue)+'")');
			myObj.value = unescape(escape(strValue))
			//var myObj = eval(strObj.substring(0, strObj.length - 6));
		
			var txt = objName.split('_');
			
			FlagChangeV2Wrapper(txt[1], txt[0].substring(3, 20), $j(myObj.parentNode));
		} else {
			strObj = JavaScriptSpellCheck__DOM_API(objName);
			eval(strObj+' = unescape("'+escape(strValue)+'")');
			var myObj = eval(strObj.substring(0, strObj.length - 6));
		
			FlagChangeV2(myObj);	
		}
	}
	return true;
}
function JavaScriptSpellCheck__DOM_API(strObj) {
	var arrObj = strObj.split('.');
	strObj = 'window';
	for (i=0; i<arrObj.length; i++) {
		if (i == 0) {
			if (!eval(strObj+'.'+arrObj[i])) {
				if (document.getElementById(arrObj[i])) {
					arrObj[i] = "document.getElementById('"+arrObj[i]+"')";
				}
			}
		}
		if (eval(strObj+'.'+arrObj[i])) {
			strObj += '.'+arrObj[i];
		} else if (arrObj[i] == 'document' && eval(strObj+'.'+'contentDocument')) {
			strObj += '.'+'contentDocument';
		} else {
			strObj = 'false';
			break;
		}
	}
	var objObj = eval(strObj);
	if (objObj.value!=undefined) {
		strObj += '.value';
	} else if (objObj.innerHTML) {
		strObj += '.innerHTML';
	}

	return strObj;
}
function JavaScriptSpellCheck__PostForward_API(strObj) {
	var binGood = false;
	var strObjMem = strObj;
	strObj = JavaScriptSpellCheck__DOM_API(strObj);
	eval("if("+strObj+"){binGood=true }");
	if (!binGood) {
		//	alert('Object: '+strObjMem+"\n Does not exist")
		return null;
	}
	var strOut = eval(strObj);

	if (strOut.replace  ){
	strOut = strOut.replace(/^\s*|\s*$/g,"");}
	return strOut;
}
/*///////////////////////////////////////////////////////// 
JAVASCRIPT SPELL CHECK (C)2006  JAVASCRIPTSPELLCHECK.COM  
/////////////////////////////////////////////////////////*/

// ******** pulled in simple_server_comm.js **********************************
var IFrameObj; // our IFrame object
/* The following code was taken from: http://www.glish.com/articles/apple/rs_with_iframe.html */
function callToServer(fullcall) {
	//urlReplace(document.getElementById('Search_Results3'), fullcall);
	urlReplace(document.getElementById('pageactions_bg'), fullcall);
}
function callToServer_old(fullcall) {
  if (!document.createElement) {return true};
  var IFrameDoc;
  var URL = (fullcall) ? fullcall : 'server.html';
  if (!IFrameObj && document.createElement) {
    // create the IFrame and assign a reference to the
    // object to our global variable IFrameObj.
    // this will only happen the first time 
    // callToServer() is called
    var tempIFrame=document.createElement('iframe');
    tempIFrame.setAttribute('id','RSIFrame');
    tempIFrame.style.border='0px';
    tempIFrame.style.width='0px';
    tempIFrame.style.height='0px';
    IFrameObj = document.body.appendChild(tempIFrame);
  
    if (document.frames) {
      // this is for IE5 Mac, because it will only
      // allow access to the document object
      // of the IFrame if we access it through
      // the document.frames array
      IFrameObj = document.frames['RSIFrame'];
    }
  }
	iFrameObj = document.getElementById('pageactions_bg');			// 7/17/05 trying to resolve problems
	alert('found obj');
  
  if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
    // we have to give NS6 a fraction of a second
    // to recognize the new IFrame
    setTimeout('callToServer()',10);
    return false;
  }
  
  if (IFrameObj.contentDocument) {
    // For NS6
    IFrameDoc = IFrameObj.contentDocument; 
  } else if (IFrameObj.contentWindow) {
    // For IE5.5 and IE6
    IFrameDoc = IFrameObj.contentWindow.document;
  } else if (IFrameObj.document) {
    // For IE5
    IFrameDoc = IFrameObj.document;
  } else {
    return true;
  }
  
  //IFrameDoc.location.replace(URL);
	urlReplace(document.getElementById('Search_Results3'), URL);	
  return false;
}


// ******** pulled in date.js **********************************

// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
//                 perfectly with SimpleDateFormat formats, but 
//                 backwards-compatability was required.

// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');
function LZ(x) {return(x<0||x>9?"":"0")+x}

// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y-M-d','MMM d, y','MMM d,y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d!=0) { return new Date(d); }
			}
		}
	return null;
	}



// ******** pulled in button_gen.js **********************************
/*
This javascript is called inline with the html to generate a button, usually from the xsl
with a line similar to:
document.write( st_button("<xsl:value-of select="$PassedEnterAction"/>", "<xsl:value-of select="$class"/>", "<xsl:value-of select="Attributes/Attribute[@Label='Item Note']/@Val"/>", "<xsl:value-of select="@Label"/>", "<xsl:value-of select="$varLabel"/>" ));
st_button accepts the parameters usually needed to create a button A tag

if you don't specify a special_class for a given CSS class, then the default A tag will be used							

*/
var special_classes = new Object();
var Page=9999;
/* To override a default button, specify in the following way
   special_classes[class name] = function name;
*/

/*special_classes['UIButtonred'] = 'custom1';

//function custom1(onclick, class_, title, id, label, style) {
function custom1(scale) {
	if (!scale) scale = 1;
	// dimensions for the end points I'm using is 12 wide by 26 high
	var height = (scale * 20);
	var width = (height * .5);		// 12 / 26
	var fontsize = (height * .5);	// 12 pt font / 26
	var fontweight = 'bold';
	
	with (this) {
	var action = onclick;
	
	str = '<table class="button_custom1_table"  border="0" cellspacing="0" cellpadding="0" onmouseover="handPointer(this)" onclick="' + action + '" id="' + id + '" style="' + style + '" href="' + href + '" >'
 + '<tr>'
 + ' <td width="' + width + '" height="' + height + '"><img src="images/small_green_left_endcap_v2.gif" style="width: ' + width + 'px; height: ' + height + 'px"/></td>'
 + '    <td height="' + height + '" style="position: relative"><span style="position: relative; top: 1px; font-size:' + fontsize + 'pt; font-family: verdana; color: white; font-weight: ' + fontweight + '; z-index: 5">' + label + '</span><img style="position: absolute; top: 0px; left: 0px; width: 100%; height: ' + height + 'px" src="images/small_green_mid_endcap_v2.gif"/></td>'
 + ' <td width="' + width + '" height="' + height + '"><img src="images/small_green_right_endcap_v2.gif" style="width: ' + width + 'px; height: ' + height + 'px"/></td>'
 + ' </tr>'
 + ' </table>';
 
	}
	return str;
}
*/

function simulate_A(obj, verifySave, popup) {
	//alert('simulate_A');
	if ((verifySave && VerifySave(true)) || !verifySave) {
		if (popup) {
			window.open(obj.getAttribute('href'));
			}
		else {
			//alert('href='+obj.getAttribute('href'));
			document.location = obj.getAttribute('href');
		}
	}
	
}

function st_button(onclick, href, class_, title, id, label, style, pf) {
	// if we have a special class defined for this css class, then search for and
	//  call the custom function. Otherwise, use default A tag.
	//alert(onclick);
	this.onclick = (onclick ? onclick : '');
	this.href = (href ? href : '');
	this.class_ = (class_ ? class_ : '');
	this.title = (title ? title : '');
	this.id = (id ? id : '');
	this.label = (label ? label : '');
	this.style = (style ? style : '');	
	this.pf = (pf ? pf : '0');	
}

st_button.prototype.create = function() {
	var func;
	if (this.pf > '0'){
	if (typeof varPermissionsString != 'undefined')
		if (varPermissionsString.substr(this.pf-1,1)=='0'){
			return '';
		}
	}
	if (special_classes[this.class_]) {
		try {
			func = eval(special_classes[this.class_]);
		} catch (e) {}
		
		if ( typeof func == 'function' ) {
			//return func.apply(this,arguments);
			return func.apply(this, arguments);
		}
	}
	//return '<a href="/jsError.html" onclick="' + onclick + '" id="' + id + '" title="' + title + '" class="' + class_ + '" style="' + style + '">' + label + '</a>';
	//return '<a href="/jsError.html" onclick="' + this.onclick + '" id="' + this.id + '" title="' + this.title + '" class="' + this.class_ + '" style="' + this.style + '">' + this.label + '</a>';
	if (this.href!='')
		return '<a href="' + this.href + '" onclick="' + this.onclick + '" id="' + this.id + '" title="' + this.title + '" class="' + this.class_ + '" style="' + this.style + '">' + this.label + '</a>';
	else
		return '<a href="/jsError.html" href="' + this.href + '" onclick="' + this.onclick + '" id="' + this.id + '" title="' + this.title + '" class="' + this.class_ + '" style="' + this.style + '">' + this.label + '</a>';
}
// *******************************************************************




function newHL(obj){
	var labelID = 'lbl_' + obj.getAttribute('id').substring(6);
	var def = obj.getAttribute('def');
	var value = obj.value;
	//alert('labelID: ' + labelID + '\ndef: ' + def + '\nvalue: ' + value);
	
	if (document.getElementById(labelID))
	{
		if (def!=value){
			document.getElementById(labelID).style.backgroundColor = '#99FF99';
		}
		else{
			document.getElementById(labelID).style.backgroundColor = '';
		}
	}
}


function inputHL(obj){
	var def = obj.getAttribute('def');
	var value = obj.value;
	if (def!=value){
		obj.style.backgroundColor = '#99FF99';
	}
	else{
		obj.style.backgroundColor = '';
	}
}

//////////////////////////////////////////////////////////////////////////////////////////////
//     This function attaches all of the events needed to correctly size dropdowm lists   
//     the setup looks like this:  onload_actions.push('attachDropDownResizeEvents([<array of field names>]);'); 
//////////////////////////////////////////////////////////////////////////////////////////////

function attachDropDownResizeEvents(objectNames){
	var obj;
	var currFunc;
	
	for(var i=0;i<objectNames.length;i++){
		if(document.getElementById(objectNames[i])){
			obj = document.getElementById(objectNames[i]);	
			if($j.browser.msie && $j.browser.version < 7.0){
				currFunc = (obj.onfocus) ? obj.onfocus : function () {};
				obj.onfocus = function(){
						currFunc();
						var currPos = findPos(this);
						var currWidth = this.offsetWidth;
						this.setAttribute('startingWidth', currWidth);
						
						this.style.top = currPos[1];
						this.style.width = currPos[0];
						this.style.position = 'absolute';
						this.style.width = '';
						if(this.offsetWidth < currWidth) this.style.width = currWidth;
					}
				currFunc = (obj.onblur) ? obj.onblur : function () {};
				obj.onblur = function(){
						currFunc();
						this.style.position = '';
						this.style.width = this.getAttribute('startingWidth');
						this.setAttribute('startingWidth', null);	
					}
				
			} else {
				currFunc = (obj.onfocusin) ? obj.onfocusin : function () {};
				obj.onfocusin = function(){
					currFunc();
					var currPos = findPos(this);
					var currWidth = this.offsetWidth;
					this.setAttribute('startingWidth', currWidth);
					
					this.style.top = currPos[1];
					this.style.width = currPos[0];
					this.style.position = 'absolute';
					this.style.width = '';
					if(this.offsetWidth < currWidth) this.style.width = currWidth;
				}
				currFunc = (obj.onfocusout) ? obj.onfocusout : function () {};
				obj.onfocusout = function(){
					currFunc();
					this.style.position = '';
					this.style.width = this.getAttribute('startingWidth');
					this.setAttribute('startingWidth', null);
				}
			}
		}
	}
}

//---------------------------------------------------
//---------------------------------------------------
// The following functions are used for the scrolling 
// table that uses the jQuery slider bar
//---------------------------------------------------
//---------------------------------------------------
function sliderScrollObject(){
	this.dataStorage;
	this.templateTable;
	this.displayTable;
	this.sliderBar;
	this.sliderText;
	this.contentHolders = 2;
	this.visible = false;
	this.updateRow = function(){};
}

function sliderScrollInit(dataObj){
	if (document.getElementById('debugstuff')){debug('start sliderScrollInit  ' + dataObj.displayTable.tBodies[0].hasChildNodes()  );}
	if (dataObj.displayTable.tBodies[0].hasChildNodes()) return;	
	
	//build the question table
	sliderScrollBuildTable(dataObj);
	
	//now set up the slider with jquery
	$j(dataObj.sliderBar).slider({
		orientation: "vertical",
		min: (dataObj.dataStorage.attr('itemCount') * -1),
		max: -1,
		value: -1,
		slide: function(event, ui) {
			dataObj.sliderText.value = Math.abs(ui.value);
		},
		change: function(event, ui) {
			if (document.getElementById('debugstuff')){debug('start sliderbar change '  );}
			sliderScrollChangeItems(dataObj);
		}
	});
}

function sliderScrollBuildTable(dataObj){
	if (document.getElementById('debugstuff')){debug('start sliderScrollBuildTable '  );}
	if (dataObj.dataStorage.attr('itemCount') <= 0) return;
	//find the table's current position in the window? on the page?
	var tablePos = findPos(dataObj.displayTable);
	var windowSize = findWindowSize();
	//GRH 10132010 Following added to prevent mispositioning of standarddropdownimage in table.  Only happens in IE7, vista.
	dataObj.sliderBar.style.height = 20;
	
	//empty out the current table
	while(dataObj.displayTable.tBodies[0] && dataObj.displayTable.tBodies[0].hasChildNodes())
	{
	   dataObj.displayTable.tBodies[0].removeChild(dataObj.displayTable.tBodies[0].firstChild);
	}
	
	//build a table from the template with the right number of rows and insert the question data
	var rowTemplate = dataObj.templateTable.tBodies[0].rows[0];
	for(var i=0; i<dataObj.dataStorage.attr('itemCount'); i++){
	//for(var i=dataObj.dataStorage.attr('itemCount')-1; i>=0; i--){
		var newRow = rowTemplate.cloneNode(true);
		newRow.setAttribute('rowNum', i);
		//add the row to the table
		dataObj.displayTable.tBodies[0].appendChild(newRow);
		dataObj.contentHolders = i + 1;
		if ((tablePos[1] + dataObj.displayTable.offsetHeight + dataObj.displayTable.tBodies[0].firstChild.offsetHeight > windowSize[1]) && i >= 1){
			//alert(tablePos[1] + '+' + QuestionTable.offsetHeight + '+' + QuestionTable.tBodies[0].firstChild.offsetHeight + '=' + (tablePos[1] + QuestionTable.offsetHeight + QuestionTable.tBodies[0].firstChild.offsetHeight) + '>' + windowSize[1]);
			break;
		}
	}
	
	//figure out the height and set it 
	dataObj.sliderBar.style.height = (dataObj.displayTable.offsetHeight - 125 < 0) ? 20 : dataObj.displayTable.offsetHeight - 125;
	//update the table
	sliderScrollChangeItems(dataObj);
}

function sliderScrollChangeItems(dataObj){
	if (document.getElementById('debugstuff')){debug('start sliderScrollChangeItems ' + 'slidertext.value=' + dataObj.sliderText.value  + ' itemcount=' + dataObj.dataStorage.attr('itemCount') + ' contentHolders=' + dataObj.contentHolders);}
	dataObj.sliderText.value = (+dataObj.sliderText.value>dataObj.dataStorage.attr('itemCount')-dataObj.contentHolders+1) ? dataObj.dataStorage.attr('itemCount')-dataObj.contentHolders+1 : +dataObj.sliderText.value;
	if (dataObj.sliderText.value <= 0){
		dataObj.sliderText.value = 1;
		sliderScrollBuildTable(dataObj);
	}
	for(var i=0; i<dataObj.contentHolders; i++){
		var r = dataObj.displayTable.tBodies[0].rows[i];
		dataObj.updateRow(r,+dataObj.sliderText.value+i);
	}
}

function sliderScrollSliderTextChange(dataObj){
	if (document.getElementById('debugstuff')){debug('start sliderScrollSliderTextChange '  );}
	dataObj.sliderText.value = (+dataObj.sliderText.value < 1) ? 1 : (+dataObj.sliderText.value > +dataObj.dataStorage.attr('itemCount')) ? dataObj.dataStorage.attr('itemCount') : dataObj.sliderText.value;
	
	$j(dataObj.sliderBar).slider("value", (+dataObj.sliderText.value*-1)); 
	//sliderScrollChangeItems(dataObj);
}

function sliderScrollButtonNavigate(mode, dataObj){
	if (document.getElementById('debugstuff')){debug('start sliderScrollButtonNavigate '  );}
	switch(mode){
		case 'top':
			dataObj.sliderText.value = (1);
			break;
		case 'up':
			dataObj.sliderText.value = (+dataObj.sliderText.value - dataObj.contentHolders);
			break;
		 case 'down':
			dataObj.sliderText.value = (+dataObj.sliderText.value + dataObj.contentHolders);
			break;
		 case 'bottom':
			dataObj.sliderText.value = (dataObj.dataStorage.attr('itemCount'));
			break;
	}
	if (document.getElementById('debugstuff')){debug('22222 sliderScrollButtonNavigate '  );}
	sliderScrollSliderTextChange(dataObj);
	if (document.getElementById('debugstuff')){debug('end sliderScrollButtonNavigate '  );}
}

function updateItem(tablename, id, item, val) {
	var url = 'AjaxActions.asp';
		var pars = 'action=UpdateExtItem'
				 + '&tablename=' + tablename
				 + '&id=' + id
				 + '&item=' + item
				 + '&val=' + val
				 + '&rnd='+ (Math.random() * Date.parse(new Date()));
			 
		var target = '';	
		//alert(pars);
		//return false;
		var myAjax = new Ajax.Updater(target, url, { method: 'get', parameters: pars, 
					onComplete: function (r){
										if(r.responseText == '') $('divMessage').innerHTML = 'Save Completed.';
										alert(r.responseText);
					} });
}



//---------------------------------------------------
//---------------------------------------------------

//Following added from base_linkeddropdowns.xsl
			// array structure mapping pointers
			var list_item_ = 0;
			var sublist_ = 1;
			var list_label_ = 1;
			var list_val_ = 0;
			var list_id_ = 2;
			
			
			var const_ALL = 'All';			// this is the value attribute for the All option, the visible text of the All option is defined in the Execute SQL
						
			function register_dropdown(name, parentName, addblankline, all_label, persist_cookie) {
				// prefil dropdowns with data, define attributes needed, select initial values
				//debugger;
				
				var sel_obj = getElementByName(name);
				if (!sel_obj) return;
				var root_name = name;				// root_name is the name of the first set of linked data. If select boxes are Location, Loc2, Loc3... root_name is Location
				var parentVal ='';
				var filter = new Array();
				if (parentName) {
					var parent_obj = getElementByName(parentName);
					
					/* --------------------------------------- */
						//Cross-browser compliant: Complete
						//Notes: Some prompts don't show all the
						//		 search parameters, but they are
						//		 still running through this
						//		 function. Need to filter out
						//		 parent dropdowns that are not
						//		 displayed.
					/* --------------------------------------- */
						if(!parent_obj) return;
					/* --------------------------------------- */
						//End of Cross-browser compliant
					/* --------------------------------------- */
					
					// add the dropdown to the list of children of its parent dd. This is done to allow a dropdown to have multiple dependents
					var child_items = parent_obj.getAttribute('child_items') ? parent_obj.getAttribute('child_items').split(',') : new Array();
					child_items.push(name);
					parent_obj.setAttribute('child_items', child_items.join(','));
					
					root_name = parent_obj.getAttribute('root_name');
					var parentVal = parent_obj.getAttribute('InitVal') ? parent_obj.getAttribute('InitVal') : dd_getSelected(parent_obj);
					filter = parent_obj.getAttribute('filter').length > 0 ? parent_obj.getAttribute('filter').split(',') : filter;
					filter.push(parentVal);
				} 
				sel_obj.setAttribute('parent', parentName);
				sel_obj.setAttribute('filter', filter.length > 0 ? filter.join(',') : '');
				sel_obj.setAttribute('addblankline', addblankline);
				sel_obj.setAttribute('root_name', root_name);
				sel_obj.setAttribute('all_label', all_label);
				sel_obj.setAttribute('persist_cookie', persist_cookie);
				sel_obj.onchange = dd_change;
				sel_obj.setAttribute("cmd","dd_add_option(sel_obj, sel_obj.options[sel_obj.options.length-1])");		//set attribute of cmd to call following an Add 
				var selected_val = sel_obj.getAttribute('InitVal') ? sel_obj.getAttribute('InitVal') : dd_getSelected(sel_obj);
				//selected_val =  getCookie(persist_cookie) ? getCookie(persist_cookie) : selected_val;
				if(persist_cookie!=''){
					if (persist_cookie.indexOf("|")!=-1) {
						var cookieVals = persist_cookie.split("|");
						selected_val =  getCookie(cookieVals[0],cookieVals[1]) ? getCookie(cookieVals[0],cookieVals[1]) : selected_val;
						setCookie(cookieVals[0],selected_val,null,null,null,null,cookieVals[1]);
					} else {
						selected_val =  getCookie(persist_cookie) ? getCookie(persist_cookie) : selected_val;
						setCookie(persist_cookie,selected_val);
					}
				}
				//alert(persist_cookie + ' = ' + getCookie(persist_cookie));
				//window.status = window.status + '**' +  persist_cookie + ' = ' + getCookie(persist_cookie);

				//alert(name + ':' + selected_val + ':' + filter + '!' + sel_obj.getAttribute('filter'));
				//setTimeout("var selected_val =  getCookie('" + persist_cookie + "') ? getCookie('" + persist_cookie + "') : '" + selected_val + "'; dd_setList(getElementByName('" + name + "'), selected_val, new Array());", 3000);
				dd_setList(sel_obj, selected_val, filter); 												//prefill dropdown
				//highlightLabels();  //Removed by GRH due to performance issues
			}
			
			function dd_add_option(target_obj, new_option) {
				// new_option has already been added to target_obj, now we need to add it to the raw data arrays
				var filter = target_obj.getAttribute('filter') ? target_obj.getAttribute('filter').split(',') : new Array();			
				var data_array = eval('rawlist_' + target_obj.getAttribute('root_name'));
				var list_vals = dd_find_data (data_array, filter);
				list_vals.push( new Array(new Array(new_option.value, new_option.name ? new_option.name : ''), new Array()) );
				dd_change(target_obj)
			}
			function dd_setList(target_obj, selected, filter) {
				// set the select box (target_obj) using the given (filter)
				var data_array = eval('rawlist_' + target_obj.getAttribute('root_name'));
				var list_vals = dd_filter_data (data_array, filter);
				dd_fill_w_array(target_obj, list_vals, selected);
			}

			function dd_filter_data (data, filter) {
				// take raw data array, and recursively move through the dimensions, filtering down to desired data
				// the result will be a new array with pointers to the desired data in the raw array
				var data_2_pass = new Array();
				if (filter.length == 0) return data;
				for (var j=0; j < data.length; j++) {
					if (data[j][list_item_][list_val_] == filter[0] || filter[0] == const_ALL) {
						for (var i=0; i < data[j][sublist_].length; i++) {
							data_2_pass.push( data[j][sublist_][i] );
						}
					}
				}
				return dd_filter_data ( data_2_pass, filter.slice(1) );
			}
			function dd_find_data (data, filter) {
				// take raw data array, and recursively move through the dimensions, filtering down to desired data
				// the result will be a single target array specified by the filter. This will not be a copy and thus, can have entries added
				if (filter.length == 0) return data;
				for (var j=0; j < data.length; j++) {
					if (data[j][list_item_][list_val_] == filter[0]) {
						return dd_find_data ( data[j][sublist_] , filter.slice(1) );
					}
				}

			}

			function dd_fill_w_array(obj, arr, selected) {
			//debugger;
				if (obj.type=='hidden'){return;}
				// use the array of data (arr) and fill the Select box (obj) while removing duplicates and setting (selected)
				var already_processed = new Object();
				dd_clearList(obj);
				if (obj.getAttribute('addblankline') == 'true') obj.options[obj.options.length] = new Option('','');   	//blank entry
				if (obj.getAttribute('all_label') != '' ) obj.options[obj.options.length] = new Option(obj.getAttribute('all_label'), const_ALL);   	//blank entry
				
				var selected_count=-1;
				var pkg =  obj.getAttribute('pkg');
				if (pkg==null) pkg = '';
				for (i=0; i < arr.length; i++) {
					if (!already_processed[ arr[i][list_item_][list_val_] ] && (obj.id == arr[i][list_item_][list_id_] || pkg.indexOf(arr[i][list_item_][list_id_])!=-1 )){
						//document.getElementById('debug').value = document.getElementById('debug').value + arr[i][list_item_][list_val_]  + ':' + selected + '\n';
					//	if(selected=='GPS') alert(obj.getAttribute('name') + ' selected value =' + selected + ' x=' + arr[i][list_item_][list_val_] );
						//obj.options[obj.options.length] = new Option((arr[i][list_item_][list_label_] ? arr[i][list_item_][list_label_]  : arr[i][list_item_][list_val_]), arr[i][list_item_][list_val_], null, (arr[i][list_item_][list_val_] == selected));
						// if  list_label = empty then use a blank text option otherwise if the list_label = '' use the list_val for the text
						obj.options[obj.options.length] = new Option((arr[i][list_item_][list_label_] == 'empty' ? '' : (arr[i][list_item_][list_label_] ? arr[i][list_item_][list_label_]  : arr[i][list_item_][list_val_])), arr[i][list_item_][list_val_], null); 
						if (arr[i][list_item_][list_val_] == selected) selected_count = obj.options.length - 1;

						already_processed[ arr[i][list_item_][list_val_] ] = true;
					}
				}
				if (selected_count>0) obj.options[selected_count].selected = true;
					if ((obj.getAttribute('all_label') == const_ALL || obj.getAttribute('all_label') == 'Select One' ) && obj.length==2) {  //if the only two options are All and one other, remove All
						/*	-------------------------------------	*/
							//Cross-browser compliant - Complete
							//Notes: Safari = obj.getAttribute('parent') != 'null'
							//		 IE & Firefox = obj.getAttribute('parent') ?
						/*	-------------------------------------	*/
						if(obj.getAttribute('parent') && /*Safari*/obj.getAttribute('parent')!='null')  { //if the parent has multiple dependencies we don't want to remove the all option
							/*	-------------------------------------	*/
								//End of Cross-browser complaint
							/*	-------------------------------------	*/
						
							if(getElementByName(obj.getAttribute('parent')).value != const_ALL && getElementByName(obj.getAttribute('parent')).getAttribute('child_items').indexOf(',')==-1) { 
								obj.options[0] = null;
								var dd_selected = dd_getSelected(obj);
								if (obj.getAttribute('persist_cookie').indexOf("|")!=-1) {
									var cookieVals = obj.getAttribute('persist_cookie').split("|");
									setCookie(cookieVals[0],dd_selected,null,null,null,null,cookieVals[1]);
								} else {
									setCookie(obj.getAttribute('persist_cookie'),dd_selected);
								}
							}
						} else {
							obj.options[0] = null;
							var dd_selected = dd_getSelected(obj);
							if (obj.getAttribute('persist_cookie').indexOf("|")!=-1) {
								var cookieVals = obj.getAttribute('persist_cookie').split("|");
								setCookie(cookieVals[0],dd_selected,null,null,null,null,cookieVals[1]);
							} else {
								setCookie(obj.getAttribute('persist_cookie'),dd_selected);
							}
						}
					}
				//if the initval is not contained in the new list, add it, and select it.
				if (obj.getAttribute('InitVal')!=null && obj.getAttribute('InitVal')!='' && obj.getAttribute('InitVal')==selected && obj.getAttribute('InitVal')!=dd_getSelected(obj))  obj.options[obj.options.length] = new Option(obj.getAttribute('InitVal'), obj.getAttribute('InitVal'), null, true);
			}
			function dd_clearList(obj) {
				if (obj.type=='hidden'){return;}
				// clear all options from the list
				for (var i=obj.length; i > 0; i--) {		//clear dropdown
					//obj.remove(0);
					obj.options[0] = null;
				}
				obj.options[0] = new Option('','');	 // when you remove all items, the box retains it's width. By adding a blank item, then removing, it shrinks to minimum
				obj.options[0] = null;
				//obj.remove(0);
			}
			function dd_getSelected(obj) {
				if (obj.type=='hidden'){return;}
				// get selected option text
				if(!obj || obj == 'undefined') return null;
				if(!obj.options || obj.options == 'undefined') return;
				
				for (var j=0 ; j < obj.options.length; j++) {
					if (obj.options[j].selected) {
						return (obj.options[j].value ? obj.options[j].value : obj.options[j].text);
					}
				}
				return null;
			}
			function dd_change(obj) {
				// occurs when a select box changes values and propagates selects to children
				if (obj && obj.target) obj = obj.target;
				if (!obj) obj = this;
				var dd_selected = dd_getSelected(obj);
				//if(obj.getAttribute('persist_cookie')!='')
					//setCookie(obj.getAttribute('persist_cookie'),dd_selected);
					
				//if(!dd_selected || dd_selected == 'undefined') return;
				
				if(obj.getAttribute && obj.getAttribute('persist_cookie') && obj.getAttribute('persist_cookie')!=''){
					if (obj.getAttribute('persist_cookie').indexOf("|")!=-1) {
						var cookieVals = obj.getAttribute('persist_cookie').split("|");
						setCookie(cookieVals[0],dd_selected,null,null,null,null,cookieVals[1]);
					} else {
						if(dd_selected && dd_selected != 'undefined')
							setCookie(obj.getAttribute('persist_cookie'),dd_selected);
					}
				}
				
				var filter = obj.getAttribute && obj.getAttribute('filter') ? obj.getAttribute('filter').split(',') : new Array();
				filter.push(dd_selected);
				
				var child_items = obj.getAttribute && obj.getAttribute('child_items') ? obj.getAttribute('child_items').split(',') : new Array();
				for (var j=0; j < child_items.length; j++) {
					var child = getElementByName(child_items[j]);
					//if a value was selected, the call setList on the children, otherwise, clear the children
					//also allow blank subtypes which are a valid option
					if (!dd_selected && obj.getAttribute('name').toUpperCase().indexOf('SUBTYPE')==-1) {
						dd_clearList( child );
					} else {
						if(child.getAttribute('persist_cookie')!=''){
							if (child.getAttribute('persist_cookie').indexOf("|")!=-1) {
								var cookieVals = child.getAttribute('persist_cookie').split("|");
								var selected_val =  getCookie(cookieVals[0], cookieVals[1]) ? getCookie(cookieVals[0], cookieVals[1]) : dd_getSelected(child);
							} else {
								var selected_val =  getCookie(child.getAttribute('persist_cookie')) ? getCookie(child.getAttribute('persist_cookie')) : dd_getSelected(child);
							}
						}
						//var selected_val =  getCookie(child.getAttribute('persist_cookie')) ? getCookie(child.getAttribute('persist_cookie')) : dd_getSelected(child);
						dd_setList( child, selected_val, filter );
					}
					child.setAttribute( 'filter', filter.join(',') );
					dd_change( child );		// recurse on children
				}
				//the customOnChange attribute allows object specific onchange events to be run.
				if (obj.getAttribute && obj.getAttribute('customOnChange'))	{
					var runChange = obj.getAttribute('customOnChange');
					eval(runChange);
					}
				FlagChangeV2(obj);
				//new line added by krish to facilitate auto search in 2 pane search pages
				//debugger;
				base_persistSearchValues(obj);
			}
			


/*------------------------Client Detection---------------------------*/
/*------------------------------------------------------------------*/
var client = function() {
	//rendering engines
	var engine = {
		ie: 0,
		gecko: 0,
		webkit: 0,
		khtml: 0,
		opera: 0,
		
		//complete version
		ver: null
	};
	
	//browsers
	var browser = {
		ie: 0,
		firefox: 0,
		safari: 0,
		konq: 0,
		opera: 0,
		chrome: 0,
		
		//specific version
		ver: null
	};
	
	//platform/device/OS
	var system = {
		win: false,
		mac: false,
		x11: false,
		
		//mobile devices
		iphone: false,
		ipod: false,
		nokiaN: false,
		winMobile: false,
		macMobile: false,
		
		//game systems
		wii: false,
		ps: false
	};
	
	//detect rendering engines/browsers
	var ua = navigator.userAgent;
	if(window.opera) {
		engine.ver = browser.ver = window.opera.version();
		engine.opera = browser.opera = parseFloast(engine.ver);
	}
	else if(/AppleWebKit\/(\S+)/.test(ua)) {
		engine.ver = RegExp["$1"];
		engine.webkit = parseFloat(engine.ver);
		
		//figure out if it's Chrome or Safari
		if(/Chrome\/(\S+)/.test(ua)) {
			browser.ver = RegExp["$1"];
			browser.chrome = parseFloat(browser.ver);
		}
		else if(/Version\/(\S+)/.test(ua)) {
			browser.ver = RegExp["$1"];
			browser.safari = parseFloat(browser.ver);
		}
		else {
			//approximate version
			var safariVersion = 1;
			if(engine.webkit < 100) {
				safariVersion = 1;
			}
			else if(engine.webkit < 312) {
				safariVersion = 1.2;
			}
			else if(engine.webkit < 412) {
				safariVersion = 1.3;
			}
			else {
				safariVersion = 2;
			}
			
			browser.safari = browser.ver = safariVersion;
		}
	}
	else if(/KHTML\/(\S+)/.test(ua) || /Konqueror\/([^;]+)/.test(ua)) {
		engine.ver = browser.ver = RegExp["$1"];
		engine.khtml = browser.konq = parseFloat(engine.ver);
	}
	else if(/rv:([^\)]+)\) Gecko\/\d{8}/.test(ua)) {
		engine.ver = RegExp["$1"];
		engine.gecko = parseFloat(engine.ver);
		
		//determine if it's Firefox
		if(/Firefox\/(\S+)/.test(ua)) {
			browser.ver = RegExp["$1"];
			browser.firefox = parseFloat(browser.ver);
		}
	}
	else if(/MSIE ([^;]+)/.test(ua)) {
		engine.ver = browser.ver = RegExp["$1"];
		engine.ie = browser.ie = parseFloat(engine.ver);
	}
	
	//detect browsers
	browser.ie = engine.ie;
	browser.opera = engine.opera;
	
	//detect platform
	var p = navigator.platform;
	system.win = p.indexOf("Win") == 0;
	system.mac = p.indexOf("Mac") == 0;
	system.x11 = (p == "X11") || (p.indexOf("Linux") == 0);
	
	//detect windows operating systems
	if(system.win) {
		if(/Win(?:dows )?([^do]{2})\s?(\d+\.\d+)?/.test(ua)) {
			if(RegExp["$1"] == "NT") {
				switch(RegExp["$2"]) {
					case "5.0":
						system.win = "2000";
						break;
					case "5.1":
						system.win = "XP";
						break;
					case "6.0":
						system.win = "Vista";
						break;
					default:
						system.win = "NT";
						break;
				}
			}
			else if(RegExp["$1"] == "9x") {
				system.win = "ME";
			}
			else {
				system.win = RegExp["$1"];
			}
		}
	}
	
	//mobile devices
	system.iphone = ua.indexOf("iPhone") > -1;
	system.ipod = ua.indexOf("iPod") > -1;
	system.nokiaN = ua.indexOf("NokiaN") > -1;
	system.winMobile = (system.win == "CE");
	system.macMobile = (system.iphone || system.ipod);
	
	//gaming systems
	system.wii = ua.indexOf("Wii") > -1;
	system.ps = /playstation/i.test(ua);
	
	//return it
	return {
		engine: engine,
		browser: browser,
		system: system
	};
}();

/*
krish 06/10/11 - clean out whitespace text child nodes from node. This comes in handy in dealing with errors thrown 
when trying to read attributes of textnodes, which are inserted into div content in firefox, and in some cases in IE
*/
function cleanWhitespace(node) 
{
  if(node==null)
	return;
  for (var x = 0; x < node.childNodes.length; x++) 
  {
	var childNode = node.childNodes[x];
	if ((childNode.nodeType == 3) && (notWhitespace.indexOf(childNode.nodeValue)) > -1) {
	// that is, if it's a whitespace text node
	node.removeChild(node.childNodes[x]);
	x--;
  }
	  if (childNode.nodeType == 1) 
	  {
		// elements can have text child nodes of their own
		  cleanWhitespace(childNode);
	  }
  }
}


