var mensaje_exp = '';

function validar_campos_exp(control,tipo,campo,oblig,msj){
	//var mensaje;
	//mensaje_exp = '';
	this.eval_exp = eval_exp;	this.no_vacio = no_vacio;
	this.no_vacio = expresiones;
	
	control_x = document.getElementById(control);
	valor_x = control_x.value;
	control_x.className = '';

	if(oblig=='1'){
		if(!no_vacio(valor_x)){
			if(msj==null){
				mensaje_exp += "<div style='padding-left:60px' class='mensaje_error'>El campo "+campo+" es obligatorio</div>";
			}else{
				mensaje_exp +=	msj;		
			}
			control_x.className = 'obligatorio';
			control_x.focus();
			return true;		}// end if
	}//end if
	
	if(oblig=='2'){
		if(valor_x<=0){
			if(msj==null){
				mensaje_exp += "<div style='padding-left:60px' class='mensaje_error'>El campo "+campo+" es obligatorio</div>";
			}else{
				mensaje_exp +=	msj;		
			}
			//control_x.nodeType;	
			control_x.className = 'obligatorio';
			control_x.focus();
			return true;		}// end if
	}//end if

	if(no_vacio(valor_x)){
		if((!eval_exp(expresiones(tipo),valor_x))){
			mensaje_exp += "<div style='padding-left:60px' class='mensaje_error'>El campo "+campo+" no es válido</div>";
			control_x.className = 'obligatorio';
			control_x.focus();
			return true;		}// end if
	}
	//alert(mensaje_exp)	function no_vacio(valor_x){		re = /.+/		var matchArray = re.exec(valor_x)
		if (matchArray){			return true		}// end if
		return false	}// end function	
	function eval_exp(patron_x,valor_x){		if (no_vacio(valor_x)){			var re = eval("/"+patron_x+"/i")			var matchArray = re.exec(valor_x)			if (matchArray){				return true			}else{				return false			}// end if					}// end if
		return true			}// end function
	
	function expresiones(tipo){
		if(tipo!=null){
			var tipo_exp = new Array();
			tipo_exp[1] = "^[-]?\\d*\\.?\\d*$";
			tipo_exp[2] = "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$";
			tipo_exp[3] = "^([ a-zA-ZñÑáéíóúÁÉÍÓÚ ]+)$";
			tipo_exp[4] = "^[JVjv]-[0-9]{1,8}(-[0-9]){0,1}$";
			tipo_exp[5] = "^([ a-z0-9A-Z+.,_#%$*&@/\\-]+)$";
			tipo_exp[6] = "^([ a-zA-Z0-9]+)$";
			tipo_exp[7] = "^([0-9]+)$";
			tipo_exp[8] = "^[-]?\\d*$";
			tipo_exp[9] = "^([ a-zA-Z0-9 /ÁÉÍÓÚáéíóúñÑ]+)$";
			return tipo_exp[tipo];
		}//end if
	}//end if
	return false;
}// end function
