//--------------PRELOADS IMAGES SO THEY ROLL FASTER
function preLoad()
{
var images = new Array('path/image.jpg','path/image.gif'); /****/
preloadImages(images);
}

//--------------Defines process for preload
function preloadImages(images)
{
for(loop = 0; loop < images.length; loop++)
	{
	var image = new Image();
	image.src = images[loop];
	}
}

//---------------- FORM PROCESSING

//--------------- Validates Email
	function validEmail(email) {
		invalidChars = " /:,;"
			
		if (email == "") {		// cannot be empty
		return false
		}
		for (i=0; i<invalidChars.length; i++) {	
			// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
		return false
		}
		}
		atPos = email.indexOf("@",1)	// must be one "@" symbol
		if (atPos == -1) {
		return false
		}
		if (email.indexOf("@",atPos+1) != -1) {	
			// only 1 "@" symbol
		return false
		}
		periodPos = email.indexOf(".",atPos)
		if (periodPos == -1) {	// at least one "." after the "@"
		return false
		}
		if (periodPos+3 > email.length)	{	
			// must be at least 2 characters after the "."
		return false
		}
		return true
		}
		
		
function submitIt(form) 
{
					
	//--- runs email validation and requires fields

	if (!validEmail(form.email.value)) 
	{
	alert("Invalid or empty email address")
	form.email.focus()
	form.email.select()
	return false
	}

	if (form.name.value == "")
	{
	alert ("The name field is required")
	form.name.focus()
	form.name.select()
	return false
	}

	if (form.arr_day.value == "")
	{
	alert ("The arrival day field is required")
	form.arr_day.focus()
	form.arr_day.select()
	return false
	}

	if (form.arr_month.value == "")
	{
	alert ("The month field is required")
	form.arr_month.focus()
	form.arr_month.select()
	return false
	}

	if (form.arr_year.value == "")
	{
	alert ("The arrival year field is required")
	form.arr_year.focus()
	form.arr_year.select()
	return false
	}

	if (form.weeks.value == "")
	{
	alert ("The number of weeks field is required")
	form.weeks.focus()
	form.weeks.select()
	return false
	}

	if (form.adults.value == "")
	{
	alert ("The number of adults field is required")
	form.adults.focus()
	form.adults.select()
	return false
	}

   // If we made it to here, everything's valid, so return true
 
return true
}

