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 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) {
	openWindow('filBrowse.asp?FRM=' + myForm + '&FLD=' + myField + '&FN=' + myFilename,'FileBrowser',320,150)
}

function checkSearch() {
	if (document.frmSearch.txtSearch.value == '') {
		alert('You must enter a search string.');
		return false;
	} else {
		return true;
	}
}

function setBillInfo() {
	if (document.frmCustomer.chkBillSame.checked) {
		document.frmCustomer.txtBillAddress1.value = document.frmCustomer.txtShipAddress1.value;
		document.frmCustomer.txtBillAddress2.value = document.frmCustomer.txtShipAddress2.value;
		document.frmCustomer.txtBillCity.value = document.frmCustomer.txtShipCity.value;
		document.frmCustomer.cmbBillStateId.value = document.frmCustomer.cmbShipStateId.value;
		document.frmCustomer.txtBillZipCode.value = document.frmCustomer.txtShipZipCode.value;
		document.frmCustomer.txtBillAttn.value = document.frmCustomer.txtShipAttn.value;
	} else {
		document.frmCustomer.txtBillAddress1.value = '';
		document.frmCustomer.txtBillAddress2.value = '';
		document.frmCustomer.txtBillCity.value = '';
		document.frmCustomer.cmbBillStateId.value = '';
		document.frmCustomer.txtBillZipCode.value = '';
		document.frmCustomer.txtBillAttn.value = '';
	}
}

function checkForInt(object) {
	var theValue = object.value
	var newValue = parseInt(theValue,10);

	if (isNaN(newValue)) { object.value = '' } else { object.value = newValue }
	if (newValue > 100) {
		alert("For quantities over 100, please e-mail or call for special pricing.");
		object.value = 100;
	}
}


