// JavaScript Document

  function validate(order)
	{

	    var get_name=order.txtName.value;
	    var len_name=get_name.length;
	    
	    var get_company=order.txtCompany.value;
	    var len_company=get_company.length;
		
		var get_mail=order.txtEmail.value;
	    var len_mail=get_mail.length;
		
        var get_tel=order.txtTel.value;
	    var len_tel=get_tel.length;

	    var get_int=order.txtInt.value;
	    var len_int=get_int.length;


//********************************** Name field validation *********************************
		if(len_name==0)
		{
			alert("Please enter your name");
			order.txtName.select();
			order.txtName.focus();
			return false;
		}


//************************************* Telephone field validation *************************
		   if(len_tel==0)
		   {
			 test=1;
			 alert("Enter Telephone Number");
			 order.txtTel.select();
			 order.txtTel.focus();
			 return false;
		   }
			  if(len_int==0)
			  {
			       test=1;
			       alert("Please enter your interest");
			       order.txtint.select();
			       order.txtint.focus();
			       return false;
			  }
//************************************ Email validation  ********************************
			    if(len_mail==0)
			    {
					   test=1;
					   alert("Enter Email ID");
					   order.txtEmail.select();
					   order.txtEmail.focus();
					   return false;
			     }
			     else   //charter read
			     {
				 first_char=get_mail.charAt(0);
				 if(!isNaN(first_char))
				 {
				      test=1;
				      alert("First Character must be an alphabet in Email id");
				      order.txtEmail.select();
				      order.txtEmail.focus();
				      return false;
				 }
				 else
				 {
				       for(i=0;i<len_mail;i++)
				       {
					    if(get_mail.charAt(i)=='@')
					    {
					       mail_count++;
					    }
					   if(get_mail.charAt(i)==',')
					    {
					      mail_temp++;
					    }
					    if(get_mail.charAt(i)==' ')
					    {
						mail_temp++;
					     }
					    if(get_mail.charAt(i)==';')
					    {
						mail_temp++;
					    }
					    if(get_mail.charAt(i)==':')
					    {
						mail_temp++;
					     }
					     if(get_mail.charAt(i)=='.')
					     {
					       mail_flag++;
					     }
					}//for loop (charter reader)
				       if(mail_count>1 || mail_temp>0)
				       {
					 alert("Invalid Email ID");
					 order.txtEmail.select();
					 order.txtEmail.focus();
					 return false;
				       }
				       else
					   {
						if(mail_count==1 && mail_flag>0)
						{
						  test=0;
						  return true;
						 }
						 else
						 {
						   alert("invalid Email ID");
						    order.txtEmail.select();
						    order.txtEmail.focus();
						    return false;
						  }
					      }//else
				     }//else (charter reader)
			     }//else from empty field check
//********************************** end of mail validation ********************************

       if(test==0)
       return true;
       }//function validate()
