function redirectToHTTPS()
{
  if($_SERVER['HTTPS']!="on")
  {
     $redirect= "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
     header("Location:$redirect");
  }
}
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
}
function validForm(contact_form) {
	if (contact_form.name.value == "") {
		alert("Please enter your name.")
		contact_form.name.focus()
		return false
	}
	if (!validEmail(contact_form.email.value)) {
		alert("Please enter a valid email address (like name@domain.com).")
		contact_form.email.focus()
		contact_form.email.select()
		return false
	}
	if (contact_form.phone.value == "") {
		alert("Please enter your phone number.")
		contact_form.phone.focus()
		return false
	}
	if (contact_form.time.value == "") {
		alert("Please enter the best time to contact you.")
		contact_form.time.focus()
		return false
	}
	if (contact_form.message.value == "") {
		alert("Please enter your message.")
		contact_form.message.focus()
		return false
	}
	return true
}
