YAHOO.namespace('CF.www.form');

YAHOO.CF.www.form.validate = function(validators) {
	try {
		var validAll = true;
		
		validators.each(function(validator) {
			var valid = YAHOO.CF.form.validate(validator);
			
			if (!valid) {
				validAll = false;
				var hint = $('formHint_' + validator.field.id);
				if (hint) {
					hint.show();
				}
				validator.field.addClassName('invalid');
			}
		});

		return validAll;

	} catch(e) {
		alert(e);
		return false;
	} 
}


YAHOO.CF.www.form.validateForm = function(form) {
	// multiple checkboxen teller op 0 zetten
	YAHOO.CF.www.form.multipleCounter = 0;
	
	// hints verbergen
	var form = $(form.name);
	try {
		form.getInputs().each(function(input) {
			input.removeClassName('invalid');
		});
		var hints = $$('#' + form.id + ' .hintContainer');
		hints.each(function(hint) {
			hint.hide();
		}) 
		
		var validators = YAHOO.CF.form.getValidators(form);
		return YAHOO.CF.www.form.validate(validators);
	} catch(e) {
		alert(e);
		return false;
	} 
} 
