/******************************************************************************************/
//	Validacion (evento)
/******************************************************************************************/

	var blnValidado = false;
	addEvent(window, 'load', function() {

		var i,j, intCount, objForm, objElement; 
		for (i=0;(objForm = document.forms[i]); i++) {
			objForm.blnValidado = true;
			objForm.arrValidadores = new Array();
			k = 0;
			for(j=0;(objElement = objForm.elements[j]); j++) {
				//////////////////////////////
				/// Obligatorio //////////////
				//////////////////////////////
				if(objElement.attributes['obligatorio']){					
					addEvent(objElement, 'blur', vldObligatorioByEvent);
					objForm.arrValidadores[k] = "vldObligatorioById('"+ objElement.name +"')";
					k++;
					}
				///////////////////////////
				/// MinLength /////////////
				///////////////////////////
				if(objElement.attributes['minlength']){
					addEvent(objElement, 'blur', vldMinLengthByEvent);
					objForm.arrValidadores[k] = "vldMinLengthById('"+ objElement.name +"')";
					k++;
					}					
				///////////////////////////
				/// MaxLength /////////////
				///////////////////////////
				if(objElement.attributes['maxlength']){
					addEvent(objElement, 'blur', vldMaxLengthByEvent);
					objForm.arrValidadores[k] = "vldMaxLengthById('"+ objElement.name +"')";
					k++;
					}
				///////////////////////////
				/// Numerico //////////////
				///////////////////////////					
				if(objElement.attributes['numerico']){
					addEvent(objElement, 'blur', vldNumericoByEvent);
					objForm.arrValidadores[k] = "vldNumericoById('"+ objElement.name +"')";
					k++;
					}
				///////////////////////////
				/// NumeroNatural /////////
				///////////////////////////					
				if(objElement.attributes['numeronatural']){
					addEvent(objElement, 'blur', vldNumeroNaturalByEvent);
					objForm.arrValidadores[k] = "vldNumeroNaturalById('"+ objElement.name +"')";
					k++;
					}
				///////////////////////////
				/// MinValue //////////////
				///////////////////////////
				if(objElement.attributes['minvalue']){
					addEvent(objElement, 'blur', vldMinValueByEvent);
					objForm.arrValidadores[k] = "vldMinValueById('"+ objElement.name +"')";
					k++;
					}
				///////////////////////////
				/// MaxValue //////////////
				///////////////////////////
				if(objElement.attributes['maxvalue']){
					addEvent(objElement, 'blur', vldMaxValueByEvent);
					objForm.arrValidadores[k] = "vldMaxValueById('"+ objElement.name +"')";
					k++;
					}
				///////////////////////////
				/// CorreoElectronico /////
				///////////////////////////
				if(objElement.attributes['correoelectronico']){
					addEvent(objElement, 'blur', vldCorreoElectronicoByEvent);
					objForm.arrValidadores[k] = "vldCorreoElectronicoById('"+ objElement.name +"')";
					k++;
					}																					
				///////////////////////////
				/// ValidationType ////////
				///////////////////////////
				if(objElement.attributes['vldtipo']){
					switch (objElement.attributes['vldtipo'].value){
						case "numeronatural": 
							addEvent(objElement, 'blur', vldNumeroNaturalByEvent);
							objForm.arrValidadores[k] = "vldNumeroNaturalById('"+ objElement.name +"')";
							k++;
							break;
						}			
					}							
				}
			addEvent(objForm, 'submit', validarForm);		
			}
		}
	);
	
	function validarForm(e){
		var i, j, objElement, objForm = getEventObject(e);
		if(objForm){
			blnValidado = true;
			for(j in objForm.arrValidadores){
				if(j != "containsValue"){ // Conflicto con Xajax
					blnValidado = blnValidado & eval(objForm.arrValidadores[j]);
					}
				}
			}
		if(blnValidado)	return true;
		if(navigator.appName == "Microsoft Internet Explorer"){
	   	e.cancelBubble = true;
  	  e.returnValue = false;
  		}
  	else {
			e.preventDefault();
			e.stopPropagation();
			}
		objForm.validado = true;
		return false;
		}
		
