function isPhoneNumber(str){
  var re = /^\(?[2-9]\d{2}[\)\.-]?\s?\d{3}[\s\.-]?\d{4}$/;
  return re.test(str);
}
function validate_reg(){	
	if(document.buyerreg.fname.value == "")
	{
	alert("Please enter first name.")
	document.buyerreg.fname.focus()
	return false;
	}
	
	if(!isNaN(document.buyerreg.fname.value))
	{
	alert("Please enter alphabetic value in first name.")
	document.buyerreg.fname.focus()
	return false;
	}
	
	if(document.buyerreg.lname.value == "")
	{
	alert("Please enter last name.")
	document.buyerreg.lname.focus()
	return false;
	}	
	if(!isNaN(document.buyerreg.lname.value))
	{
	alert("Please enter alphabetic value in last name.")
	document.buyerreg.lname.focus()
	return false;
	}
	
	if(document.buyerreg.bil_address.value == "")
	{
	alert("Please enter billing address.")
	document.buyerreg.bil_address.focus()
	return false;
	}
	if(document.buyerreg.bil_city1.value == "")
	{
	alert("Please enter billing city.")
	document.buyerreg.bil_city1.focus()
	return false;
	}
	
	if(document.buyerreg.bil_state.value == "")
	{
	alert("Please enter billing state.")
	document.buyerreg.bil_state.focus()
	return false;
	}
	
	
	if(document.buyerreg.bil_country.value == "")
	{
	alert("Please select billing country.")
	document.buyerreg.bil_country.focus()
	return false;
	}
	
	
	if(document.buyerreg.bil_zipcode.value == "")
	{
	alert("Please enter billing zip code.")
	document.buyerreg.bil_zipcode.focus()
	return false;
	}
	
	
	
	
	if(document.buyerreg.user_id.value == ""){
	alert("Please enter user id.")
	document.buyerreg.user_id.focus()
	return false;
	}
	
	var userid = document.buyerreg.user_id.value;
	if(!userid.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
	alert("This is not a valid user id! Please fill a valid user ID.");
	document.buyerreg.user_id.focus();
	return false;
	}	
	
	if(document.buyerreg.upass.value == ""){
	alert("Please enter password.")
	document.buyerreg.upass.focus()
	return false;
	}
	if(document.buyerreg.cpass.value == "")
	{
	alert("Please enter confirm password.")
	document.buyerreg.cpass.focus()
	return false;
	}
	if(document.buyerreg.upass.value != document.buyerreg.cpass.value)
	{
	alert("Both password does not match.")
	document.buyerreg.cpass.focus()
	return false;
	}		
	
}
function validate_edit_reg(){
	if(document.buyerreg.fname.value == "")
	{
	alert("Please enter first name.")
	document.buyerreg.fname.focus()
	return false;
	}
	
	if(!isNaN(document.buyerreg.fname.value))
	{
	alert("Please enter alphabetic value in first name.")
	document.buyerreg.fname.focus()
	return false;
	}
	
	if(document.buyerreg.lname.value == "")
	{
	alert("Please enter last name.")
	document.buyerreg.lname.focus()
	return false;
	}	
	if(!isNaN(document.buyerreg.lname.value))
	{
	alert("Please enter alphabetic value in last name.")
	document.buyerreg.lname.focus()
	return false;
	}
	
	if(document.buyerreg.phone_no.value == "")
	{	 
	alert("Please enter phone.")
	document.buyerreg.phone_no.focus()
	return false;
	}	
	if(document.buyerreg.email.value == "")
	{
	alert("Please enter email address.")
	document.buyerreg.email.focus()
	return false;
	}
	var email = document.buyerreg.email.value;
	if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
	alert("This is not a valid email id! Please fill a valid Email ID.");
	document.buyerreg.email.focus();
	return false;
	}
	if(document.buyerreg.bill_contact_name.value == "")
	{
	alert("Please enter contact name.")
	document.buyerreg.bill_contact_name.focus()
	return false;
	}
	if(document.buyerreg.bil_address.value == "")
	{
	alert("Please enter billing address.")
	document.buyerreg.bil_address.focus()
	return false;
	}
	if(document.buyerreg.bil_country.value == "")
	{
	alert("Please select billing country.")
	document.buyerreg.bil_country.focus()
	return false;
	}
	if(document.buyerreg.bil_state.value == "")
	{
	alert("Please enter billing state.")
	document.buyerreg.bil_state.focus()
	return false;
	}
	if(document.getElementById('bil_city')){
		
		if(document.buyerreg.bil_city.value == "")
		{
		alert("Please enter billing county.")
		document.buyerreg.bil_city.focus()
		return false;
		}
	
	}
	
	if(document.buyerreg.bil_city1.value == "")
	{
	alert("Please enter billing city.")
	document.buyerreg.bil_city1.focus()
	return false;
	}
	
	if(document.buyerreg.bil_zipcode.value == "")
	{
	alert("Please enter billing zip code.")
	document.buyerreg.bil_zipcode.focus()
	return false;
	}
	if(document.buyerreg.bil_phone.value == "")
	{
	alert("Please enter billing phone.")
	document.buyerreg.bil_phone.focus()
	return false;
	}	
	if(document.buyerreg.ship_contact_name.value == "")
	{
	alert("Please enter contact name.")
	document.buyerreg.ship_contact_name.focus()
	return false;
	}	
	if(document.buyerreg.ship_address.value == "")
	{
	alert("Please enter shipping address.")
	document.buyerreg.ship_address.focus()
	return false;
	}
	
	if(document.buyerreg.ship_country.value == "")
	{
	alert("Please select shipping country.")
	document.buyerreg.ship_country.focus()
	return false;
	}
	if(document.buyerreg.ship_state.value == "")
	{
	alert("Please enter shipping state.")
	document.buyerreg.ship_state.focus()
	return false;
	}
	if(document.getElementById('ship_city')){
		if(document.buyerreg.ship_city.value == "")
		{
		alert("Please enter shipping county.")
		document.buyerreg.ship_city.focus()
		return false;
		}
	}
	if(document.buyerreg.ship_city1.value == "")
	{
	alert("Please enter shipping city.")
	document.buyerreg.ship_city1.focus()
	return false;
	}
	
	
	
	if(document.buyerreg.ship_zipcode.value == "")
	{
	alert("Please enter shipping zip code.")
	document.buyerreg.ship_zipcode.focus()
	return false;
	}
	if(document.buyerreg.ship_phone.value == "")
	{
	alert("Please enter shipping phone.")
	document.buyerreg.ship_phone.focus()
	return false;
	}

}
function validate_checkout_reg(){	
	if(document.buyerreg.bill_contact_name.value == ""){
		alert("Please enter contact name.")
		document.buyerreg.bill_contact_name.focus()
		return false;
	}
	if(document.buyerreg.bil_address.value == ""){
		alert("Please enter billing address.")
		document.buyerreg.bil_address.focus()
		return false;
	}
	if(document.buyerreg.bil_country.value == ""){
		alert("Please select billing country.")
		document.buyerreg.bil_country.focus()
		return false;
	}
	if(document.buyerreg.bil_state.value == ""){
		alert("Please enter billing state.")
		document.buyerreg.bil_state.focus()
		return false;
	}	
	
	if(document.buyerreg.bil_city.value == ""){
		alert("Please enter billing city.")
		document.buyerreg.bil_city.focus()
		return false;
	}	
	if(document.buyerreg.bil_zipcode.value == ""){
		alert("Please enter billing zip code.")
		document.buyerreg.bil_zipcode.focus()
		return false;
	}
	if(document.buyerreg.bil_phone.value == ""){
		alert("Please enter billing phone.")
		document.buyerreg.bil_phone.focus()
		return false;
	}	
	if(document.buyerreg.ship_contact_name.value == "")	{
		alert("Please enter contact name.")
		document.buyerreg.ship_contact_name.focus()
		return false;
	}	
	if(document.buyerreg.ship_address.value == ""){
		alert("Please enter shipping address.")
		document.buyerreg.ship_address.focus()
		return false;
	}
	
	if(document.buyerreg.ship_country.value == ""){
		alert("Please select shipping country.")
		document.buyerreg.ship_country.focus()
		return false;
	}
	if(document.buyerreg.ship_state.value == ""){
		alert("Please enter shipping state.")
		document.buyerreg.ship_state.focus()
		return false;
	}
	if(document.buyerreg.ship_city.value == "")	{
		alert("Please enter shipping city.")
		document.buyerreg.ship_city.focus()
		return false;
	}
	
	if(document.buyerreg.ship_zipcode.value == ""){
		alert("Please enter shipping zip code.")
		document.buyerreg.ship_zipcode.focus()
		return false;
	}
	if(document.buyerreg.ship_phone.value == ""){
		alert("Please enter shipping phone.")
		document.buyerreg.ship_phone.focus()
		return false;
	}

}

