//===========================================================

//File Name: 	guestbook.js
//Created By:	Sam Tuan Nguyen
//Date Created:	7/7/2005
//Description:	check all fields in guestbook.php page are field in
//Requires:

//index.php
//services.php
//-----------------------------------------------------------

//Modified By:		N/A
//Modified Date:	N/A
//Description:		N/A
//Reason:		N/A

//=============================o0o===========================


function valid_guestbook()
{
var full_name = document.guestbook.full_name.value;
var full_nameLength = document.guestbook.full_name.value.length;
if(full_nameLength<2 || full_name=="")
	{
	window.status=("Please enter your name");
	alert("Applied Geodetics Inc. \n\nPlease enter your name");
	document.guestbook.full_name.focus();
	return false;
	}
function validEmail(email)
{
var email = document.guestbook.email.value;

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;
  }


 if(!validEmail(document.guestbook.email.value))
	{
		window.status=("Invalid email addsess");
		alert("Applied Geodetics Inc. \n\nInvalid email addsess");
		document.guestbook.email.focus();
		document.guestbook.email.select();
		return false;
	}

var comments = document.guestbook.comments.value;
var commentsLength = document.guestbook.comments.value.length;

if(comments=="")
	{
		window.status=("Please enter your comments.");
		alert("Applied Geodetics Inc. \n\nPlease enter your comments.");
		return false;
	}
if(commentsLength>500)
	{
		window.status=("Sorry, your comments must less then 499 chrs.");
		alert("Applied Geodetics Inc. \n\nSorry, your comments must less then 499 chrs.");
		return false;
	}
}
