function checkForm()
{	
	if (IsBlank(document.forms[0].realname))
	{
		alert("Please Enter Your Name");
		document.forms[0].realname.focus();
		return false;
	}

	if (IsBlank(document.forms[0].contactemail))
	{
		alert("Please Enter Your Email Address");
		document.forms[0].contactemail.focus();
		return false;
	}

	if (!validEmail(document.forms[0].contactemail.value)) {
	      alert("Invalid email address");
	      document.forms[0].contactemail.focus();
              document.forms[0].contactemail.select();
	      return false;
	}
	return true;
}

// check to see if the field contains data.
function IsBlank(theInput)
{
	if (theInput.value == "") 
	{
		return true;
	}
    	return false;
}

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 submitForm()
{
	if (checkForm())
	{
		document.forms[0].submit();
	}
}
