function emailCheck (emailStr) 
{
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);
if (matchArray==null)
{
	alert("Email address seems incorrect enter in correct format eg:(check@yahoo.com)");
	return false;
}

var user=matchArray[1];
var domain=matchArray[2];
for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
return false;
   }
}

if (user.match(userPat)==null) {
// user is not valid
alert("The username doesn't seem to be valid.");
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
return false;
   }
}
return true;
}
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
return false;
   }
}


if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The address must end in a well-known domain or two letter " + "country.");
return false;
}
// Make sure there's a host name preceding the domain.
if (len<2) {
alert("This address is missing a hostname!");
return false;
}
// If we've gotten this far, everything's valid!

return true;
}

function uservalidate()
{
	
	var str="abcdefghijklmnopqrstuvwxyz. "
	var strnum="1234567890"
	var strName=document.form1.dentname.value;
	
	if((strName.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
	{
		var i=0;
		for(i;i < strName.length;i++)
		{
			if(str.indexOf((strName.charAt(i)).toLowerCase( ),0)<0)
			{
			alert("Please use characters only")
			document.form1.dentname.focus();
			document.form1.dentname.select();
			return false;
			}//
		}//
		
			var strPh=document.form1.phone.value;
			if(((strPh.replace(/(\s+)$/, "")).replace(/^(\s+)/,"")!=""))
			{
				if(isNaN(strPh))
				{
					alert("Please use numbers only");
					document.form1.phone.focus();
					document.form1.phone.select();
					return false;
				}			
					
			}//
		
			else
			{
				alert("Please Enter Phone No" )
				document.form1.phone.focus();
				document.form1.phone.select();
				return false;
			}		
	}
	else
	{
		alert("Please  enter Dentist's Name ");
		document.form1.dentname.focus();
		document.form1.dentname.select();
		return false; 

	}
	//second field
	var strName1=document.form1.dentname1.value;
	if((strName1.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
	{
		var i=0;
		for(i;i < strName1.length;i++)
		{
			if(str.indexOf((strName1.charAt(i)).toLowerCase( ),0)<0)
			{
			alert("Please use characters only")
			document.form1.dentname1.focus();
			document.form1.dentname1.select();
			return false;
			}//
		}
		var phNum=document.form1.phone1.value;
		if((phNum.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
		{
			if(isNaN(phNum))
			{
				alert("Please Use numbers only ");
				document.form1.phone1.select();
				document.form1.phone1.focus();
				return false;
			}
		}
		else
		{
			alert("Please Enter Phone No");
			document.form1.phone1.select();
			document.form1.phone1.focus();
			return false;
		}
	}
	//third field
	var strName2=document.form1.dentname2.value;
	if((strName2.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
	{
		var i=0;
		for(i;i < strName2.length;i++)
		{
			if(str.indexOf((strName2.charAt(i)).toLowerCase( ),0)<0)
			{
			alert("Please use characters only")
			document.form1.dentname2.focus();
			document.form1.dentname2.select();
			return false;
			}//
		}
		var phNum=document.form1.phone2.value;
		if((phNum.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
		{
			if(isNaN(phNum))
			{
				alert("Please Use numbers only ");
				document.form1.phone2.select();
				document.form1.phone2.focus();
				return false;
			}
		}
		else
		{
			alert("Please Enter Phone No");
			document.form1.phone2.select();
			document.form1.phone2.focus();
			return false;
		}
	}
	//sender field validate
	var sender=document.form1.sname.value;
	if((sender.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
	{
		var i=0;
		for(i;i < sender.length;i++)
		{
			if(str.indexOf((sender.charAt(i)).toLowerCase( ),0)<0)
			{
			alert("Please use characters only")
			document.form1.sname.focus();
			document.form1.sname.select();
			return false;
			}
		}
	}
	else
	{
		alert("Please Enter Your Name");
		document.form1.sname.select();
		document.form1.sname.focus();
		return false;
	}
	var pnum=document.form1.phno.value;
	if((pnum.replace(/(\s+)$/, "")).replace(/^(\s+)/, "")!="")
	{
		if(isNaN(pnum))
		{
			alert("Please use numbers only");
			document.form1.phno.select();
			document.form1.phno.focus();
			return false;
		}
	}
	else
	{
		alert("Please enter Your Phone Number");
		document.form1.phno.select();
		document.form1.phno.focus();
		return false;
	}
	//validation for email
	
	var email=document.form1.yemail.value;
	email=email.replace(/(\s+)$/,"");
	email=email.replace(/^(\s+)/,"");
	if(email!="")
	{
		if(emailCheck(email)==false)
		{
			document.form1.yemail.focus();
			document.form1.yemail.select();
			return false;
		}
	}
	else
	{
		alert("Please Enter Your Email");
		document.form1.yemail.focus();
		document.form1.yemail.select();
		return false;
	}
	
		
}// end of function uservalidate


function logincheck()
	{
			
	if(document.frm1.uid.value!="")
	{	
		var strName=document.frm1.uid.value;
		strName=strName.replace(/(\s+)$/,"");
		strName=strName.replace(/^(\s+)/,"");
		if(emailCheck(strName)==false)
		{		
			
			document.frm1.uid.focus();
			document.frm1.uid.select();
			return false;
		}		
	}
	else	
	{	alert("Please! Enter your User id");
		//document.frm1.uid.value="";
		document.frm1.uid.focus();
		return false;
	}
		
strName=document.frm1.pwd.value;
strName=strName.replace(/(\s+)$/,"");
strName=strName.replace(/^(\s+)/,"")
	
if(strName=="")
{
	alert("Please! Enter your password");
	document.frm1.pwd.focus();
	document.frm1.pwd.select();
	return false;
}	
	

}

function  signupvalidation()
{
  //var b_submit=true;
  //validation for company
  var company=document.signup.companyname.value;
  company=company.replace(/(\s+)$/,"");
  company=company.replace(/^(\s+)/,"");
  if((document.signup.companyname.value!="")&&( company.length >= 2 )&&( company.length <= 40 ))
  {
       	var strcomp="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz&-@0123456789. "
        
	        for ( var i=0;i<=company.length;i++ )
	         {
		       
	           if(strcomp.indexOf(company.charAt(i),0)<0)
			     {
		           alert("Please use charecters ,numbers and '&' ,'@','.' ");
				   document.signup.companyname.focus();
				   document.signup.companyname.select();
		           //b_submit=false;
		           return false; 
			      } 
	          }
    }
   else 
    {
	 
     alert("Company Name can't have less than 2 characters");
	 document.signup.companyname.focus();
	 document.signup.companyname.select();
     //b_submit=false;
     return false;
    }
	//validation for first name
	var firstname=document.signup.fname.value;
	firstname=firstname.replace(/(\s+)$/,"");
    firstname=firstname.replace(/^(\s+)/,"");
	var strfname="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	if( (document.signup.fname.value1!="") && (firstname.length >=2) && (firstname.length <=40))
	{
	   for(var i=0;i<=firstname.length;i++)
	     {
		  if(strfname.indexOf(firstname.charAt(i),0)<0)
		   {
		    alert("Please  Use charecters only")
			document.signup.fname.focus();
			document.signup.fname.select();
			//b_submit=false;
			return false;
		   }
		 }  
	}
	else
	{
	  alert("First Name can't have less than 2 characters");
	  document.signup.fname.focus();
	  document.signup.fname.select();
	  //b_submit=false;
	  return false;
	}
	//validation for street address
	var addr=document.signup.streetadds.value; 
	addr=addr.replace(/(\s+)$/,"");
	addr=addr.replace(/^(\s+)/,"");

	/*if(addr=="")
	{
		alert("Street Address can't have less than 2 characters");
			document.signup.streetadds.focus();
			document.signup.streetadds.select();
			//b_submit=true;
			return false;
	}*/
	
var lastname=document.signup.lname.value;
lastname=lastname.replace(/(\s+)$/,"");
lastname=lastname.replace(/^(\s+)/,"");
	  if( (document.signup.lname.value1=="") || ((lastname.length <2) || (lastname.length >40)))
		{
	   	//for(var i=0;i<=lastname.length;i++)
	     //{
		  //if(strfname.indexOf(lastname.charAt(i),0)<0)
		   //{
		    alert("Last Name can't have less then 2 characters");
			document.signup.lname.focus();
			document.signup.lname.select();
			//b_submit=false;
			return false;
		   //}
//		 }  
	}
	/*else
	{
	  alert("Last Name should be atleast 2 charcters ");
	  document.signup.lname.focus();
	  document.signup.lname.select();
	  //b_submit=false;
	  return false;
	}*/
	//validation for city
	var str="!@#$%^*()_+=|<>[]";
	 var city=document.signup.city.value;
	 city=city.replace(/(\s+)$/,"");
	 city=city.replace(/^(\s+)/,"");
	 if( (document.signup.city.value1=="") || ((city.length <2) || (city.length >40)))
		{
	  	    alert("City can't have less then 2 characters");
			document.signup.city.focus();
			document.signup.city.select();
			//b_submit=false;
			return false;
		}
	/*  if( (document.signup.city.value1!="") && (city.length >=2) )
	{
	   for(var i=0;i<=city.length;i++)
	     {
		  if(str.indexOf(city.charAt(i),0) > 0)
		   {
		    alert("enter city in proper formate")
			document.signup.city.select();
			document.signup.city.focus();
			//b_submit=false;
			return false;
		   }
		 }  
	}
	else
	{
	  alert("City should be atleast 2 charcter ");
	  document.signup.city.focus();
	  document.signup.city.select();
	  //b_submit=false;
	  return false;
	}*/
	 //valdation for job title
	 var job=document.signup.jobtitle.value;
	 job=job.replace(/(\s+)$/,"");
	 job=job.replace(/^(\s+)/,"");
	 var jobstr="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-\/ ";
	/*  if( (document.signup.jobtitle.value1=="") || ((jobtitle.length <2) || (jobtitle.length >40)))
		{
	  	    alert("Job Title can't have less then 2 characters");
			document.signup.jobtitle.focus();
			document.signup.jobtitle.select();
			b_submit=false;
			return false;
		}*/
	  if( (document.signup.jobtitle.value!="") && (job.length >=2) )
	{
	   for(var i=0;i<=job.length;i++)
	     {
		  if(jobstr.indexOf(job.charAt(i),0) < 0)
		   {
		    alert("Enter Job Title in proper format")
			document.signup.jobtitle.focus();
			document.signup.jobtitle.select();
			//b_submit=false;
			return false;
		   }
		 }  
	}
	else
	{
	  alert("Job Title can't have less than 2 characters ");
	  document.signup.jobtitle.focus();
	  document.signup.jobtitle.select();
	  //b_submit=false;
	  return false;
	}
	 
	 //validation for telno
	  var telstr="0123456789";
	 var phone=document.signup.telno.value;
	
	 
	   if ((document.signup.telno.value!="")&&( phone.length >=10))  
	{
	   for(var i=0;i<=phone.length;i++)
	     {
		   
		  if( telstr.indexOf(phone.charAt(i),0) < 0)
		   {
		    alert("Enter Numbers only");
			 document.signup.telno.focus();
			 document.signup.telno.select();
	         //b_submit=false;
	         return false;
		    }
		   }
		   
			 
	}
	else
	{
	  alert("Enter Telephone no. and it should not be less than 10 numbers ");
	  document.signup.telno.focus();
	  document.signup.telno.select();
	  //b_submit=false;
	  return false;
	}
	
	 /*var telstr="0123456789";
	 var phone=document.signup.telno.value;
	 phone=phone.replace(/(\s+)$/,"");
	 phone=phone.replace(/^(\s+)/,"");
	 
	 if ((document.signup.telno.value!="") && (phone.length>=10))  
	{
	   for(var i=0;i<=phone.length;i++)
	     {
		  if( telstr.indexOf(phone.charAt(i),0) < 0)
		   {
		    alert("Please ! Enter numbers only");
			 document.signup.telno.focus();
			 document.signup.telno.select();
	         //b_submit=false;
	         return false;
		    }
		   }
		}
	else if (document.signup.telno.value=="")
	{
	  alert("Telephone no. should have atleast 10 numbers ");
	  document.signup.telno.focus();
	  document.signup.telno.select();
	  //b_submit=false;
	  return false;
	}*/
	 
	 //validation for email
	 if(document.signup.emailadds.value!="")
	{	
		var strName=document.signup.emailadds.value;
		strName=strName.replace(/(\s+)$/,"");
		strName=strName.replace(/^(\s+)/,"");
		if(emailCheck (strName)==false)
		{
			document.signup.emailadds.focus();
			document.signup.emailadds.select();
			//b_submit=false;
			return false;
	 	}
				
	}else	
	{	alert("Please! Enter your email Address");
		document.signup.emailadds.focus();
		//b_submit=false;
		return false;
	}
	//validation for other
	if((document.signup.other.value=="")&&(document.signup.other.disabled!=true))
	 { 
	   alert("enter text in other");
	   document.signup.other.focus();
	   //b_submit=false;
	   return false;
	   }
//validation for question
var qandcom=document.signup.qandcom.value;
if(document.signup.qandcom.value!="")
	{
		if(qandcom.length > 2000)
		{
			alert("Description should not more than 2000 charecter");
			document.signup.qandcom.focus();
			 //b_submit=false;
			return false;
		}
	}
	return true;
} 	
	
 
function enable()
{ 
 if(document.signup.pracmgtsys.value=="others")
       document.signup.other.disabled=false;
 else 
      {
      document.signup.other.disabled=true;
	  document.signup.other.value="";
	   }
}



