


//wholesale.asp validate
function isEmail(stremail){
	var patrn = /^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/;
	return patrn.test(stremail);
}
function isValidInput(s)
{
	var patrn=/^[a-zA-Z]{1}([a-zA-Z0-9]|[.-]){1,}$/; 
	if (!patrn.exec(s)) return false;
	return true;
}

$(document).ready(function(){
	
	$("#wholesalereg #wholesalereg_btn").click(function(){
		if ($("input#Business").val()=="")
		{alert("Please enter a value for the \"Business / Store Name\" field.");$("input#Business").focus();return false;}
		if ($("input#Business").val().length<5)
		{alert("Please enter at least 5 characters in the \"Business / Store Name\" field.");$("input#Business").focus();return false;}
		//if (!isValidInput($("input#Business").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"Business / Store Name\" field.");$("input#Business").focus();return false;}
		
		if ($("input#Contact").val()=="")
		{alert("Please enter a value for the \"Contact Name\" field.");$("input#Contact").focus();return false;}
		if ($("input#Contact").val().length<5)
		{alert("Please enter at least 5 characters in the \"Contact Name\" field.");$("input#Contact").focus();return false;}
		//if (!isValidInput($("input#Contact").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"Contact Name\" field.");$("input#Contact").focus();return false;}
		
		if ($("input#Address").val()=="")
		{alert("Please enter a value for the \"Address\" field.");$("input#Address").focus();return false;}
		if ($("input#Address").val().length<5)
		{alert("Please enter at least 5 characters in the \"Address\" field.");$("input#Address").focus();return false;}

		if ($("input#City").val()=="")
		{alert("Please enter a value for the \"City\" field.");$("input#City").focus();return false;}
		if ($("input#City").val().length<2)
		{alert("Please enter at least 2 characters in the \"City\" field.");$("input#City").focus();return false;}
		//if (!isValidInput($("input#City").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"City\" field.");$("input#City").focus();return false;}
		
		if ($("input#State").val()=="")
		{alert("Please enter a value for the \"State\" field.");$("input#State").focus();return false;}
		if ($("input#State").val().length<2)
		{alert("Please enter at least 2 characters in the \"State\" field.");$("input#State").focus();return false;}
		//if (!isValidInput($("input#State").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"State\" field.");$("input#State").focus();return false;}
		
		if ($("input#Country").val()=="")
		{alert("Please enter a value for the \"Country\" field.");$("input#Country").focus();return false;}
		if ($("input#Country").val().length<2)
		{alert("Please enter at least 2 characters in the \"Country\" field.");$("input#Country").focus();return false;}

		if ($("input#ShippingAddress").val()=="")
		{alert("Please enter a value for the \"Shipping Address\" field.");$("input#ShippingAddress").focus();return false;}
		if ($("input#ShippingAddress").val().length<5)
		{alert("Please enter at least 5 characters in the \"Shipping Address\" field.");$("input#ShippingAddress").focus();return false;}
		//if (!isValidInput($("input#ShippingAddress").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"Shipping Address\" field.");$("input#ShippingAddress").focus();return false;}
		
		if ($("input#ShippingCity").val()=="")
		{alert("Please enter a value for the \"Shipping City\" field.");$("input#ShippingCity").focus();return false;}
		if ($("input#ShippingCity").val().length<2)
		{alert("Please enter at least 2 characters in the \"Shipping City\" field.");$("input#ShippingCity").focus();return false;}
		//if (!isValidInput($("input#ShippingCity").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"Shipping City\" field.");$("input#ShippingCity").focus();return false;}
		
		if ($("input#ShippingState").val()=="")
		{alert("Please enter a value for the \"Shipping State\" field.");$("input#ShippingState").focus();return false;}
		if ($("input#ShippingState").val().length<2)
		{alert("Please enter at least 2 characters in the \"Shipping State\" field.");$("input#ShippingState").focus();return false;}
		//if (!isValidInput($("input#ShippingState").val()))
		//{alert("Please enter only letter, digit, whitespace and \"-.\" characters in the \"Shipping State\" field.");$("input#ShippingState").focus();return false;}
		
		if ($("input#ShippingCountry").val()=="")
		{alert("Please enter a value for the \"Shipping Country\" field.");$("input#ShippingCountry").focus();return false;}
		if ($("input#ShippingCountry").val().length<2)
		{alert("Please enter at least 2 characters in the \"Shipping Country\" field.");$("input#ShippingCountry").focus();return false;}

		if ($("input#Phone").val()=="")
		{alert("Please enter a value for the \"Phone Number\" field.");$("input#Phone").focus();return false;}
		if ($("input#Phone").val().length<10)
		{alert("Please enter at least 10 characters in the \"Phone Number\" field.");$("input#Phone").focus();return false;}

		if ($("input#Fax").val()=="")
		{alert("Please enter a value for the \"Fax Number\" field.");$("input#Fax").focus();return false;}
		if ($("input#Fax").val().length<10)
		{alert("Please enter at least 10 characters in the \"Fax Number\" field.");$("input#Fax").focus();return false;}

		if ($("input#TaxID").val()=="")
		{alert("Please enter a value for the \"Tax ID\" field.");$("input#TaxID").focus();return false;}
		if ($("input#TaxID").val().length<2)
		{alert("Please enter at least 2 characters in the \"Tax ID\" field.");$("input#TaxID").focus();return false;}

		if ($("input#StoreType").val()=="")
		{alert("Please enter a value for the \"Store Type\" field.");$("input#StoreType").focus();return false;}

		if ($("input#email").val()=="")
		{alert("Please enter a value for the \"email\" field.");$("input#email").focus();return false;}
		if (!isEmail($("input#email").val()))
		{alert("Please enter a valid email address");$("input#email").focus();return false;}
		
	});

	$("#wholesalereg #FillField").click(function(){
		if ($("input#FillField[checked]").val()=="on")
		{
			$("input#ShippingAddress").val($("input#Address").val());
			$("input#ShippingAddress2").val($("input#Address2").val());
			$("input#ShippingCity").val($("input#City").val());
			$("input#ShippingState").val($("input#State").val());
			$("input#ShippingCountry").val($("input#Country").val());
		}
	});
	
});