	<!--

var popupTarget;
var popupID;
var popupModifier;
var lastPopup = 0;
var PWindow;

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 ssError = false;

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);
	}
	
	catch (error) {
		return;
	}
	
	return true;
}

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;
}

function VerifySave()
{
var Answer
	if (document.frmSelections.Saved.value==-1)
	{	
		document.frmSelections.Saved.value=0;
		return true;
	}	
	if (document.frmSelections.Saved.value==0)
	{	
		if (confirm("Changes have been made to this page. Do you wish to save and continue?"))
		{
			document.frmSelections.Saved.value=-1;
			return true;
		}
		else
		{
			return (confirm("Do you wish to continue with requested action without saving?"));
		}
	}
	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 ("backreload");
	if (endstr > -1)
	{
		document.cookie = "EndAction=none";
		//window.location.reload(true);
		window.location.reload(true);
		//window.location.replace(window.location.href);
	}
  	document.frmSelections.Saved.value=1;
	return true;
}

function PotentialBackNavigation()
{
	if (document.frmSelections.EndAction.value ==1)
	{
		document.frmSelections.EndAction.value = 0;
		history.go(-2);
	}
	if (document.frmSelections.EndAction.value == 2)
	{
		document.frmSelections.EndAction.value = 0;
		document.cookie = "EndAction=backreload";
		history.go(-2);
	}
	
	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);
		}
		
	}
	catch (error) {
		return;
	}
	
	if (popupPage.indexOf('.') > -1) {
		openURL = popupPage;
	}
	
	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.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;
	}
	
	
}

function getYearlyStatsPrompt() {
	var pURL = 'getYearlyPlayerStats.asp?action=getReportPrompt';
	var winW = 400;
	var winH = 200;
	var winTitle = 'Yearly Player Stats Report';
	
	popupElement.docPopup(pURL,winW,winH,winTitle);
	
	//window.open('fastsql_v2_direct.asp?id=8814/Execute_YearlyPlayerStats&outformat=excel_net&filename=Yearly Player Stats');
}

// *************************************************************
// 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");

function keyDown(DnEvents) { // handles keypress
	// determines whether Netscape or Internet Explorer
	k = (netscape) ? DnEvents.which : window.event.keyCode;
	if (k == 13) { // enter key pressed
		src = window.event.srcElement;
		if (src.name.substr(0,3)=='Val') {
			eval('FlagChange('+src.name.substr(3,9)+')');
		}
		//alert(document.getElementById('QuickSearch').value);
		if((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);
		}
	}
}

document.onkeydown = keyDown; // work together to analyze keystrokes
if (netscape) document.captureEvents(Event.KEYDOWN|Event.KEYUP);


function setCursor() {
	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

// 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) {
  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) {
  var dc = document.cookie;
  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 = document.cookie.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);
	
}

// *************************************************************
// TABLE SORT FUNCTIONS
// *************************************************************

// -->
document.write('<SCRIPT LANGUAGE="JavaScript" SRC="js/date.js"></SCRIPT>');

