
function valid()
{

//alert('hello');


	 if (document.addaddress.title.value=="") 
	{
		alert("Please enter Title");
		document.addaddress.title.focus();
		return false;
	}
	if(document.addaddress.title.value.length >= 1 )
	{
		chk1="!@#$%^&*|\~`{}[]:<>?/,";
		for(i=0;i!=document.addaddress.title.value.length;i++)
		{
			ch1=document.addaddress.title.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter valid Title");
				document.addaddress.title.focus();
				return false;
				break;
			}
		}
	}

	 if (document.addaddress.firstname.value=="") 
	{
		alert("Please enter First Name");
		document.addaddress.firstname.focus();
		return false;
	}
	if(document.addaddress.firstname.value.length >= 1 )
	{
		chk1="!@#$%^&*|\~`{}[]:<>?/,";
		for(i=0;i!=document.addaddress.firstname.value.length;i++)
		{
			ch1=document.addaddress.firstname.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter valid First Name");
				document.addaddress.firstname.focus();
				return false;
				break;
			}
		}
	}
	
	 if (document.addaddress.lastname.value=="") 
	{
		alert("Please Enter Last Name");
		document.addaddress.lastname.focus();
		return false;
	}
	if(document.addaddress.lastname.value.length >= 1 )
	{
		chk1="!@#$%^&*|\~`{}[]:<>?/,";
		for(i=0;i!=document.addaddress.lastname.value.length;i++)
		{
			ch1=document.addaddress.lastname.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter valid Last Name");
				document.addaddress.lastname.focus();
				return false;
				break;
			}
		}
	}
	
	 if (document.addaddress.address1.value=="") 
	{
		alert("Please Enter Address");
		document.addaddress.address1.focus();
		return false;
	}
	/*if(document.addaddress.address1.value.length >= 1 )
	{
		chk1="!@$%^&*|\~`{}[]:<>?";
		for(i=0;i!=document.addaddress.address1.value.length;i++)
		{
			ch1=document.addaddress.address1.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter valid Address");
				document.addaddress.address1.focus();
				return false;
				break;
			}
		}
	}*/


if(document.addaddress.address1.value.length >= 1 )
	{
	
	var add1=document.addaddress.address1.value;
		add1=add1.toUpperCase();
		var quote= new Array(5)
		quote[0]="PO BOX";
		quote[1]="P O BOX";
		quote[2]="P.O. BOX";
		quote[3]="P.O.BOX";
		quote[4]="P.O BOX";


		for(i=0;i<quote.length;i++)
		{
	
			rtn1=add1.indexOf(quote[i]);
			if(rtn1!=-1)
			{
				alert("We do NOT ship to PO Addresses - so please do not place orders with PO Box address");
				document.addaddress.address1.focus();
				return false;
				break;
			}
		}
	}

if(document.addaddress.address2.value.length >= 1 )
	{
	
	var add2=document.addaddress.address2.value;
		add2=add2.toUpperCase();
	
		var quote= new Array(5)
		quote[0]="PO BOX";
		quote[1]="P O BOX";
		quote[2]="P.O. BOX";
		quote[3]="P.O.BOX";
		quote[4]="P.O BOX";
		quote[5]="P.O BOX";


		for(i=0;i<quote.length;i++)
		{
	
			rtn1=add2.indexOf(quote[i]);
			if(rtn1!=-1)
			{
				alert("We do NOT ship to PO Addresses - so please do not place orders with PO Box address");
				document.addaddress.address2.focus();
				return false;
				break;
			}
		}
	}


	 if (document.addaddress.city.value=="") 
	{
		alert("Please Enter City");
		document.addaddress.city.focus();
		return false;
	}
	if(document.addaddress.city.value.length >= 1 )
	{
		chk1="!@#$%^&*|\~`{}[]:<>?/,";
		for(i=0;i!=document.addaddress.city.value.length;i++)
		{
			ch1=document.addaddress.city.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter valid City");
				document.addaddress.city.focus();
				return false;
				break;
			}
		}
	}

	 if (document.addaddress.state.value=="") 
	{
		alert("Please Enter State");
		document.addaddress.state.focus();
		return false;
	}
	if(document.addaddress.state.value.length >= 1 )
	{
		chk1="!@#$%^&*|\~`{}[]:<>?/,";
		for(i=0;i!=document.addaddress.state.value.length;i++)
		{
			ch1=document.addaddress.state.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter valid State");
				document.addaddress.state.focus();
				return false;
				break;
			}
		}
	}

if (document.addaddress.zip.value.replace(/^\s+|\s+$/g,"")=="") 
	{
		alert("Please enter Zip Code");
		document.addaddress.zip.focus();
		return false;
	}
	else
	{
			if(document.addaddress.country.value == "US")
				{
					var str=document.addaddress.zip.value;
					var re = /^\d{5}([\-]\d{4})?$/;
					if (re.test(str))
					{
					}
					else
					{
								alert("Please enter a valid Zip Code !")
								document.addaddress.zip.focus();
								return false;
					}
				}
	}


/*	
	 if (document.addaddress.zip.value=="") 
	{
		alert("Please Enter Zip");
		document.addaddress.zip.focus();
		return false;
	}
*/
/*
if(document.addaddress.zip.value.length >= 1 )
{
	chk1="!@#$%^&*|\~`{}[]:<>?/,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
	for(i=0;i!=document.addaddress.zip.value.length;i++)
	{
		ch1=document.addaddress.zip.value.charAt(i);
		rtn1=chk1.indexOf(ch1);
		if(rtn1!=-1)
		{
			alert("Please Enter valid Zip");
			document.addaddress.zip.focus();
			return false;
			break;
		}
	}
}
*/

if (document.addaddress.phone.value=="") 
{
	alert("Please enter Phone No");
	document.addaddress.phone.focus();
	return false;
}





	if (document.addaddress.email.value.replace(/^\s+|\s+$/g,"")=="") 
	{
		alert("Please enter E-Mail");
		document.addaddress.email.focus();
		return false;
	}
	else
	{
			
			var str=document.addaddress.email.value;
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			//var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (filter.test(str))
			{
					sliptarr = str.split("@");
					var emailRegEx1 = /[a-zA-Z]+/;
					if(sliptarr[0].match(emailRegEx1))
					{
					}
					else
					{
						alert("Please input a valid email address!")
						document.addaddress.email.focus();
						return false;
					}
				
			}
			else
			{
				alert("Please input a valid email address!")
				document.addaddress.email.focus();
				return false;
			}
			
					/*
					//update mail validation on 28_7_08
					
					var regex=new RegExp(/^[\w\_\.]+@[^\.]+.\w{1,3}\W\w{2,3}$/)
					if(document.addaddress.email.value.length > 0 && regex.test(document.addaddress.email.value)==false)
					{
					//error=3;
								alert("Please input a valid email address!")
								document.addaddress.email.focus();
								return false;
					}
					*/
					
			
	}







/*
	 if (document.addaddress.email.value=="") 
	{
		alert("Please enter Email");
		document.addaddress.email.focus();
		return false;
	}
	if(document.addaddress.email.value.length >= 1 )
	{
		chk1=" !#$%^&*|\~`{}[]:<>?/,";
		for(i=0;i!=document.addaddress.email.value.length;i++)
		{
			ch1=document.addaddress.email.value.charAt(i);
			rtn1=chk1.indexOf(ch1);
			if(rtn1!=-1)
			{
				alert("Please Enter Your Valid Email!!");
				document.addaddress.email.focus();
				return false;
				break;
			}
		}
	}

*/	
	
}
