<!-- //

var errorMessage = "";

function chkForm(theform) {
	var hidden = theform.private;
	var storename = theform.storename.value;
	var storetype = theform.storetype.value;
	var email = theform.email.value;
	var phone = theform.phone.value;
	var website = theform.website.value;
	var storefront = theform.storefront.value;
	var split = storefront.split(".");
	var taxnumber = theform.taxnumber.value;
	var baddress = theform.baddress.value;
	var bcity = theform.bcity.value;
	var bstate = theform.bstate.value;
	var bzip = theform.bzip.value;
	var saddress = theform.saddress.value;
	var scity = theform.scity.value;
	var sstate = theform.sstate.value;
	var szip = theform.szip.value;
	var temail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	if(storename.length == 0){
		setError("- Store name");
	}
	if(storetype == "0"){
		setError("- Store type");
	}
	if(email == 0){
		setError("- E-mail");
	}
	if(email !=0 && email.search(temail) == -1){
		setError("- A valid email address");
	}
	if(phone <= 8){
		setError("- Valid phone number");
	}
	if(storetype == "1" || storetype == "3"){
		if(website == 0 || website == "http://"){
			setError("- Website");
		}
		if(baddress == "Address"){
			setError("- Billing address");
		}
		if(bcity == "City"){
			setError("- Billing city");
		}
		if(bstate == "State"){
			setError("- Billing state");
		}
		if(bzip == "Zip"){
			setError("- Billing zip");
		}
		if(saddress == "Address"){
			setError("- Shipping address");
		}
		if(scity == "City"){
			setError("- Shipping city");
		}
		if(sstate == "State"){
			setError("- Shipping state");
		}
		if(szip == "Zip"){
			setError("- Shipping zip");
		}
	}
	if(storetype == "2" || storetype == "3"){
		if(storefront == 0){
			setError("- Store front or lease image");
		}
		if(split[split.length-1] != "png" && split[split.length-1] != "jpg" && split[split.length-1] != "gif"){
			setError("- Store front or lease image must be either jpg, png, or gif");
		}
		if(taxnumber == 0){
			setError("- Tax number");
		}
		if(baddress == "Address"){
			setError("- Billing address");
		}
		if(bcity == "City"){
			setError("- Billing city");
		}
		if(bstate == "State"){
			setError("- Billing state");
		}
		if(bzip == "Zip"){
			setError("- Billing zip");
		}
		if(saddress == "Address"){
			setError("- Shipping address");
		}
		if(scity == "City"){
			setError("- Shipping city");
		}
		if(sstate == "State"){
			setError("- Shipping state");
		}
		if(szip == "Zip"){
			setError("- Shipping zip");
		}
	}

	if(errorMessage.length == 0){
		hidden.value = "privatevar";
		return true;
	} else {
		alert("Please enter the following:\r\n"+errorMessage);
		errorMessage = "";
		return false;
	}
}

function setError(x) {
	errorMessage += x + "\r\n";
}

function parsePhone(obj) {
	number = obj.value;
	if(number.match(/[\(\)-]/g)) {
		number = obj.value.replace(/[\(\)-]/g,"");
	}
	setOne = "(" + number.substring(0,3) + ")";
	setTwo = number.substring(3,6) + "-";
	setThree = number.substring(6,10);
	obj.value = setOne + setTwo + setThree;
}

// -->