function Check_Bill_Ship(chk){
	if(chk.check_add.checked==1){
		chk.ship_contact_name.value= chk.bill_contact_name.value;
		chk.ship_address.value= chk.bil_address.value;
		chk.ship_zipcode.value= chk.bil_zipcode.value;
		chk.ship_city.value = chk.bil_city.value;
		chk.ship_city1.value = chk.bil_city1.value;
		chk.ship_state.value= chk.bil_state.value;
		chk.ship_country.value= chk.bil_country.options[chk.bil_country.selectedIndex].value;
		chk.ship_phone.value= chk.bil_phone.value;		
		chk.ship_fax.value= chk.bil_fax.value;
	}   
	if(chk.check_add.checked==0){
		chk.ship_contact_name.value='';
		chk.ship_address.value= '';
		chk.ship_zipcode.value= '';
		chk.ship_city.value= '';
		chk.ship_city1.value= '';
		chk.ship_state.value= '';
		chk.ship_country.value=chk.bil_country.options[0].value;
		chk.ship_phone.value= '';		
		chk.ship_fax.value= '';
	}   
}


function Check_Bill_Ship2(chk){
	if(chk.check_add.checked==1){
	 	 bill_set_state(this.value,'');		
		//alert(document.getElementById('bil_city'));
		chk.ship_contact_name.value= chk.bill_contact_name.value;
		chk.ship_address.value= chk.bil_address.value;
		chk.ship_country.value= chk.bil_country.options[chk.bil_country.selectedIndex].value;
		chk.ship_state.value= chk.bil_state.value;
		if(document.getElementById('bil_city')){
		   chk.ship_city.value = chk.bil_city.value;
		}
		chk.ship_city1.value = chk.bil_city1.value;		
		chk.ship_zipcode.value= chk.bil_zipcode.value;	
		chk.ship_phone.value= chk.bil_phone.value;		
		chk.ship_fax.value= chk.bil_fax.value;
	}   
	if(chk.check_add.checked==0){
		chk.ship_contact_name.value='';
		chk.ship_address.value= '';
		chk.ship_country.value=chk.bil_country.options[0].value;
		chk.ship_state.value= '';
		if(document.getElementById('bil_city')){
		  chk.ship_city.value= '';
		}
		chk.ship_city1.value= '';		
		chk.ship_zipcode.value= '';	
		chk.ship_phone.value= '';		
		chk.ship_fax.value= '';
	}   
}





 function validate_chkout(){	
 if(document.buyerreg.comp_name.value == "")
	{
	alert("Please enter your company name.")
	document.buyerreg.comp_name.focus()
	return false;
	}
	
	if(document.buyerreg.fname.value == "")
	{
	alert("Please enter first name.")
	document.buyerreg.fname.focus()
	return false;
	}
	
	if(!isNaN(document.buyerreg.fname.value))
	{
	alert("Please enter alphabetic value in first name.")
	document.buyerreg.fname.focus()
	return false;
	}
	
	if(document.buyerreg.lname.value == "")
	{
	alert("Please enter last name.")
	document.buyerreg.lname.focus()
	return false;
	}
	
	if(!isNaN(document.buyerreg.lname.value))
	{
	alert("Please enter alphabetic value in last name.")
	document.buyerreg.lname.focus()
	return false;
	}	
	if(document.buyerreg.phone_no.value == "")
	{	 
	alert("Please enter phone.")
	document.buyerreg.phone_no.focus()
	return false;
	}	
	if(document.buyerreg.email.value == "")
	{
	alert("Please enter email address.")
	document.buyerreg.email.focus()
	return false;
	}
	var email = document.buyerreg.email.value;
	if(!email.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
	{
	alert("This is not a valid email id! Please fill a valid Email ID.");
	document.buyerreg.email.focus();
	return false;
	}
	if(document.buyerreg.bill_comp.value == "")
	{
	alert("Please enter billing company name.")
	document.buyerreg.bill_comp.focus()
	return false;
	}
	if(document.buyerreg.bil_address.value == "")
	{
	alert("Please enter billing address.")
	document.buyerreg.bil_address.focus()
	return false;
	}
	if(document.buyerreg.bil_zipcode.value == "")
	{
	alert("Please enter billing zip code.")
	document.buyerreg.bil_zipcode.focus()
	return false;
	}
	if(document.buyerreg.bil_city.value == "")
	{
	alert("Please enter billing city.")
	document.buyerreg.bil_city.focus()
	return false;
	}
	if(document.buyerreg.bil_state.value == "")
	{
	alert("Please enter billing state.")
	document.buyerreg.bil_state.focus()
	return false;
	}
	if(document.buyerreg.bil_country.value == "")
	{
	alert("Please select billing country.")
	document.buyerreg.bil_country.focus()
	return false;
	}
	if(document.buyerreg.bil_phone.value == "")
	{
	alert("Please enter billing phone.")
	document.buyerreg.bil_phone.focus()
	return false;
	}	
	if(document.buyerreg.ship_comp.value == "")
	{
	alert("Please enter shipping company name.")
	document.buyerreg.ship_comp.focus()
	return false;
	}	
	
	if(document.buyerreg.ship_address.value == "")
	{
	alert("Please enter shipping address.")
	document.buyerreg.ship_address.focus()
	return false;
	}
	if(document.buyerreg.ship_zipcode.value == "")
	{
	alert("Please enter shipping zip code.")
	document.buyerreg.ship_zipcode.focus()
	return false;
	}
	if(document.buyerreg.ship_city.value == "")
	{
	alert("Please enter shipping city.")
	document.buyerreg.ship_city.focus()
	return false;
	}
	if(document.buyerreg.ship_state.value == "")
	{
	alert("Please enter shipping state.")
	document.buyerreg.ship_state.focus()
	return false;
	}
	if(document.buyerreg.ship_country.value == "")
	{
	alert("Please select shipping country.")
	document.buyerreg.ship_country.focus()
	return false;
	}
	if(document.buyerreg.ship_phone.value == "")
	{
	alert("Please enter shipping phone.")
	document.buyerreg.ship_phone.focus()
	return false;
	}
 }
	
function NewWindow(mypage,myname,w,h,scroll){
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings)
}

function validate3() {
	if(document.changepwd.old_pwd.value == "")
	 {
		alert("Please enter old password.")
		document.changepwd.old_pwd.focus()
		return false;
	 }
	 if(document.changepwd.new_pwd.value == "")
	 {
		alert("Please enter new password.")
		document.changepwd.new_pwd.focus()
		return false;
	 }
	  if(document.changepwd.c_pwd.value == "")
	 {
		alert("Please enter confirm password.")
		document.changepwd.c_pwd.focus()
		return false;
	 }
	  if(document.changepwd.new_pwd.value != document.changepwd.c_pwd.value)
			 {
			   alert("Both password does not match.")
				document.changepwd.cpass.focus()
				return false;
			 } 
			 
  }
  function getship($val){
   document.frm.submit();
  }  
  function checkshipping(obj){	
	if(document.getElementById('ship').value==''){
	  alert("Plese select shipping option")	;
	  return false;
	}else{
	   obj.form.action='checkout-step1.php';
	   obj.form.submit();
	}
}
  

