
function validar_formulario(formulario)
{
	/*
		ob = OBLIGATORIO
		no = NO OBLIGATORIO

		tx = TEXTO
		se = SELECT
		ch = CHECKBOX
		nu = NUMÉRICO
		fh = FECHA
		fp = FECHA PARTIDA
		fn = FECHA NACIMIENTO
		me = TEXTAREA
		em = E-MAIL
	*/

	var problema = false

	for (i=0;i<formulario.length;i++)
	{
		var tempobj = formulario.elements[i]
		var campo_ = (formulario.name + "." + tempobj.name);
		var nombre_ = "";
	
		if ( typeof(tempobj.nombre) != "undefined" )
			nombre_ = tempobj.nombre.toUpperCase();

		if ( (tempobj.type) != "hidden" )
		{

			switch ( tempobj.name.substring(0,5) )
			{
				case "ob_tx": 	if (obligatorio(campo_, nombre_)) { problema = true; }
								break;
				case "ob_me": 	if (obligatorio(campo_, nombre_)) { problema = true; }
								break;
				case "ob_se":	if ( uno_seleccionado(campo_,nombre_)) { problema = true; }
								break;
				case "ob_em": 	if (!esemail(campo_, nombre_)) { problema = true; }
								break;
				case "ob_nu": 	if (numerico(campo_, nombre_)) { problema = true; }
								break;
				case "ob_fp": 	d_ = eval(formulario.name + "." + tempobj.name.substring(0,5) + "_dia.value");
								m_ = eval(formulario.name + "." + tempobj.name.substring(0,5) + "_mes.value");
								y_ = eval(formulario.name + "." + tempobj.name.substring(0,5) + "_anyo.value");
								
								if ( !isDate(y_, m_, d_) )
								{
									if ( ( d_ == 0 ) && ( m_ == 0 ) && ( y_ ==  0 ) )
										alert("El campo FECHA DE LA OFERTA es obligatorio");
									else
										alert("El campo FECHA DE LA OFERTA es incorrecto");

									eval(formulario.name + "." + tempobj.name.substring(0,5) + "_dia.focus()");

									problema = true;
								}

								break;
				case "ob_fn": 	d_ = eval(formulario.name + "." + tempobj.name.substring(0,5) + "_dia.value");
								m_ = eval(formulario.name + "." + tempobj.name.substring(0,5) + "_mes.value");
								y_ = eval(formulario.name + "." + tempobj.name.substring(0,5) + "_anyo.value");
								
								if ( !isDate(y_, m_, d_) )
								{
									if ( ( d_ == 0 ) && ( m_ == 0 ) && ( y_ ==  0 ) )
										alert("El campo FECHA DE NACIMIENTO es obligatoria");
									else
										alert("El campo FECHA DE NACIMIENTO es incorrecta");

									eval(formulario.name + "." + tempobj.name.substring(0,5) + "_dia.focus()");

									problema = true;
								}

								break;
				case "no_nu": 	if (!isEmpty((eval(campo_)).value) && numerico(campo_, nombre_)) { problema = true; }
								break;
				case "no_em": 	if (!isEmpty((eval(campo_)).value) && !esemail(campo_, nombre_)) { problema = true; }
								break;
			}
		}

		if ( problema )
			break;
	}

	return !problema;
}

