$(document).ready(function() {
	
	$('form.formoo').submit(function() {
		var id = $(this).attr('id');
		var form = $('form#'+id);
		var formLog = $('div#log_'+form.attr('id'));
		var formValid = true;
		var cualEsElForm=parent.document.getElementById('cualForm').innerHTML;
		formLog.html('');						
		$(':input', form).each(function(i) {
			var type = this.type;
			var value = this.value;
			var name = this.name;
			var object = $(this);
			if(type != 'hidden' && type != 'submit' && type != 'radio') {
				if(type == 'checkbox') {
					value = $('#' + form.attr('id') + ' :checkbox[name=' + name + ']:checked').size();
				}
				var data = $.ajax({url: 'includes/config/validaform.php?form=' + form.attr('id') + '&field=' + name + '&value=' + value + '&cualForm=' + cualEsElForm, async: false, type: 'GET'}).responseText;					 
				if(data) {
					object.attr('class', 'formooFieldInvalid');
					object.parent().find('span.formooPatrol').html(data);
					formValid  = false;
				} else {
					object.attr('class', 'formooFieldValid');
					object.parent().find('span.formooPatrol').html('');
				}
			}
		});
		return formValid;
		/*if(formValid){
			var vars=camposForm('formRegistro');
			recibeid('postRegistro.php','',''+vars+'','validateform');
		}*/
		this.blur();
	});
	
})