function isemailform (s){
	
	var i = 1;
	var sLength = s.length;
	// look for @
	while ((i < sLength) && (s.charAt(i) != "@")){
	i++
	}
    
	if ((i >= sLength) || (s.charAt(i) != "@")) 
	return false;
	else i += 2;
 
	// look for .
	while ((i < sLength) && (s.charAt(i) != ".")){
	i++
	}
	
	// there must be at least one character after the .
	if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
	else return true;
}

function checknumber (n)
{

var error;
var stripped = n;
var j;
var dta;
//strip out acceptable non-numeric characters
//if (isNaN(parseInt(stripped)))
//{
//   alert("The phone number contains illegal characters.");
//   return false;
//}

      for(j=0;j<stripped.length;j++)
      {
        dta=stripped.charAt(j);
        if( (dta>= 'a' && dta<= 'z') || (dta>= 'A' && dta<= 'Z') || (dta == "@") || dta=="$" || dta=="#")
        {  
           return false;
           break;
   
  
        }

      }


      if(j<= stripped.length)
      {  return true; }



}


function validateform()
{
	if (document.registration.company_name.value=="")
	{
		alert("please enter company name");
		document.registration.company_name.focus();
		return false
	}
        else if (document.registration.mn_year.value=="")
	{
		alert("please enter Year of Manufacturing");
		document.registration.mn_year.focus();
		return false
	}
        
	else if (document.registration.address.value=="")
	{
		alert("please enter address");
		document.registration.address.focus();
		return false
	}
	else if (document.registration.products.value=="")
	{
		alert("please enter products");
		document.registration.products.focus();
		return false
	}
	else if (document.registration.capacity.value=="")
	{
		alert("please enter product capacity");
		document.registration.capacity.focus();
		return false
	}
        else if (document.registration.phone.value=="")
	{
		alert("please enter your Phone Number");
		document.registration.phone.focus();
		return false
	} 
        else if (document.registration.email.value=="")
	{
		alert("please enter your Email Address");
		document.registration.email.focus();
		return false
	}
	else if (isemailform(document.registration.email.value)==false)
	{
		alert("Correct the email address !.");
		document.registration.email.focus();
                document.registration.email.select();
		return false		
	}
        else if(checknumber(document.registration.mn_year.value)==false)
        {
              alert("enter correct year!.");
              document.registration.mn_year.focus();
              document.registration.mn_year.select();
              return false


        }
        else if(checknumber(document.registration.phone.value)==false)
        {
              alert("enter correct Phone Number!.");
              document.registration.phone.focus();
              document.registration.phone.select();
              return false


        }
	else
	{       
              if(document.registration.mn_year.value.length!=4)
              { alert("Length of year field should be 4!.");
                document.registration.mn_year.focus();
                document.registration.mn_year.select();
                return false; 
                 
              }
              else
              {
              
              return true;
              }   
       
           
            
	}
	
}