/*
	validationfunctions.js
	Funciones de validacion de datos
*/

var IDS_ERR_FECHA_ERRONEA = "-2147221386";
var IDS_ERR_NO_ES_NUMERO = "-2147221385";
var IDS_ERR_NO_PUEDE_SER_CERO = "-2147221384";
var IDS_ERR_CANT_ENTEROS = "-2147221383";
var IDS_ERR_CANT_DECIMALES = "-2147221382";
var IDS_ERR_NO_SELECCIONO_UN_ITEM = "-2147221381";
var IDS_ERR_NO_HAY_ITEMS = "-2147221380";
var IDS_ERR_DEBE_COMPLETAR_EL_CAMPO = "-2147221379";
var IDS_ERR_LONGITUD_MAXIMA = "-2147221378";
var IDS_ERR_LONGITUD_MINIMA = "-2147221377";
var IDS_ERR_SELECCIONO_MAS_DE_UN_ITEM = "-2147221368";
var IDS_ERR_FECHA_ERRONEA_MAYOR = "-2147221359";


// Pregunta al usuario si confirma la acción
function confirmar(tipo, obl)
{
	var aux = "";
	var re;
			
	if (obl == 1)
	{
		aux = obtenerEtiqueta(szuil, "ż Está seguro de que desea %1 ?");
		re = /%1/;
		aux = aux.replace(re, tipo);
		
		if (confirm(aux))
		{
			window.event.returnValue = true; 	
			return true;
		}
		else
		{
			window.event.returnValue = false; 	
			return false;
		}		
	}
	else
	{										
		window.event.returnValue = false; 				
		return true;				
	}			
}

