/*
	This file contains some overridden functions from the asp.net file webuivalidation.js.
	This includes highlighting of input fields with errors upon client side validation
*/

// Customization performed 2007-02-28 by THV (enables regular expression validators even if input is empty):
function RegularExpressionValidatorEvaluateIsValid(val) {
	var value = ValidatorGetValue(val.controltovalidate);
	//make it fire always, if matching empty string is enabled
	if (val.matchemptystring != "true" && ValidatorTrim(value).length == 0)
	    return true;        
	var rx = new RegExp(val.validationexpression);
	var matches = rx.exec(value);
	return (matches != null && value == matches[0]);
}

// Customization performed 2007-02-28 by THV (enables highlighting of input field):
function ValidatorUpdateDisplay(val) {
    if (typeof(val.display) == "string") { 
        if (document.getElementById(val.controltovalidate)){
            document.getElementById(val.controltovalidate).style.backgroundColor = (!val.isvalid) ? 'yellow' : 'white';
        }
        if (val.display == "None") {
            return;
        }
        if (val.display == "Dynamic") {
            val.style.display = val.isvalid ? "none" : "inline";
            return;
        }
    }
    val.style.visibility = val.isvalid ? "hidden" : "visible";
}