var invalidColor = "#ffcc00";
function Validate(form) {
	
	var cansubmit = "";
	var str = "Form submission failed because of the following reason(s) : \n";

	for (h=0; h<document.all.length; h++) {
		//if (document.all(h).type == "text") || (document.all(h).type == "textarea") || (document.all(h).type == "select-one") {
			if (document.all(h).required == "y") {
				filter = document.all(h).filter;
				var myVal = document.all(h).value;
				validate = myVal.match(filter);
				if (validate == null) {
					document.all(h).style.backgroundColor = invalidColor;
					str += "\n     - " + document.all(h).err;
					cansubmit += "0";
				}
				else {
					document.all(h).style.backgroundColor = "white";
					cansubmit += "1";
				}
			}
		//}
	}
	ready = cansubmit.indexOf("0")
	if (ready == "-1") {
		return true;
		//document.all(form).submit();
	}
	else {
		alert (str);
		return false;
	}
}


/*function pageValidate(form){
	if (Validate(form)){
		form.action = 'submit.asp';
		form.submit();
	}
}*/

function pageValidate(pagename){
	if (Validate(pagename)){
		document.all(pagename).submit();
	}
}