// Valida la fecha y la hora en un campo
function val_fecha_y_hora(campo, nom, Bloque, obl, errpage) 
{
	var valor = campo.value;
	
	var re = /%1/;
	var me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha_y_hora&description=" + obtenerEtiqueta(szuil, IDS_ERR_FECHA_ERRONEA) + ". Bloque: " + Bloque;
	me = me.replace(re, nom);

	if (valor.toString().length > 0) {
		
		// La fecha no es valida
		if (valor.toString().length < 10) {
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
		
		// Valido la fecha
		if (!checkdate(valor.substr(0,10))) {
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
		
		// Si hay hora valido la hora
		if (valor.toString().length > 10 && valor.toString().length < 19) {
			me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha_y_hora&description=La porcion se la hora del campo %1 es inválida, especifique dd/mm/aaaa hh:mm:ss. Bloque: " + Bloque;
			me = me.replace(re, nom);
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
		
		// Validar la hora
		var hh = valor.substr(11,2);
		var mm = valor.substr(14,2);
		var ss = valor.substr(17,2);
		
		if (hh<0 || hh>23) {
			me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha_y_hora&description=La porcion se la hora del campo %1 es inválida, especifique dd/mm/aaaa hh:mm:ss. Bloque: " + Bloque;
			me = me.replace(re, nom);
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
		
		if (mm<0 || mm>59) {
			me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha_y_hora&description=La porcion se la hora del campo %1 es inválida, especifique dd/mm/aaaa hh:mm:ss. Bloque: " + Bloque;
			me = me.replace(re, nom);
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}

		if (ss<0 || ss>59) {
			me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha_y_hora&description=La porcion se la hora del campo %1 es inválida, especifique dd/mm/aaaa hh:mm:ss. Bloque: " + Bloque;
			me = me.replace(re, nom);
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	}
	else {
		if (obl==1) {
			me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha_y_hora&description=El campo %1 es obligatorio. Bloque: " + Bloque;
			me = me.replace(re, nom);
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	}
	return true;
}

/*
  jscript date checking function
*/

function checkdate(mydate)
{
var dateArray = new Array(21);							// will received parsed output
var i, j, err, b, c, d, e, f, g;

	// insurance
	for (i=0; i<dateArray.length; i++) {
		dateArray[i] = "";
	}

	a = mydate;
	i = 0;												// index for output array

	for (j=0; j<a.length; j++) {
		if ((isNaN(a.charAt(j)))) {						// test jth input char
			i++;										// step past possible numerics
			dateArray[i] = a.charAt(j);					// deposit non-numeric separator
			i++;										// step past	
		}          
		else {											// numeric
			dateArray[i] = dateArray[i] + a.charAt(j);	// concatenate
		}
	}

	/*
	// date format: mm/dd/yyyy
	b = dateArray[0] //a.substring(0, 2) month
	c = dateArray[1] //a.substring(2, 3) '/'
	d = dateArray[2] //a.substring(3, 5) day
	e = dateArray[3] //a.substring(5, 6) '/'
	f = dateArray[4] //a.substring(6, 10) year
	g = dateArray[5] //
	*/

	// date format: dd/mm/yyyy
	d = dateArray[0] //a.substring(0, 2) day
	c = dateArray[1] //a.substring(2, 3) '/'
	b = dateArray[2] //a.substring(3, 5) month
	e = dateArray[3] //a.substring(5, 6) '/'
	f = dateArray[4] //a.substring(6, 10) year
	g = dateArray[5] //

	//basic error checking
	err = 0;
	if (isNaN(b))			err = 1;
	if (b<1 || b>12)		err = 2;
	if (c != '/')			err = 3;
	if (isNaN(d))			err = 4;
	if (d<1 || d>31)		err = 5;
	if (e != '/')			err = 6;
	if (isNaN(f))			err = 7;
	if (f<1900 || f>3000)	err = 8;
	if (g != '')			err = 9;

	//advanced error checking
	if (b==4 || b==6 || b==9 || b==11) {  // months with 30 days
		if (d>30)			err = 10;
	}

	// february, leap year
	if (b==2) {        // feb
		g = parseInt(f/4);
		if (isNaN(g)) {
			err = 11;
		}

		if (d>29)			err = 12;
		if (d==29 && ((f/4)!=parseInt(f/4))) err = 13; // test remainder > 0
	}
 
	if (err>0) {
		return (false);
	}
	else {
		return (true);
	}
}

/*
  end of jscript date checking function
*/


// Validar valores de fecha
function val_fecha(campo, nom, Bloque, obl, errpage)
{
	var fec = new Date()
	var tot = campo.value;

	var y = campo.value;
	var m = campo.value;
	var d = campo.value;
	
	y = y.substr(6,4);
	m = m.substr (3,2);
	d = d.substr (0,2);

	var f = tot.length;
	var re = /%1/;
	var me = errpage + "?number=" + IDS_ERR_FECHA_ERRONEA + "&source=javascript;val_fecha&description=" + obtenerEtiqueta(szuil, IDS_ERR_FECHA_ERRONEA) + ". Bloque: " + Bloque;
	me = me.replace(re, nom);
	
	if (obl==1) {		
		if (f != 10) {
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	}
	else {
		if (f != 0) {
			if (f != 10) {
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
		else {
			return true;
		}
	}
	
	// Verificar si las barras están correctas
	if (tot.substr(2,1) != '/' && tot.substr(5,1) != '/') {
		window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
		window.event.returnValue = false; 	
		return false;
	}

	// Verificar los valores
	if (obl == 1) {
		if (y<1000)
		{
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	} else {
		if ((f!=0) && (y<1000))
		{
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	}
	if (obl == 1) {
		if ((m<1) || (m>12))
		{
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	} else {
		if((f!=0)) {
			if ((m<1) || (m>12))
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
	}
	if (obl == 1) {
		if (d<1)
		{
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	} else {
		if((f!=0)) {
			if (d<1)
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
	}
	if (obl == 1 ) {
		if (d>31)	
		{
			window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	} else {
		if((f!=0)) {
			if (d>31)	
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}	
		}
	}
	if(obl == 1) {
		if (m==4)
		{
			if (d>30)
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
	} else {
		if (f!=0) 
		{
			if (m==4)
			{
				if (d>30)
				{
					window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 	
					return false;
				}
			}
		}
	}
	if(obl == 1) {
		if (m==6)
		{
			if (d>30)
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 					 
				return false;
			}
		}
	} else {
		if (f!=0) {
			if (m==6)
			{
				if (d>30)
				{
					window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 						 
					return false;
				}
			}
		}
	}
	if(obl == 1) {
		if (m==9)
		{
			if (d>30)
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
	} else {
		if (f!=0) {
			if (m==9)
			{
				if (d>30)
				{
					window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 							 
					return false;
				}
			}
		}
	}
	if(obl == 1) {
		if (m==11)
		{
			if (d>30)
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 					 
				return false;
			}
		}
	} else {
		if (f!=0) {
			if (m==11)
			{
				if (d>30)
				{
					window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 						 
					return false;
				}
			}
		}
	}
	if(obl == 1) {
		if (m==2)
		{
			if (d>29)
			{
				window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 				
				return false;
			}
			if (d==29)
			{
				if ((y%4)!=0)
				{
					window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 	
					return false;
				}
				else
				{
					if ( ((y%100)==0) && ((y%400)!=0) )
					{
						window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
						window.event.returnValue = false; 	
						return false;
					}
				}
			}
		}
	} else {
		if (f!=0) {
			if (m==2)
			{
				if (d>29)
				{
					window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 									 
					return false;
				}
				if (d==29)
				{
					if ((y%4)!=0)
					{
						window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
						window.event.returnValue = false; 							 
						return false;
					}
					else
					{
						if ( ((y%100)==0) && ((y%400)!=0) )
						{
							window.open(me,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
							window.event.returnValue = false; 								 
							return false;
						}
					}
				}
			}
		}
	}
} 



// Validar valores numerico
function val_num(campo, ent, dec, nom, obl, errpage)
{
	var aux;
	var tot = 0;
	var tot2 = 0;
	var auxStrNum = "";
	var re = /%1/;

	campo.value = formatearNum(campo.value, errpage);
	tot = campo.value;	
	tot2 = tot;
	auxStrNum = campo.value;
		
	if (obl==1 && (isNaN(tot2) || (auxStrNum == "")))
	{
		aux = errpage + "?number=" + IDS_ERR_NO_ES_NUMERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_ES_NUMERO);
		aux = aux.replace(re, nom);
		window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
		window.event.returnValue = false; 	
		return false;
	}
	else
	{
		if (tot2 == 0)
		{
			if (obl==1) {
				aux = errpage + "?number=" + IDS_ERR_NO_PUEDE_SER_CERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_PUEDE_SER_CERO);
				aux = aux.replace(re, nom);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
		else
		{
			if (isNaN(tot2)){
				aux = errpage + "?number=-" + IDS_ERR_NO_ES_NUMERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_ES_NUMERO);
				aux = aux.replace(re, nom);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;			
			}
		}
	}

	var arr;
	var num="";
	var l_dec=0;
	var l_ent=0;
	var aux;
	num= "" + tot2 ;
	arr= num.split('.');

	l_ent= arr[0].length;
	if (l_ent>ent)
	{
		aux = errpage + "?number=" + IDS_ERR_CANT_ENTEROS + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_CANT_ENTEROS);
		re = /%1/;
		aux = aux.replace(re, ent);
		re = /%2/;
		aux = aux.replace(re, nom);
		window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
		window.event.returnValue = false; 	
		return false;
	}

	if (arr[1])
	{
		l_dec= arr[1].length;
		if (l_dec>dec)
		{
			aux = errpage + "?number=" + IDS_ERR_CANT_DECIMALES + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_CANT_DECIMALES);
			re = /%1/;
			aux = aux.replace(re, dec);
			re = /%2/;
			aux = aux.replace(re, nom);
			window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	}
}


// Validar valores numerico
function val_numero(campo, nEnt, nDec, szObligatorio, szCondicionValidacion, szName, Bloque, errpage, FormateNum)
{

	try {	
		if (campo.disabled)
		{
			return true;
		}		

		var aux;
		var valor;
		var re = /%1/;
		var valor = "";
		if (FormateNum != "1")	{
			valor = formatearNum(campo.value, errpage);				
		} else {	
			valor = (campo.value);
		}				
		var re1 = /,/;
		valor = valor.replace(re1, ".");
		
		if (szObligatorio == "1") {
			if (szCondicionValidacion == "OB") {
				if ((isNaN(valor)) || (valor == 0) || (valor == "")) {

					aux = errpage + "?number=(1)" + IDS_ERR_NO_ES_NUMERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_ES_NUMERO) + ". Bloque: " + Bloque;
					aux = aux.replace(re, szName);
					window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 	
					return false;
				}
			}
			else {
				if (szCondicionValidacion != "") {
					if (eval((szCondicionValidacion)) && ((isNaN(valor)) || (valor == 0) || (valor == ""))) {
						aux = errpage + "?number=(2)" + IDS_ERR_NO_PUEDE_SER_CERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_PUEDE_SER_CERO) + ". Bloque: " + Bloque;
						aux = aux.replace(re, szName);
						window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
						window.event.returnValue = false; 	
						return false;
					}
				}
			}
		}

		if (szCondicionValidacion != "" && szCondicionValidacion != "OB") {
			if (eval((szCondicionValidacion)) && ((isNaN(valor)) || (valor == 0) || (valor == ""))) {
				aux = errpage + "?number=(3)" + IDS_ERR_NO_ES_NUMERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_ES_NUMERO) + ". Bloque: " + Bloque;
				aux = aux.replace(re, szName);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}

		if (isNaN(valor) && valor != "") {
			aux = errpage + "?number=" + IDS_ERR_NO_ES_NUMERO + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_ES_NUMERO) + ". Bloque: " + Bloque;
			aux = aux.replace(re, szName);
			window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}	

		var l_dec=0;
		var l_ent=0;
	
		var num = "" + valor;
		var arr = num.split('.');

		l_ent= arr[0].length;
		if (l_ent>nEnt)
		{
			aux = errpage + "?number=" + IDS_ERR_CANT_ENTEROS + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_CANT_ENTEROS) + ". Bloque: " + Bloque;
			re = /%1/;
			aux = aux.replace(re, nEnt);
			re = /%2/;
			aux = aux.replace(re, szName);
			window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}

		if (arr[1])
		{
			l_dec= arr[1].length;
			if (l_dec>nDec)
			{
				aux = errpage + "?number=" + IDS_ERR_CANT_DECIMALES + "&source=javascript:val_num&description=" + obtenerEtiqueta(szuil, IDS_ERR_CANT_DECIMALES) + ". Bloque: " + Bloque;
				re = /%1/;
				aux = aux.replace(re, nDec);
				re = /%2/;
				aux = aux.replace(re, szName);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
	}
	catch (E) {
	}
	return true;
}


// Validar opciones
function val_opt (campo, nom, errpage)
{

	var i=0;
	var b=0;
	var aux;
	var re = /%1/;
	try {
	var len= campo.length;

		if ((len>0)&&(len<99999))
		{


			for(i=0; i<len;i++)
			{
	
				if (campo[i].checked==true)
				{
					b=1;
				}	
			}
			if (b==0)
			{
				aux = errpage + "?number=" + IDS_ERR_NO_SELECCIONO_UN_ITEM + "&source=javascript:val_opt&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_SELECCIONO_UN_ITEM);
				aux = aux.replace(re, nom);				
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}

		} else {

			if (campo.checked==true) {
				b=1;	
			}
		
			if (b==0) {
				aux = errpage + "?number=" + IDS_ERR_NO_SELECCIONO_UN_ITEM + "&source=javascript:val_opt&description=" + obtenerEtiqueta(szuil, IDS_ERR_NO_SELECCIONO_UN_ITEM);
				aux = aux.replace(re, nom);				
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
	} catch(E) {
		aux = errpage + "?number=" + IDS_ERR_NO_HAY_ITEMS + "&source=javascript:val_opt&description=" + obtenerEtiquetaEx(szuil, IDS_ERR_NO_HAY_ITEMS);
		aux = aux.replace(re, nom);				
		window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
		window.event.returnValue = false; 	
		return false;
	}
}


// Validar valores de texto
function val_text2(campo, len, len2, nom, obl, errpage)
{
	try {
		var re;
		var aux;
		var tex = campo.value;
		var l = tex.length;
		if (l==0)
		{
			if(obl==1) {
				aux = errpage + "?number=" + IDS_ERR_DEBE_COMPLETAR_EL_CAMPO + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_DEBE_COMPLETAR_EL_CAMPO);
				re = /%1/;
				aux = aux.replace(re, nom);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}
		if (l>len)
		{
			aux = errpage + "?number=" + IDS_ERR_LONGITUD_MAXIMA + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_LONGITUD_MAXIMA);
			re = /%1/;
			aux = aux.replace(re, nom);
			re = /%2/;
			aux = aux.replace(re, len);

			window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
		if (l<len2)
		{
			aux = errpage + "?number=" + IDS_ERR_LONGITUD_MINIMA + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_LONGITUD_MINIMA);
			re = /%1/;
			aux = aux.replace(re, nom);
			re = /%2/;
			aux = aux.replace(re, len2);

			window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
			window.event.returnValue = false; 	
			return false;
		}
	} catch(E) { }
}

// Validar valores de texto
function val_texto(campo, nMaxLen, nMinLen, szObligatorio, szCondicionValidacion, szName, Bloque, errpage) {

	try {
		var re;

		if (campo.disabled) 
		{
			return true;
		}
		
		var valor = campo.value;
		var len = valor.length;
		var aux;

		if (szObligatorio == "1") {
			if (szCondicionValidacion == "OB") {
				if (len == 0) {
					aux = errpage + "?number=" + IDS_ERR_DEBE_COMPLETAR_EL_CAMPO + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_DEBE_COMPLETAR_EL_CAMPO) + ". Bloque: " + Bloque;
					re = /%1/;
					aux = aux.replace(re, szName);
					window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
					window.event.returnValue = false; 	
					return false;
				}
			}
			else {
				if (szCondicionValidacion != "") {
					if (eval((szCondicionValidacion)) && len == 0) {
						aux = errpage + "?number=" + IDS_ERR_DEBE_COMPLETAR_EL_CAMPO + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_DEBE_COMPLETAR_EL_CAMPO) + ". Bloque: " + Bloque;
						re = /%1/;
						aux = aux.replace(re, szName);
						window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
						window.event.returnValue = false; 	
						return false;
					}
				}
			}
		}
	

		if (szCondicionValidacion != "" && szCondicionValidacion != "OB") {
			if (eval((szCondicionValidacion)) && len == 0) {
				aux = errpage + "?number=" + IDS_ERR_DEBE_COMPLETAR_EL_CAMPO + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_DEBE_COMPLETAR_EL_CAMPO) + ". Bloque: " + Bloque;
				re = /%1/;
				aux = aux.replace(re, szName);

				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}

		if (nMaxLen > 0) {
			if (len > nMaxLen) {
				aux = errpage + "?number=" + IDS_ERR_LONGITUD_MAXIMA + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_LONGITUD_MAXIMA) + ". Bloque: " + Bloque;
				re = /%1/;
				aux = aux.replace(re, szName);
				re = /%2/;
				aux = aux.replace(re, nMaxLen);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
			if (len < nMinLen) {
				aux = errpage + "?number=" + IDS_ERR_LONGITUD_MINIMA + "&source=javascript:val_text2&description=" + obtenerEtiqueta(szuil, IDS_ERR_LONGITUD_MINIMA) + ". Bloque: " + Bloque;
				re = /%1/;
				aux = aux.replace(re, szName);
				re = /%2/;
				aux = aux.replace(re, nMinLen);
				window.open(aux,'_blank','toolbar=no, location=no, status=no, scrollbars=yes, width=400, height=300');
				window.event.returnValue = false; 	
				return false;
			}
		}

		}
	catch (E) {
	}

	return true;
}
