  var email

  function isBlank(s)

  {

    var len=s.length

    var i

    for(i=0;i<len;++i)

    {

      if(s.charAt(i)!=" ") return false;

    }

    return true;

  }



  function validate(fieldName,fieldValue)

  {

    if(isBlank(fieldValue))

    {

      alert(fieldName+" cannot be left blank.");

          document.form.email.focus();

      return false

    }

    x=mailcheck(document.form.email.value,0);

    if (x==false)

    {

      document.form.email.focus();

        return false;

    }

    return true

  }



  function validateform()
  {
    var str = document.form.email.value;
    var posemail = str.lastIndexOf("vsnl");
    var posvemail = str.lastIndexOf("VSNL");
	
	if(!document.form.team_s.checked)
	{
		alert("Please agree the terms and conditions.");
		document.form.team_s.focus();
		return false;	
	}

	if(!validate("The Name field",document.form.Yname.value))
    {
		document.form.Yname.focus();
        return false;
    }

    if(!validate("The Organization field",document.form.organization.value))
    {
		document.form.organization.focus();
		return false;
	}

	if(!validate("The Address field",document.form.address.value))
	{
		document.form.address.focus();
		return false;
	}

	if(!validate("The City field",document.form.city.value))
	{
		document.form.city.focus();
		return false;
	}
	if(!validate("The State field",document.form.state.value))
	{
		document.form.state.focus();
		return false;
	}
	if(!validate("The Country field",document.form.country.value))
	{
		document.form.country.focus();
		return false;
	}

	if(!validate("The ZIP field",document.form.zip.value))
    {
		document.form.zip.focus();
		return false;
	}

	if(!validate("The Telephone field",document.form.tel.value))
	{
		document.form.tel.focus();
		return false;
	}

    if(!validate("The E-mail field",document.form.email.value))
	{
		document.form.email.focus();
		return false;
	}

	if ((posemail >= 0) || (posvemail >= 0))
    {
		alert("We do not accept vsnl mail address, because of mail bounce. Please suggest any other e-mail.");
		document.form.email.focus();
		return false;
	}
 }



  function mailcheck(valmail, valtype)

  {

    var n,atCount,dotCount,temp_1,temp_2,temp_ascii;

    var temp_3=0;

    atCount=0;

    dotCount=0;

    n=0;

    var st=new String;

    st = valmail.split(" ");

    st = st.join("");

    st = st.toLowerCase();

    if (valtype==0)

    {

      document.form.email.value=st;

    }

    else

    {

      document.myForm.E2.value=st;

    }



    temp_1=st.charAt(0);

    temp_ascii = st.charCodeAt(0);

    for(n=0;n<st.length;n++)

    {

      temp_2=st.charCodeAt(n);

      if ((temp_2<48)||(temp_2>57))

      {

        if((temp_2<97)||(temp_2>122))

        {

          if ((temp_2==95)||(temp_2==46)||(temp_2==64)||(temp_2==45))

          {

            //alert("special but correct");

          }

          else

          {

            alert("Please enter a valid Email Address");

            count=0;

                        document.form.email.focus();

            return false;

          }

        }

      }



      if(st.charAt(n)=='@'&&n==0) atCount=atCount+1;

      if(st.charAt(n)=='@'&&st.charAt(n+1)=='.')atCount=atCount+1;

      if(st.charAt(n)=='@')atCount=atCount+1;

      if(st.charAt(n)=='.')

      {

        if(st.charAt(n+1)=='.'||n==st.length-1)atCount=2;

        dotCount=dotCount+1;

      }



      if(st.charAt(n)=='.')

      {

        if((st.charAt(n+1)=='@')||(st.charAt(n-1)=='@'))

        {

          alert("Please enter a valid Email address");

          return false;

        }

      }

    }



    if (atCount!=1 || dotCount<1)

    {

      alert("Please enter a valid Email address");

      return false;

    }



    /*changed here so that it accepts number as that First Character

    */



    else if((temp_ascii<48)||(temp_ascii>122))

    {

      alert("Please enter a valid Email address");

      count=0;

      return false;

    }

    else

    {

      x=st.lastIndexOf("@");

      y=st.lastIndexOf(".");

      if (y<x)

      {

        alert("Please enter a valid Email address");

        return false;

      }

    }

  }
