function ValidationController_DisableHiddenValidators()
{
	// Loops through all the registered validation controls on the page and disables them if they are not visible
	// The Page_Validators array is provided by the ASP.Net validation controls
	// There will be no Page_Validators array if there are no validator controls on the page
	
	if (typeof(Page_Validators) != 'undefined')
	{
		bPageNeedsValidating = false;
		for (var i = 0; i < Page_Validators.length; i++)
		{
			oValidationControl = Page_Validators[i];
			sValidatedControlID = oValidationControl.getAttribute('ValidationController_ValidatedControl');
			if (sValidatedControlID != null) 
			{
				oValidatedControl = document.getElementById(sValidatedControlID);
				oValidationControl.enabled = (!oValidatedControl.disabled && !ValidationController_GetElementReadOnly(oValidatedControl));
				//alert(oValidatedControl.id + ': disabled ' + oValidatedControl.disabled + ', readonly ' + ValidationController_GetElementReadOnly(oValidatedControl) + ', ROAttribute ' + oValidatedControl.getAttribute('readonly'));
			}
		}
	}
}

function ValidationController_GetElementReadOnly(element) {
	// Unlike disabled, javascript returns 'undefined' for the readonly attribute
	if (element.getAttribute('readonly') != null)
	{
		// IE7 returns true for a readonly field, while IE8 returns 'readonly'
		return (element.getAttribute('readonly') == 'readonly' || element.getAttribute('readonly') == true)
	}
	else
	{
	  return false
	}
}


// Unused currently
function ValidationController_GetElementVisibility(element)
{
	// Returns a boolean, indicating whether the specified control is visible or not (i.e. if it is control.visible, or whether any of its parents are)
	// When element.parentNode == null then we are at the root of the tree. We do not interrogate style for this object as it causes an error
	while (element.parentNode != null) 
	{
		if (ValidationController_GetStyle(element, 'display') == 'none')
			return false;
		element = element.parentNode;
	}
	return true;
}


function ValidationController_GetStyle(oElm, strCssRule){
	var strValue = "";
	if(document.defaultView && document.defaultView.getComputedStyle){
		strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
	}
	else if(oElm.currentStyle){
		strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
			return p1.toUpperCase();
		});
		strValue = oElm.currentStyle[strCssRule];
	}
	return strValue;
}
