// JavaScript Document<!--
function checkItemForm ( form ) {
	//if (form.itemID.value == "") {
	//	alert("Please Enter an Item ID");
	//	form.itemID.focus();
	//	return false;
	//}
	
	var itemIDVal = form.itemID.value;
	if (itemIDVal.length > 5 || itemIDVal.length < 4) {
		alert("Item ID length invalid\nThe item ID must be either 4 or 5 characters in length.\nIf the item is for the Oral or Live Auction, it will contain a 4-digit number with leading zeroes (i.e. 0001, 0002, etc)\nIf the item is for another Auction Section, the 4-digit number is preceeded by the section letter (i.e. B0001, G0002, etc)");
		form.itemID.focus();
		return false;
	}
	var itemIDNum = itemIDVal.replace(/0/g,"");
	if (parseFloat(itemIDNum,10) == (itemIDNum*1)) {
	} else {
		alert("Invalid Item ID. Use Numbers Only");
		return false;
	}
	if (form.shortDescription.value == "") {
		alert("Please Enter a Short Description");
		form.shortDescription.focus();
		return false;
	}
	if (form.itemValue.value == "") {
		alert("Please Enter an Item Value");
		form.shortDescription.focus();
		return false;
	}
	if (parseFloat(form.itemValue.value,10) == (form.itemValue.value*1)) {
	} else {
		alert("Invalid Item Value. Enter a whole dollar amount");
		return false;
	}
	
	return true;
}
function checkAttendeeForm (formobj) {
	$val = formobj.lastName1.value;
	if ($val == "") {
		alert("Please Enter a Last Name");
		return false;
	}
	return true;
}
		

function checkSetupForm (formobj) {

	var alertMsg = "Please complete the following fields:\n\n";
	
	var l_Msg = alertMsg.length;

	// name of mandatory fields
	var fieldRequired = Array("organizationName","organizationStreet","organizationCity","organizationState","organizationZip","organizationPhone1","organizationPhone2","organizationPhone3","eventName","eventLocation","eventMonth","eventDay","eventYear","eventTimeHour","eventTimeMinute","mainContact1Name","mainContact1Phone");
	// field description to appear in the dialog box
	var fieldDescription = Array("Organization Name","Organization Street Address","Organization City","Organization State","Organization Zip","Organization Area Code","Organization Phone","Organization Phone","Event Name","Event Location","Event Date (Month)","Event Date (Day)","Event Date (Year)","Event Time (Hour)","Event Time (Minute)","Main Contact Name","Main Contact Phone");
	// dialog message
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			if (obj.type == null){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				continue;
			}

			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
		}
	}
	if (alertMsg.length == l_Msg){
		return true;
	} else {
		alert(alertMsg);
		return false;
	}
}

function checkCustomerSetup (form) {

	var customerID = form.customer.value;
	var length  = customerID.length;
	var goodChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	if(length == 0) {
		alert("Please Enter a Customer ID");
		return false;
	} else {
		for(i=0; i<=length -1; i++) {
			if (goodChars.indexOf(customerID.charAt(i)) == -1) {
				alert("You have an invalid character in the Customer ID");
				return false;
			}
		}
	}
	return true;
}
function checkBusinessForm ( form ) {
	//if (form.itemID.value == "") {
	//	alert("Please Enter an Item ID");
	//	form.itemID.focus();
	//	return false;
	//}
	var businessName = form.businessName.value;
	var length = businessName.length;
	if (length == 0) {
		alert("Please enter a business name");
		return false;
	}
	var numberOfAttendees = form.numberOfAttendees.value;
	var length  = numberOfAttendees.length;
	var goodChars = "0123456789";
	if(length == 0) {
		alert("Please Enter the Number of Attendees from this business");
		return false;
	} else {
		for(i=0; i<=length -1; i++) {
			if (goodChars.indexOf(customerID.charAt(i)) == -1) {
				alert("You have an invalid character in the Number of Attendees field");
				return false;
			}
		}
	}
	return true;
}

//-->
