
//---------------- 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.no_of_weeks.value == "")
	{
	alert ("The number of weeks field is required. If you wish to rent for more than a month, just type 4\+ and explain in comments below.")
	form.no_of_weeks.focus()
	form.no_of_weeks.select()
	return false
	}


   // If we made it to here, everything's valid, so return true
 
return true
}

//------- Print Page
function printWindow() {
bV = parseInt(navigator.appVersion);
if (bV >= 4) window.print();
}

//------- Close Window
function closeWindow() 
{
window.close(this)
}
