	<!--

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 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;

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 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);
	for (var j=0; j < objs.length; 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);
			if (inner_inputs && inner_inputs.length < 10) // if there are too many inputs, something is fishy and I don't trust the situation
			for (var i=0; i < inner_inputs.length && !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() {
	alert('here');
	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() {
	while (onload_actions.length > 0) {
		act = onload_actions.shift();
		//act = act.replace("'", "'");		
		//alert('onload_action: '+act);
		eval(act);
	}
}

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 {
	  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_) {
	str = str + '=';
	if (!(window.location.href.indexOf(str) > 0)) return default_;
	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;
}
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)
{
	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
{
	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"))
			doUpdate(dont_wait);
			return true;
		} else
		return (confirm("Do you wish to continue with requested action without saving?"));
	}
	
	//following specifically for Testgate, question page.
	try {
		SaveHTML(selectedEditObj);
	} catch (e) {}
	
	
	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')) {
			var savecmd = document.getElementById('Save').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?"))
		{
			//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
				}
				catch (error) {return;}

			} else {
				document.frmSelections.Saved.value=-1;
				return true;
			}
		}
		else
		{
			return (confirm("Do you wish to continue with requested action without saving?"));
		}
	}
	else
		return true;
}

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);
		}
	}
	
	catch (error) {
		return;
	}
	
	
	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.FlagChange(opener.popupID);
			} catch (error) {
				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
	// 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) { // enter key pressed
		var src = (event.target) ? event.target : event.srcElement;		// JS2FIREFOX [changed]
		if (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) { // 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;
	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(){
	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])) {
				document.getElementById(currentCookie[0]).value = currentCookie[1];
			}
		}
	}
}

// *************************************************************
// Ajax Functions
// *************************************************************

function AjaxSave() {
      //alert('AjaxSave');
      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)
{
	if(optParms==null) optParms = '';
	var url = 'fastsql_v2_direct.asp';
	
	var pars = 'id=' + executeID + '&' + (window.location.href.substr(window.location.href.indexOf("?")+1)).replace('id=', 'originalId=')
			 + optParms
			 + '&ajaxrnd='+ (Math.random() * Date.parse(new Date()));
	
	pars = replaceAll(pars,"&&","&");
	pars = replaceAll(pars,"&amp;","&");
	
	var target = "Execute"+executeID;
	
	document.body.style.cursor = "wait";
	if ( $('spin_'+executeID) ) $('spin_'+executeID).style.visibility = 'visible';
	if ($('displayLoadingMessage')) $(target).InnerHTML = $('displayLoadingMessage').value;
	
	var myAjax = new Ajax.Updater(target, url, { method: 'get', parameters: pars,
	                              onComplete: function (r) 
								  {				
									//alert(r.responseText);
									document.body.style.cursor = "";
									if ( $('spin_'+executeID) ) $('spin_'+executeID).style.visibility = 'hidden';
								  } });
}

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)
{	
	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){
				$(updatetables[k]).innerHTML = ' Loading... ';
			}
		}
	}
	
	var extraPars = 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', parameters: "",
	                              onComplete: function (d) 
								  {	
									//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));
											}
											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 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]
}


// *************************************************************
// 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>');

