function hiliteRow(thisElement) {
	document.all[thisElement].className='rowHilite';
}

function unhiliteRow(thisElement) {
	document.all[thisElement].className='rowUnHilite';
}

function lblClick(sForm,sName,iType) {
  if (iType == '') {
    if (document.forms[sForm].all[sName].checked == false) { document.forms[sForm].all[sName].checked = true; }
		else { document.forms[sForm].all[sName].checked = false; }
	} else { document.forms[sForm].all[sName].checked = true; }
}

function moveCursor(sFormName,sFirstField,sNextField,iLength) {
	var fieldValue;	fieldValue = document.forms[sFormName].elements[sFirstField].value;
	if (fieldValue.length == iLength) { document.forms[sFormName].elements[sNextField].focus(); }
}

function checkForIE() {
	if (navigator.userAgent.indexOf("MSIE") != -1) { return true } else { return false }
}

function checkPass() {
	var sForm = arguments[0]; var sFieldOne = arguments[1]; var sFieldTwo = arguments[2];
	if (document.forms[sForm].elements[sFieldOne].value == document.forms[sForm].elements[sFieldTwo].value) {
		return true;
	} else {
		alert("The passwords do not match, please enter them again.");
//		document.forms[sForm].elements[sFieldOne].value = '';
		document.forms[sForm].elements[sFieldTwo].value = '';
		return false;
	}
}

function checkForm() {
	var bSubmitForm = true; var iElements = arguments.length;
	var sForm = arguments[0]; var lblForm = arguments[1]; var bCheckPass = arguments[2];
	var x = 3;

	while (x<iElements) {
		sField = arguments[x]; sName = arguments[x+1];

		if (sField == 'txtEmail') {
			var bInvalid = false;
			if (document.forms[sForm].elements[sField].value.indexOf('@') <= -1) { bInvalid = true }
			  else { if (document.forms[sForm].elements[sField].value.indexOf('.') <= -1) { bInvalid = true; }}

			if (bInvalid == true) {
				if (checkForIE()) { document.all[sName].innerHTML = "Incomplete"; }
				  else { alert(sField.substring(sField.indexOf("txt")+3,20) + " is not a valid Email address."); }
				  bSubmitForm = false;
			} else {
				if (checkForIE) { document.all[sName].innerHTML = ""; }
			}
		} else {
			if (document.forms[sForm].elements[sField].value == "") {
				if (checkForIE()) { document.all[sName].innerHTML = "Incomplete"; }
				  else { alert(sField.substring(sField.indexOf("txt")+3,20) + " is incomplete."); }
				  bSubmitForm = false;
			} else {
				if (checkForIE()) { document.all[sName].innerHTML = ""; }
			}
		}
		x = x+2;
	}

	if (bCheckPass == 'true') {
		if (checkPass(sForm,'txtPassword','txtPasswordCheck')) {
			//nada
		} else {
			bSubmitForm = false;
		}
	}

	if (bSubmitForm) { return true }
	  else { if (checkForIE()) { document.all[lblForm].innerHTML = "All fields were not filled in correctly."; }
	  return false
	}
}

function confirmDelete() {
	if (confirm('Are you sure you would like to delete this item?') == true)
	  { return true }
	else
	  { return false }
}

function openWindow(sURL,sName,iWidth,iHeight) {
	window.self.open(sURL,sName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + iWidth + ',height=' + iHeight);
}

function openWindowScroll(sURL,sName,iWidth,iHeight) {
	window.self.open(sURL,sName,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=no,width=' + iWidth + ',height=' + iHeight);
}

function convertIt(initialVal) {
	var _c = initialVal;
	var _x = initialVal.indexOf("$");
	if (_x == -1 ) _x = initialVal.indexOf(",");
	if (_x != -1) {
		var _p1 = initialVal.substr(0,_x);
		var _p2 = initialVal.substr(_x+1,initialVal.length);
		_c = convertIt(_p1+_p2);
	}
	return (_c);
}

function fileBrowse(myForm,myField,myFilename,hiddenField) {
	if (myFilename == 'file') {
		openWindow('filBrowse.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename + '&HID=' + hiddenField,'FileBrowser',320,150)
	} else if (myFilename == 'img') {
		openWindow('imgBrowse.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename + '&HID=' + hiddenField,'ImageBrowser',320,150)
	} else if (myFilename == 'photo') {
		openWindow('photBrowse.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename + '&HID=' + hiddenField,'PhotoBrowser',320,150)
	}
}

function fileDelete(myForm,myField,myFilename,hiddenField) {
	if (myFilename == 'file') {
		//DELETE FILE
		if (hiddenField == '') {
			alert('Nothing to delete!');
		} else {
			openWindow('filDelete.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename+ '&HID=' + hiddenField,'FileBrowser',320,150);
		}
	} else if (myFilename == 'img') {
		//DELETE IMAGE
		if (hiddenField == '') {
			alert('Nothing to delete!');
		} else {
			openWindow('imgDelete.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename+ '&HID=' + hiddenField,'ImageBrowser',320,150);
		}
	} else if (myFilename == 'photo') {
		//DELETE Photo
		if (hiddenField == '') {
			alert('Nothing to delete!');
		} else {
			openWindow('photDelete.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename+ '&HID=' + hiddenField,'PhotoBrowser',320,150);
		}
	}
}

function populateMarshall() {
	frmReservation.txtFirstName.value = 'MARSHALL';
	frmReservation.txtLastName.value = 'TOWNSHIP';
	frmReservation.txtOrganization.value = 'MARSHALL TOWNSHIP';
	frmReservation.txtAddress1.value = 'P.O. BOX 2094';
	frmReservation.txtAddress2.value = '525 PLEASANT HILL ROAD';
	frmReservation.txtCity.value = 'WARRENDALE';
	frmReservation.cmbStateId.selectedIndex='37';
	frmReservation.txtZipCode.value = '15086';
	frmReservation.chkResident.checked = true;
	frmReservation.txtPhone1.value = '724-935-3090';
	frmReservation.txtEmailAddress.value = 'kimberlyp@twp.marshall.pa.us';

}

