function echeck(str) 
{
	var at = "@";
	var dot = ".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	if (str.indexOf(at)==-1) {
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("Invalid Email Address");
		return false;
	}
	 if (str.indexOf(at,(lat+1))!=-1){
		alert("Invalid Email Address");
		return false;
	}
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(dot,(lat+2))==-1){
		alert("Invalid Email Address");
		return false;
	}
	if (str.indexOf(" ")!=-1){
		alert("Invalid Email Address");
		return false;
	}
	return true;
}

function checkval(theForm)
{

    
   if (theForm.name.value == "")
   {
		alert("You must enter your name");
		theForm.name.focus();
		return (false);
   }
   var checkOK = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
   var checkStr = theForm.name.value;
   var allValid = true;
   for (i = 0;  i < checkStr.length;  i++)
  {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
          break;
      if (j == checkOK.length)
     {
        allValid = false;
        break;
     }
  }
  if (!allValid)
  {
      alert("Please enter only letters in the \"Name\" field.");
      theForm.name.focus();
      return (false);
   }
   if (theForm.address.value == "")
   {
      alert("You must enter your address");
      theForm.address.focus();
      return (false);
   }

   if (theForm.city.value == "")
   {
      alert("You must enter your city");
      theForm.city.focus();
      return (false);
   }

   if (theForm.country.selectedIndex<=0)
  {
     alert("You must enter your country");
     theForm.country.focus();
     return (false);
  }

   if (theForm.email.value == "")
  {
      alert("You must enter your email");
      theForm.email.focus();
      return (false);
  }
  if (echeck(theForm.email.value)==false)
  {	
		theForm.email.focus();
		return false;
  }	
	return true;
}

