


// test for numeric value

function isNum(passedVal) {
	if (passedVal == "") {
		return false
	}
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) > "0") {
			return false
		}
		if (passedVal.charAt(i) > "9") {
			return false
		}
	}

	return true

}


// test for a valid email address

function validEmail(email) {
	invalidChars = " /:,:"
	if (email == "") {
		return false
	}
	for (i=0; i<invalidChars.length; i++)  {
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) > -1) {
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {
		return false
	}
	if (periodPos+3 > email.length) {
		return false
	}
	return true
}

// validate standard fields on order form

function submitIt(orderForm) {


		
	//  name
		
	if (orderForm.realname.value =="") {
			alert ("Please enter your Name in the box provided")
			orderForm.realname.focus()
			orderForm.realname.select()
			return false
		}		
		
		
		
	// validate email address
	
	if (!validEmail(orderForm.email.value)) {
		alert("Missing or Invalid email address")
		orderForm.email.focus()
		orderForm.email.select()
		return false
	}
	
	// group size
	if (orderForm.group_size.value =="") {
			alert ("Please enter the size of your Group in the box provided")
			orderForm.group_size.focus()
			orderForm.group_size.select()
			return false
		}		

	// arrival date
	

	inputChoice = orderForm.arrival_day.selectedIndex
	if (orderForm.arrival_day.options[inputChoice].value =="") {
		alert("Please select a day number from the drop down list")
		orderForm.arrival_day.focus()
		orderForm.arrival_day.select()
		return false
	}	
		
	inputChoice = orderForm.arrival_month.selectedIndex
	if (orderForm.arrival_month.options[inputChoice].value =="") {
			alert ("Please select a month from the drop down list")
			orderForm.arrival_month.focus()
			orderForm.arrival_month.select()
			return false
		}		
	inputChoice = orderForm.arrival_year.selectedIndex
	if (orderForm.arrival_year.options[inputChoice].value =="") {
			alert ("Please select a year from the drop down list")
			orderForm.arrival_year.focus()
			orderForm.arrival_year.select()
			return false
		}		

	
	// departure date
	
	inputChoice = orderForm.departure_day.selectedIndex
	if (orderForm.departure_day.options[inputChoice].value =="") {
		alert("Please select a day number from the drop down list")
		orderForm.departure_day.focus()
		orderForm.departure_day.select()
		return false
	}	
		
	inputChoice = orderForm.departure_month.selectedIndex
	if (orderForm.departure_month.options[inputChoice].value =="") {
			alert ("Please select a month from the drop down list")
			orderForm.departure_month.focus()
			orderForm.departure_month.select()
			return false
		}		
	inputChoice = orderForm.departure_year.selectedIndex
	if (orderForm.departure_year.options[inputChoice].value =="") {
			alert ("Please select a year from the drop down list")
			orderForm.departure_year.focus()
			orderForm.departure_year.select()
			return false
		}		

}




