function validateEmail(addr,man,db){
	if(!checkEmail(addr,man,db)){
		document.forms[0].eail.value="";
		document.forms[0].eail.focus();
		return false;
	}


}

function checkEmail(addr,man,db) {
		
if (addr == '' && man) {
   if (db) alert('email address is mandatory');
   return false;
}
var invalidChars = '\/\'\\ ";:?!()[]\{\}^|';
for (i=0; i<invalidChars.length; i++) {
   if (addr.indexOf(invalidChars.charAt(i),0) > -1) {
      if (db) alert('email address contains invalid characters');
      return false;
   }
}
for (i=0; i<addr.length; i++) {
   if (addr.charCodeAt(i)>127) {
      if (db) alert("email address contains non ascii characters.");
      return false;
   }
}

var atPos = addr.indexOf('@',0);
if (atPos == -1) {
   if (db) alert('email address must contain an @');
   return false;
}
if (atPos == 0) {
   if (db) alert('email address must not start with @');
   return false;
}
if (addr.indexOf('@', atPos + 1) > - 1) {
   if (db) alert('email address must contain only one @');
   return false;
}
if (addr.indexOf('.', atPos) == -1) {
   if (db) alert('email address must contain a period in the domain name');
   return false;
}
if (addr.indexOf('@.',0) != -1) {
   if (db) alert('period must not immediately follow @ in email address');
   return false;
}
if (addr.indexOf('.@',0) != -1){
   if (db) alert('period must not immediately precede @ in email address');
   return false;
}
if (addr.indexOf('..',0) != -1) {
   if (db) alert('two periods must not be adjacent in email address');
   return false;
}
var suffix = addr.substring(addr.lastIndexOf('.')+1);
if (suffix.length != 2 && suffix != 'com' && suffix != 'net' && suffix != 'org' && suffix != 'edu' && suffix != 'int' && suffix != 'mil' && suffix != 'gov' & suffix != 'arpa' && suffix != 'biz' && suffix != 'aero' && suffix != 'name' && suffix != 'coop' && suffix != 'info' && suffix != 'pro' && suffix != 'museum') {
   if (db) alert('invalid primary domain in email address');
   return false;
}
return true;
}

function check_usphone(phonenumber,useareacode)  
{  
if (phonenumber.length == 11)
{
	phonenumber=phonenumber.substring(1,phonenumber.length);	
}
if(!useareacode)useareacode=1; 
if((phonenumber.match(/^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null) && ((useareacode!=1) && (phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/)==null))) {
	alert("Please Enter Correct Phone No");
	document.forms[0].phone.value="";
	document.forms[0].phone.focus();
	return false;  
}
return true;  
}  

function ValidateForm()
{
     if (document.forms[0].eail.value == "" || document.forms[0].eail.value == null)
	 {
         alert("Please enter email id ");
		 document.forms[0].eail.focus();		
		 return false;
	 }
	 else if(document.forms[0].firstName.value=="" || document.forms[0].firstName.value == null)
	 {
		 alert("Please enter your First Name ");
		 document.forms[0].firstName.focus();
		return false;
	 }
	 else if(document.forms[0].lastName.value=="" || document.forms[0].firstName.value == null)
	 {
		 alert("Please enter your Last Name ");
		 document.forms[0].lastName.focus();
		return false;
	 }
	 else if (document.forms[0].phone.value == "" || document.forms[0].phone.value == null)
           {    
                 alert("Please enter phone no ");
		 document.forms[0].phone.focus();		 
		 return false;
	 }
	return true;
}


function ValidateNewRegistration(){

  if(document.forms[0].firstName.value=="" || document.forms[0].firstName.value == null)
	 {
		 alert("Please enter your First Name ");
		 document.forms[0].firstName.focus();
		return false;
	 }
  else if(document.forms[0].lastName.value=="" || document.forms[0].lastName.value == null)
	 {
		 alert("Please enter your Last Name ");
		 document.forms[0].lastName.focus();
		return false;
	 }
 else if(document.forms[0].Company.value=="" || document.forms[0].Company.value == null)
	 {
		 alert("Please enter Company Name ");
		 document.forms[0].Company.focus();
		return false;
	 }
else if(document.forms[0].Address1.value=="" || document.forms[0].Address1.value == null)
	 {
		 alert("Please enter Address1  ");
		 document.forms[0].Address1.focus();
		return false;
	 }

else if(document.forms[0].City.value=="" || document.forms[0].City.value == null)
	 {
		 alert("Please enter City Name ");
		 document.forms[0].City.focus();
		return false;
	 }

else if(document.forms[0].Country.value=="" || document.forms[0].Country.value == null)
	 {
		 alert("Please enter Company Name ");
		 document.forms[0].Country.focus();
		return false;
	 }
else if (document.forms[0].phone.value == "" || document.forms[0].phone.value == null)
           {    
                 alert("Please enter phone no ");
		 document.forms[0].phone.focus();		 
		 return false;
	 }
else if (document.forms[0].phone.value != "" || document.forms[0].phone.value != null){
			if(!check_usphone(this.form.phone.value,'true')){
				return false;
			}
	}
else if (document.forms[0].eail.value == "" || document.forms[0].eail.value == null)
	 {
         alert("Please enter email id ");
		 document.forms[0].eail.focus();		
		 return false;
	 }

	return true;

}

function disableIt(obj)
{
	obj.disabled = !(obj.disabled);	
}


function hideshow(which){
	if (!document.getElementById)
			return
	if (which.style.display=="block")
			which.style.display="none"
	else
		which.style.display="block"
}
function deselectchekbox(obj){
	obj.checked=!(obj.checked);
}
//http://www.cs.ucsd.edu/users/bsy/area.html
//http://www.nanpa.com/area_codes/index.html