function validateCanvasPrintForm(theForm){
	//name must be provided
	if(notSupplied(theForm.Name.value)){
		theForm.Name.focus()
		alert("Please enter your name.")
		return false
	}
	
	//validate personal email
	if(validateEmail(theForm.Email.value) == false){
		theForm.Email.focus()
		alert("Invalid email address, please confirm your details and try again.")
		return false
	}
}


function validateContactForm(theForm){   

	//check manditory parameters passed
	
	typeOption = false;
	for(i=0; i<theForm.Type.length; i++){
		if(theForm.Type[i].checked){
			typeOption = true;	
		}
	}
	if(typeOption == false){
		theForm.Type[0].focus()
		alert("You must select a type for this quote!")
		return false
	}
	
	artOption = false;
	for(i=0; i<theForm.Artwork.length; i++){
		if(theForm.Artwork[i].checked){
			artOption = true;	
		}
	}
	if(artOption == false){
		theForm.Artwork[0].focus()
		alert("Please select the type of artwork required for this quote!")
		return false
	}
	
	//check manditory parameters passed
	if(notSupplied(theForm.Width.value)){
		theForm.Width.focus()
		alert("You must enter a width in cm!")
		return false
	}
	
	//check manditory parameters passed
	if(notSupplied(theForm.Height.value)){
		theForm.Height.focus()
		alert("You must enter a height in cm!")
		return false
	}
	
	//name must be provided
	if(notSupplied(theForm.Name.value)){
		theForm.Name.focus()
		alert("Please enter your name.")
		return false
	}
	
	//validate personal email
	if(validateEmail(theForm.Email.value) == false){
		theForm.Email.focus()
		alert("Invalid email address, please confirm your details and try again.")
		return false
	}
	
	//address must be supplied
	if(notSupplied(theForm.Address_1.value) || notSupplied(theForm.City.value) ||  notSupplied(theForm.State.value) || notSupplied(theForm.Postcode.value)){
		theForm.Address_1.focus()
		alert("Address details must be provided including city, state and postcode.")
		return false
	}
	
	//Phone must be provided
	if(notSupplied(theForm.Phone.value)){
		theForm.Phone.focus()
		alert("Please enter your contact number.")
		return false
	}
	return true
}



//return true if no values are checked 
function valueNotChecked(radiofield){
	for(i = 0; i<radiofield.length; i++){
		if(radiofield[i].checked){
			return false
		}
	}
	return true
}

function validateEmail(email){
	invalidChars= "/:,;"
	
	//check if email is supplied, error if not.
	if(email == ""){
		return false
	}
	
	//check if email contains one of the invalid characters, error if it does
	for(i=0; i<invalidChars.length; i++){
		badChar = invalidChars.charAt(i)
		if(email.indexOf(badChar, 0) > -1){
			return false
		}
	}
	//make sure the address has a @ in it and a . in it somewhere
	if(email.indexOf("@", 1) == -1 || email.indexOf(".", 1) == -1){
		return false
	}
	return true
}
function notSupplied(value){
	if(value != ""){
		return false
	}
	return true
}
