// JavaScript Document

function ValidateForm(frm) {
	for(var i=0; i<frm.elements.length; i++) {
		if(frm.elements[i].getAttribute('regex')) {
			if(!validateCustom(frm.elements[i]))
				return false;
		}
	}
	return true;
}
function validateCustom(o) {
	var regex = new RegExp(o.getAttribute('regex'));
	if(!regex.test(o.value)) {
		return displayError(o,1,1,"The hilited field is invalid.");
	}		
	return true;
}
function displayError(o, sel, foc, strError) {
	alert((o.getAttribute('emsg')) ? o.getAttribute('emsg') : strError);
	if(sel) o.select();
	if(foc) o.focus();
	//o.ErrHilite();
	return false;
}
