function checkInput(that, type) {
	val = that.value;
	new_val = "";
	for (i=0; i<val.length; i++) {
		isNumber = (val.charCodeAt(i) >= 48 && val.charCodeAt(i) <= 57);
		isLetter = ((val.charCodeAt(i) >= 65 && val.charCodeAt(i) <= 90) || (val.charCodeAt(i) >= 97 && val.charCodeAt(i) <= 122));
		isValidForEmail = (val.charCodeAt(i) == 64 ||
		                   val.charCodeAt(i) == 95 ||
		                   val.charCodeAt(i) == 45 ||
		                   val.charCodeAt(i) == 46);
		isValidForAddress = (val.charCodeAt(i) == 32 ||
		                     val.charCodeAt(i) == 44 ||
		                     val.charCodeAt(i) == 35 ||
		                     val.charCodeAt(i) == 45 ||
		                     val.charCodeAt(i) == 46);
		//alert(val.charCodeAt(i));
		if (type == "123" && isNumber) {
			new_val += val.substr(i,1);
		} else if (type == "abc" && isLetter) {
			if (i == 0)
				new_val += val.substr(i,1).toUpperCase();
			else
				new_val += val.substr(i,1).toLowerCase();
		} else if (type == "add" && ((isNumber || isLetter) || isValidForAddress)) {
			if (val.substr(i-1,1) == " " || i == 0)
				new_val += val.substr(i,1).toUpperCase();
			else
				new_val += val.substr(i,1).toLowerCase();
		} else if (type == "@" && ((isNumber || isLetter) || isValidForEmail)) {
			new_val += val.substr(i,1);
		} else if (type == "ph" && isNumber) {
			new_val += val.substr(i,1);
		} else if (type == "st" && isLetter) {
			new_val += val.substr(i,1).toUpperCase();
		}
	}
	if (type == "ph") {
		if (new_val.length >= 6)
			new_val = new_val.substr(0,3) + "-" + new_val.substr(3,3) + "-" + new_val.substr(6,4);
		else if (new_val.length >= 3)
			new_val = new_val.substr(0,3) + "-" + new_val.substr(3,3);
	}
	if (type == "@" && 0)
		document.getElementById("login").innerHTML = new_val.toLowerCase();
	that.value = new_val;
	return true;
}
function validate() {
	okay = true;
	if (document.getElementById("first_name").value.length < 2) {
		document.getElementById("first_name").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("first_name").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("last_name").value.length < 2) {
		document.getElementById("last_name").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("last_name").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("address1").value.length < 5) {
		okay = false;
		document.getElementById("address1").style.backgroundColor = "#FFDDDD";
	} else {
		document.getElementById("address1").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("city").value.length < 3) {
		document.getElementById("city").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("city").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("zip").value.length != 5) {
		document.getElementById("zip").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("zip").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("phone").value.length < 12) {
		document.getElementById("phone").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("phone").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("email").value.length < 5) {
		document.getElementById("email").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("email").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("password").value.length < 4) {
		document.getElementById("password").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("password").style.backgroundColor = "#FFFFFF";
	}
	if (document.getElementById("state").value.length != 2 || "AL|AK|AZ|AR|CA|CO|CT|DE|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|NC|ND|NE|NH|NJ|NM|NY|NV|OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VA|VT|WA|WV|WI|WY".indexOf(document.getElementById("state").value) == -1) {
		document.getElementById("state").style.backgroundColor = "#FFDDDD";
		okay = false;
	} else {
		document.getElementById("state").style.backgroundColor = "#FFFFFF";
	}
	if (okay) {
		return true;
	} else {
		alert("Please correct the highlighted fields.");
		return false;
	}
}