// Simplifies the way of accessing the default ASP.NET validation framework's validators, control and label

var validatorXtAPI = {
	
	//The validators within a validation group
	validators: function(groupName) {
		var vs = $('span').filter(
			function() {
				if(this.validationGroup == groupName)
					return this;
			}
		);
		return vs;
	},
	
	//The invalid validators at this time
	invalidValidators: function(groupName) {
		var group = this.validators(groupName);
		var invalidVs = $(group).filter(
			function() {
			    if (!this.IsValid)
					return this;
			}
		);
		
		return invalidVs;
	},

	//The invalid fields at this time
	invalidFields: function(groupName) {
		var invalidVs = this.invalidValidators(groupName);
		var invalidFs = $();
		invalidVs.each( function() {
			if(!this.isvalid)
				invalidFs.push(document.getElementById(this.controltovalidate));
		});
		
		return invalidFs;
	},
	
	//Get the label for an element (if it exists)
	label: function(elem) {
		return $('label[for="' + $(elem).attr('id') + '"]');
	},
	
	//get the correct label for the text without any occurances of "*" or ":"
	labelText: function(label)
	{
		return $(label).text().replace(/[*:]/g, "");
	}
};


