// JavaScript Document
// JavaScript Document

function validateEmail(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 login_validation()
{
	var txtemail2= document.sellerlogin.txtemail2.value;
		 if (txtemail2== "" )
		 { 
			 alert ("Please enter User Name");
			 document.sellerlogin.txtemail2.focus();
			 return false;
		 }
	var txtpass2 = document.sellerlogin.txtpass2.value;
		 if (txtpass2 == "" )
		 { 
			 alert ("Please enter your Password");
			 document.sellerlogin.txtpass2.focus();
			 return false;
		 }
}
//script for add member
function member_reg(type)
{	
	 var firstname = document.CustomersForm.firstname.value;
	 if (firstname == "" )
	 { 
	 alert ("Please enter the First Name");
	 document.CustomersForm.firstname.focus();
	 return false;
	 }
/*	 var lastname = document.CustomersForm.lastname.value; 
	 if (lastname == "")
	 { 
	 alert ("Please enter the Last Name");
	 document.CustomersForm.lastname.focus();
	 return false;
	 }*/
	 var emailid = document.CustomersForm.emailid.value;
	 if (emailid == "")
/*	 { 
	 alert ("Please enter the Email Address");
	 document.CustomersForm.emailid.focus();
	 return false;
	 }	
*/	 if (emailid != "")
	{
	 if (!validateEmail(document.CustomersForm.emailid.value,1,1)) 
	 {
	 document.CustomersForm.emailid.focus();
	 return false;
	 }
	}
/*	 var address1 = document.CustomersForm.address.value;
	 if (address1 == "" )
	 { 
	 alert ("Please enter the Address");
	 document.CustomersForm.address.focus();
	 return false;
	 }
	 var city=document.CustomersForm.city.value;
	 if (city=="" )
	 { 
	 alert ("Please enter the City Name");
	 document.CustomersForm.city.focus();
	 return false;
	 }
	 var state = document.CustomersForm.state.value;
	 if (state == "Choose")
	 { 
	 alert ("Please Choose the State Name");
	 document.CustomersForm.state.focus();
	 return false;
	 }
	 	 var zipcode = document.CustomersForm.zipcode.value;
	 if (zipcode == "" )
	 { 
	 alert ("Please enter the Post Code");
	 document.CustomersForm.zipcode.focus();
	 return false;
	 }	
	 if (isNaN(document.CustomersForm.zipcode.value))
	 { 
	 alert ("Post Code must be numeric");
	 document.CustomersForm.zipcode.focus();
	 return false;
	 }	
	 var country=document.CustomersForm.country.value;
	 if (country == "")
	 { 
	 alert ("Plese Enter Country");
	 document.CustomersForm.country.focus();
	 return false;
	 }
	 var phoneno = document.CustomersForm.phoneno.value;
	 if (phoneno == "")
	 { 
	 alert ("Please enter the Phone Number");
	 document.CustomersForm.phoneno.focus();
	 return false;
	 }	
	 if (isNaN(document.CustomersForm.phoneno.value))
	 { 
	 alert ("Phone Number must be numeric");
	 document.CustomersForm.phoneno.focus();
	 return false;
	 }	*/
	 
	 if(type != "edit")
	 {
		 var  Username= document.CustomersForm.username.value;
		 if (Username == "")
		 { 
		 alert ("Please enter the User Name");
		 document.CustomersForm.username.focus();
		 return false;
		 }	
		 var  password= document.CustomersForm.password.value;
		 if (password == "")
		 { 
		 alert ("Please enter the password");
		 document.CustomersForm.password.focus();
		 return false;
		 }	
		 var  confirmpass= document.CustomersForm.confirmpass.value;
		 if (confirmpass == "")
		 { 
		 alert ("Please enter the Confirm Password");
		 document.CustomersForm.confirmpass.focus();
		 return false;
		 }	
		 if (password != confirmpass)
		 { 
		 alert ("Password and Confirm Password must be the same");
		 document.CustomersForm.confirmpass.focus();
		 return false;
		 }	
	 }

}