// JavaScript Document
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("Email ID is invalid it should be in emailid@domain.com format ")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		
		   alert("Email ID is invalid it should be in emailid@domain.com format ")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Email ID is invalid it should be in emailid@domain.com format ")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Email ID is invalid it should be in emailid@domain.com format ")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Email ID is invalid it should be in emailid@domain.com format ")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Email ID is invalid it should be in emailid@domain.com format ")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Email ID is invalid it should be in emailid@domain.com format ")
		    return false
		 }

 		 return true					
	}
	
	

	

function ValidateForm(){

if ( document.form.fname.value == "" ) {
        alert ( "Please enter your First Name" );
        document.form.fname.focus()
	    return false;
    }
	
	
if ( document.form.lname.value == "" )     {
        alert ( "Please enter your Last Name" );
        document.form.lname.focus()
		return false;
    }
	
	var emailID=document.form.eadd
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	if ( document.form.cname.value == "" )     {
        alert ( "Please enter your Company Name" );
        document.form.cname.focus()
		return false;
    }
	
	if (document.form.phone.value != "" )     {
	var string = document.form.phone.value;	
	var Chars = "0123456789-";
    var flag = 0
	
	for (var i = 0; i < string.length; i++){ 	
	   if (Chars.indexOf(string.charAt(i)) == -1) {
	       alert("Phone number must contain numeric characters or hypens only ");                        
           flag=1;
           document.form.phone.value="";
           document.form.phone.focus();	
	       return false;
           }
		   if (flag == 1) {	       
                     break;
           }
       }    
   }
	
	if ( document.form.role.selectedIndex == 0 )
    {
        alert ( "Please select Role/Level" );
       return false;
    }
	

	
	if ( document.form.information.value == "" )     {
        alert ( "Please tell us, how may we provide you some information?" );
        document.form.information.focus()
		return false;
    }
	
	return true
 }
