var espacio = " ";
var defaultvacioOK = false;
var espacioblanco = " \t\n\r";
var cadnumeroneg ="0123456789-";
var cadespacio = " ";	
var cadnumero = "0123456789";
var cadnumeroespacio = "1234567890 ";
var cadnumeroespacioguion = "1234567890 -";
var cadcorreo = "1234567890abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ_-.@";
var cadtelefono = "1234567890 -";
var cadnombre = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ñÑáéíóúÁÉÍÓÚ'";
var cadusuariopassword = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&";
var cadnumeronombre = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ñÑáéíóúÁÉÍÓÚ'";
var cadnumeronombrebas = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
var cadnumeroletrasimbolos = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.- ñÑáéíóúÁÉÍÓÚ()':/#%$&@!¡?¿+-*,;üÜ";
//variable utilizada para la función validaDecimalBD:
//Esta permite verificar si la validación ha sido exitosa o no
var validacionDecimalExitosa = false;

//	<!--
	/**
	 * Permite deshabilitar el click derecho de las paginas
	 * @author jespejo - Juan Carlos Espejo Gavilano
	 * @version v1.0, Apr 13, 2005
	 */
//	document.oncontextmenu = function()
//	{
//		return false
//	}
//	if(document.layers)
//	{
//		//window.captureEvents(Event.MOUSEDOWN);
//		window.onmousedown = function(e)
//		{
//			if(e.target==document)
//				return false;
//		}
//	}
//	else
//	{
//		//document.onmousedown = function(){return false}
//	}
	// -->

esNS4 = "";
esIE4 = "";
esIE5 = "";
esNS6 = "";			
var navegador="";

function valida_caracter(e,Lista){
	// e: event
	var tecla, buscar = Lista;		
  	if (navigator.appName == "Netscape")tecla = e.which; else tecla = e.keyCode;

	if( tecla == 13) return(true);		

   	c = String.fromCharCode(tecla);	
	if( buscar.indexOf(c) == -1 )return(false);else return(true);	
}

function solonumlet(objeto){
//  objeto.value=objeto.value.toUpperCase().replace(/([^0-9A-Z ])/g,"");
  objeto.value=objeto.value.toUpperCase();
}

function solonum(objeto){
  objeto.value=objeto.value.toUpperCase().replace(/([^0-9])/g,"");
  objeto.value=objeto.value.toUpperCase();  
}

function sololet(objeto){
//  objeto.value=objeto.value.toUpperCase().replace(/([^A-Z])/g,"");
  objeto.value=objeto.value.toUpperCase();
}


	function rellenaIzq(texto, relleno, total)
	{
	if (texto.length >= total)
		return texto;
	
	var resultado = texto;
	
	total = total - texto.length
	
	for (i = 0; i < total; i++)
	  {
	    resultado = relleno + resultado
	  }
	  
	  
	return resultado;
	}

	function extraeDer(texto, cantidad)
	{
	if (texto.length <= cantidad)
		return texto;
		
	var resultado ="";
	
	for (i = (texto.length - cantidad); i < texto.length; i++)
	  {
	  	var xchar = texto.substr(i,1);
	   resultado = resultado + xchar
	  }
	  
	return resultado;
	}

	function extraeIzq(texto, cantidad)
	{
	if (texto.length <= cantidad)
		return texto;
		
	var resultado ="";
	
	for (i = 0; i < texto.length-cantidad; i++)
	  {
	  	var xchar = texto.substr(i,1);
	   resultado = resultado + xchar
	  }
	  
	return resultado;
	}


	function Abrir_Ventana(dirURL,titulo,propiedad,ancho,alto)
	{
		if(screen.width){
			var venleft = (screen.availWidth-ancho)/2;
			var ventop = (screen.availHeight-alto)/2;
		}else{
			venleft = 0;
			ventop =0;
		}
		if (venleft < 0) venleft = 0;
		if (ventop < 0) ventop = 0;
		var titulo=titulo;
		var propiedad=propiedad;
		var propiedades="toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,";
		if(propiedad==""){
			propiedades= propiedades + "top=" + ventop + ",left=" + venleft + ",width=" + ancho + ",height=" +alto;
		}else{
			propiedades= propiedad + ",top=" + ventop + ",left=" + venleft + ",width=" + ancho + ",height=" +alto;
		}
		window.open(dirURL,titulo,propiedades);
	}

	function esVacio(cadena)
	{
		return ((cadena == null) || (cadena.length == 0) || trim(cadena)== "")
	}
	
	function esDigito(cadena)
	{   return ((cadena >= "0") && (cadena <= "9"))
	}			
	
	function esNumero(cadena){
	  if ( isNaN( cadena ) )
	  {
	    return false
	  } else {
	    return true
	  }
	}

	function esEntero(cadena) {
	for (var i = 0; i < cadena.length; i++) {
		var c = cadena.charAt(i);
		if (!((c >= "0") && (c <= "9"))) {
			return false;
		}
	}
	
	return true;
	}

	function esEspacioBlanco(cadena)
	{   var i;
	    if (esVacio(cadena)) return true;    
		for (i = 0; i < cadena.length; i++)
		{   
			var c = cadena.charAt(i);
			if (espacioblanco.indexOf(c) == -1) 
			{			
			return false;
			}
		}
	    return true;
	}		
	function esEspacio(cadena)
	{   var i;
	    // Es vacio?
	    if (esVacio(cadena)) return true;
	    // Buscar un caracter no blanco en la cadena
	    for (i = 0; i < cadena.length; i++)
	    {   
	        // Verificar caracter no blanco
	        var c = cadena.charAt(i);
	        if (espacio.indexOf(c) == -1) return false;
	    }
	    return true;
	}

	function esEmail (cadena)
	{
		if (esVacio(cadena))  
   		if (esEmail.arguments.length == 1) return defaultvacioOK;
    		else return (esEmail.arguments[1] == true);
    //  es un espacioblanco?
    	if (esEspacioBlanco(cadena)) return false;
	// debe existir al menos un caracter antes del arroba 
		var i = 1;
		var k=0;
 		var sLength = cadena.length;
	// Busca @
		//while 
		//((i < sLength) && (cadena.charAt(i) != "@"))
	    //if ((i >= sLength) || (cadena.charAt(i) != "@")) return false;
   	    //else i += 2;
		for (j=1;j<sLength;j++){
			if(cadena.charAt(j) == "@")
		    { 
		    	i=j;
		    	k=k+1;
		    }
	    }
	    if(k==1)
	    {
	    	i=i+2;
	    }else{
	    	return false;
	    }

	// Busca .
	    while ((i < sLength) && (cadena.charAt(i) != "."))
	    { i++
	    }
	// Debe existir al menos un caracter antes del .
	    if ((i >= sLength - 1) || (cadena.charAt(i) != ".")) return false;
	    else return true;    
	}		

function Navegador()
{
esNS4 = (document.layers) ? true : false;
esIE4 = (document.all && !document.getElementById) ? true : false;
esIE5 = (document.all && document.getElementById) ? true : false;
esNS6 = (!document.all && document.getElementById) ? true : false;
if (esNS4) { navegador='NS4';}
if (esIE4) { navegador='IE4';}
if (esIE5) { navegador='IE5';}
if (esNS6) { navegador='NS6';}
}

function invisible_navegador(navegador,lbl_IE,lbl_NS,estado)
{
	switch (navegador)
	{
		case 'NS4': 
		if(estado=='i'){lbl_NS.visibility="hide"}else{lbl_NS.visibility="show"};	
		break;	
		case 'IE4':
		if(estado=='i'){lbl_IE.style.visibility="hidden"}else{lbl_IE.style.visibility="visible"};		
		break;		
		case 'IE5':
	    lbl_IE = document.getElementById(lbl_IE);
		if(estado=='i'){lbl_IE.style.visibility="hidden"}else{lbl_IE.style.visibility="visible"};
		break;		
		case 'NS6':
	    lbl_IE = document.getElementById(lbl_IE);
		if(estado=='i'){lbl_IE.style.visibility="hidden"}else{lbl_IE.style.visibility="visible"};
		break;		
	}
}

function obj_mayuscula(objeto){
  objeto.value= trim(objeto.value.toUpperCase());
}

function mayuscula(campo){
  return campo.value.toUpperCase()
}
function minuscula(campo){
  return campo.value.toLowerCase()
}

	function esLongitudEntre(cadena,minimo,maximo) 
	{				
		if (cadena.length<minimo || cadena.length>maximo){
			return false;				
		}else{
			return true;
		}
	}	
	function esLongitudMenor(cadena,maximo) 					
	{
		if (cadena.length>maximo){
			return false;				
		}else{
			return true;
		}
	}	
	function esLongitudMayor(cadena,minimo) 						
	{
		if (cadena.length<minimo){
			return false;				
		}else{
			return true;
		}
	}	

	function esEnteroMayor(cadena,minimo) 						
	{
		if (eval(cadena)<minimo){
			return false;				
		}else{
			return true;
		}
	}	


	function esMenor(cadena,maximo) 					
	{
		if (cadena.length>maximo){
			return false;				
		}else{
			return true;
		}
	}	
	function esMayor(cadena,minimo) 						
	{
		if (cadena.length<minimo){
			return false;				
		}else{
			return true;
		}
	}	
	function contieneNumero(obj)
	{
	  for (var i=0;i<obj.value.length;i++)
	  {
	    chr=obj.value.substring(i,i+1);
	    if(esEntero(chr))
	    {
		return true;
	    }
	  }
	  return false;
	}
	function contieneNoNumero(obj)
	{
	  for (var i=0;i<obj.value.length;i++)
	  {
	    chr=obj.value.substring(i,i+1);
	    if(!esEntero(chr))
	    {
		return true;
	    }
	  }
	  return false;
	}
		
	function lTrim(lstr)
	{
		lstr = String(lstr);
		if (lstr!="") 
		{
			var strlen, cptr, lpflag, chk;
			strlen=lstr.length;	
			cptr=0;
			lpflag=true;	
			do
			{
				chk=lstr.charAt(cptr);
				if (chk !=" ") 
				{
					lpflag=false;
				}else {
					if (cptr == strlen) 
					{
						lpflag=false;
					}else {
						cptr++;
					} 		
				}
			}
			while (lpflag == true)
			if (cptr > 0) 
			{
				lstr = lstr.substring(cptr,strlen);
			}
		}
		return lstr;
	}
	
	function rTrim(lstr)
	{
		lstr = String(lstr);
		if (lstr != "") 
		{
			var strlen, cptr, lpflag, chk;
			strlen=lstr.length;
			cptr=strlen;
			lpflag=true;
			do
			{
				chk=lstr.charAt(cptr-1);
				if (chk !=" ") 
				{
					lpflag=false;
				}else{
					if (cptr == 0) 
					{
						lpflag=false
					}else {
						cptr--;
					} 		
				}
			}
			while (lpflag == true)
			if (cptr < strlen) {
				lstr=lstr.substring(0,cptr);
			}
		}
		return lstr;
	}
				
	function trim(lstr) 
	{
		return lTrim(rTrim(lstr))
	}
	

function mensaje_status(men)
{
    status=men;
    return true;
}
function VentanaFlotante(pag,px,py,x,y)
{
	var ancho= x;
	var alto= y;
	NombreVentana=window.open(pag,"NombreVentana","bar=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=1,width=" + ancho + ",height=" + alto + ",top=" + px + ",left=" + py+"");
}
function esFecha(dia,mes,ano) {

	if (!esNumero(dia) || !esNumero(mes)
		||!esNumero(ano)){
		alert("Caracteres no validos");
		return false;
	}
	if (ano <1850 || ano.length > 4){
		alert("Año no valido");
		return false;
	}
	if ((mes<1)||(mes>12 )){
		alert("Mes no valido");
		return false;
	}
	if ((dia<1)||(dia>31)){
		alert("Dia no valido");
		return false;
	}
	if((mes==1)||(mes==3)||(mes==5)||
		(mes==7)||(mes==8)||(mes==10)||
		(mes==12)){
		if(dia > 31){
			alert('Dia no valido')
			return false;
		}
	}
	if((mes==4)||(mes==6)||(mes==9)||(mes==11)){
		if(dia > 30){
			alert('Dia no valido')
			return false;
		}
	}
	if(mes==2){
		if((ano  % 4 == 0)&&((!(ano  % 100 == 0))||(ano  % 400 == 0))){
			if(dia > 29){
				alert('Dia no valido')
				return false;
			}
		}
		else{
			if(dia > 28){ 
				alert('Dia no valido')
				return false;
			}
		}
	}
	return true;
}
function esRangoFecha(diainicio,mesinicio,anoinicio,diafin,mesfin,anofin) {

    if(!esFecha(sel_Obtener_Texto(document.form1.diainicio),sel_Obtener_Texto(document.form1.mesinicio),sel_Obtener_Texto(document.form1.anoinicio)))
    {
    	return false;
    }
    if(!esFecha(sel_Obtener_Texto(document.form1.diafin),sel_Obtener_Texto(document.form1.mesfin),sel_Obtener_Texto(document.form1.anofin)))
    {

    	return false;
    }   
	if(eval(anoinicio+mesinicio+diainicio)>eval(anofin+mesfin+diafin))
	{
   			alert('Rango de Fechas no valido')
	    	return false;
	}
	return true;
}
			function cadenadeobjeto(objeto){
				if( objeto.value==undefined){
					cadena=objeto;				
				}else{
					switch(objeto){
					case 'text':
						cadena=objeto.value;
					case 'checkbox':
						cadena=objeto.value;					
					case 'radio':
						cadena=objeto.value;										
					case 'select-one':
						cadena=objeto.value;																
					}
				}
				if( tipo=="[object]" || tipo=="object HTMLInputElement"){				
				alert("a");
				return cadena;
				}
			}
			
			function contieneCarateresValidos(cadena, cadenavalida)
			{
				if(!esEspacio(cadena))
				{
					cad= eval('cad'+ cadenavalida);					   
					for(var i=0; i<cadena.length; i++)
					{
						var caracter = cadena.substring(i,i+1);
						if (cad.indexOf(caracter) == -1)
							{
							return false;
							}
					}
					return true;	
				}
				else
				{
					return false;
				}
			}	
			function contieneCarateresInvalidos(cadena, cadenainvalida){
				if(!esEspacio(cadena)){
					cad= eval('cad'+ cadenainvalida);					   
					for(var i=0; i<cadena.length; i++){
						var caracter = cadena.substring(i,i+1);
						if (cad.indexOf(caracter) >0){
							return true;}
						}
					return false;	
				}else{
					return true;
				}
			}	
			function contieneCaracterInvalido(cadena, cadenainvalida)
			{
				alert("a");
			  
			}
			
			


function sel_Eliminar_Opciones(objeto_sel)
{
//Elimina todas las opciones de un select
	if (objeto_sel.length != 0)
	{ 
		for(var i=0; i<objeto_sel.options.length; ++i)
			{
				objeto_sel.options[i]=null;
				--i;
			}
    	}
}

function sel_Obtener_Valor(objeto_sel)
{
//Obtener codigo de papa
	var valor ="";
	for(var i=0; i< objeto_sel.options.length; i++)
		{
			if (objeto_sel.options[i].selected)
				{
					valor=objeto_sel.options[i].value;
					return valor;
					break;
				}
		}
}

function sel_Obtener_Texto(objeto_sel)
{
//Obtener codigo de papa
	var valor ="";
	for(var i=0; i< objeto_sel.options.length; i++)
		{
			if (objeto_sel.options[i].selected)
				{
					valor=objeto_sel.options[i].text;
					return valor;
					break;
				}
		}
}


function sel_Generar_Opciones(objeto_sel_destino,vector,clave)
{
	//llenar combo hijo con informaci&oacute;n de acuerdo al Id de combo padre
	var campo_valor;
	var campo_descripcion;
	var campo_clave;			
	//var clave = sel_Obtener_Valor(objeto_sel_origen);
	for (var i=0; i<vector.length; i++)
			{
				campo_clave = vector[i][0];
				campo_valor = vector[i][1];
				campo_descripcion = vector[i][2];
				if (campo_clave  == clave)
					objeto_sel_destino.options[objeto_sel_destino.length] = new Option(campo_descripcion,campo_valor);
			}
}

function sel_Reiniciar_Opciones(objeto_sel_destino,vector,objeto_sel_origen,defecto)
{
	sel_Eliminar_Opciones(objeto_sel_destino);
	var clave= sel_Obtener_Valor(objeto_sel_origen);
	if (defecto!="default")
	{
		sel_Generar_Opciones(objeto_sel_destino,vector,defecto);
	}
	if(defecto!=clave){	
		sel_Generar_Opciones(objeto_sel_destino,vector,clave);
	}
}

function sel_ActivarOpcion(objeto_sel, opcion)
{ 
for(var i=0; i< objeto_sel.options.length; i++)
	{
		if (objeto_sel.options[i].value == opcion)
				objeto_sel.options[i].selected=true;
	}
}

function sel_DesactivarOpcion(objeto_sel)
{ 
for(var i=0; i< objeto_sel.options.length; i++)
	{
			objeto_sel.options[i].selected=false;
	}
}

function tieneCaracterNoValido(cadena)
{
	for (i = 0; i < cadena.length; i++)
		{   
			var c = cadena.charAt(i);
			if (c=='%')
				return true;
		}
	return false;
}







/**
 * FUNCTION    : tempo_compare
 * author      : Henry Tong
 * date        : 21 feb 2002
 * description : receives two strings (example: "09/09/1999","02/03/1975")
				 validate if a date is lower, greater of equal to another
				 returns :
					- 1  :  date1 is lower   than date2
					  0  :  date1 is equal   to   date2
					+ 1  :  date1 is greater than date2
					
				 WARNING! ALL PARAMETERS MUST BE VALIDATED AS DATES FIRST!!!!
				 USE FUNCTION "verify_date" for that	
 */
function tempo_compare(ptext1,ptext2)
{	 
var xdd;
var xmm;
var xyy;

var dd1 = 0;
var mm1 = 0;
var yy1 = 0;

var dd2 = 0;
var mm2 = 0;
var yy2 = 0;


// first date
	xdd = ptext1.substr(0,2);
	xmm = ptext1.substr(3,2);
	xyy = ptext1.substr(6,4);

	dd1 = parseInt(xdd, 10);
	mm1 = parseInt(xmm, 10);
	yy1 = parseInt(xyy, 10);            
	
// second date	
	xdd = ptext2.substr(0,2);
	xmm = ptext2.substr(3,2);
	xyy = ptext2.substr(6,4);

	dd2 = parseInt(xdd, 10);
	mm2 = parseInt(xmm, 10);
	yy2 = parseInt(xyy, 10);            

// are they equal?????
	if (   (yy1 == yy2)  && (mm1 == mm2)  && (dd1==dd2)  )
		return 0;

	if (yy1 > yy2)
		return 1;

	if (yy2 > yy1)
		return -1;		

// years are the same
	if (mm1 > mm2)		
		return 1;
	if (mm1 < mm2)
		return -1;
		
// the months are equal)
	if (dd1 > dd2)
		return 1;
	if (dd1 < dd2)
		return -1;

}  // end of function tempo_compare

/* --------------------------------------------------------
	28 feb : DATE FUNCTIONS
*/

// tempo_add : adds a given number of days to a date
// author    : Henry Tong - 28 feb 2002
// parameters:  p1   = date in the format "dd/mm/yyyy"
//              days = number of days to add (it can be a negative number
//                     if you want to substract days)
function tempo_add(p1, days)
{
	//convert text date to real DATE
	//var rdate = new Date(p1.substring(6,9)+"-"+p1.substring(3,4)+"-"+p1.substring(0,1));
	//var rdate = new Date(p1);
	
	// date constructor requires the format "mm/dd/yyyy"
	var rdate = new Date(p1.substring(3,5)+"/"+p1.substring(0,2)+"/"+p1.substring(6,10));
	
	// add number of days
	var new_date = new Date();
	new_date.setTime(rdate.getTime() + 1000 * 60 * 60 * 24 * days);
	
	// convert the date to the TEXT FORMAT "dd/mm/yyyy"
	var dd = "";
	var mm = "";
	var yy = "";

	var i = new_date.getDate();
	if (i<=9)	
		dd= "0" + i;
	else
		dd = i;

	var m = new_date.getMonth();
	m++;
	if (m<=9)	
		mm = "0" + m;
	else
		mm = m;
	
	var y = new_date.getYear();

	var todo;

	todo = dd + "/" + mm + "/" + y;

	return todo;	
} // end of function tempo_add


/**************************************************/
/**
 * @autor Edgard Espinoza Rivas
 * @date 17/08/2004
 *  validaciones de numeros
 **/
 
 //verifica si la tecla presionada es un numero
 function fncEsTeclaNumero( ) {
  
 var valid = "0123456789.";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}

	 function fncEsTeclaFecha( ) {

	 var valid = "0123456789/";
	 var key = String.fromCharCode(event.keyCode);
		if (valid.indexOf(key) == "-1"){ return false;}
	}

 function fncEsTeclaTelefono( ) {
  
 var valid = "0123456789";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}
 function fncEsTeclaNombreNumero( ) {
  
 var valid = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.- ñÑáéíóúÁÉÍÓÚ()':/#%$&@!¡?¿+-*,;üÜ";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}
 function fncEsTeclaPagina( ) {
  
 var valid = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.-:/#&?=";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}
 //verifica si la tecla presionada es un numero
 function fncEsTeclaNombre( ) {
 var valid = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ñÑáéíóúÁÉÍÓÚ'";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}
 function fncEsTeclaNumeroDocumento( ) {
 var valid = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}
 //verifica si la tecla presionada es un numero
 function fncEsTeclaMail( ) {
 var valid = "1234567890abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ_-.@";
 var key = String.fromCharCode(event.keyCode);
	if (valid.indexOf(key) == "-1") return false;
}
//devuelve false si no es numero 
function isNumber(valor){
 if(valor != '' ){
var flag = false;
var cad = /^[1-9]{1}[0-9]*(([.]?[0-9]+)|([0-9]*))$/
 if(cad.test(valor)){
	flag = true;
 }
 }else{ // si no es vacio
	 	flag = true;
 }
 return flag;
}
 
// formatea fecha 
function  formateaFecha(objeto){

   var  keyAscii = event.keyCode;
    event.keyCode = 0;
   if((objeto.value.length == 1) || (objeto.value.length) == 4 ){
   	  if(keyAscii<48 || keyAscii>57 ){
			 event.keyCode = 0;
	  }else{
			event.keyCode = 47;
			objeto.value = objeto.value+String.fromCharCode(keyAscii);
	}

   }else{
  	  if(keyAscii<48 || keyAscii>57 ){
			 event.keyCode = 0;
	  }else{
			event.keyCode =   keyAscii;	 
	}
  }
}
// multiplica dos numeros que son tipo var 
// y lo retorna en tipo number
function multiplicaDosNumeros(num1, num2){
 var producto = parseFloat(num1)*parseFloat(num2);
 return producto.toFixed(4);
}
//multiplica tres numero del tipo var
function multiplicaTresNumeros(num1, num2, num3){
 var producto = parseFloat(num1)*parseFloat(num2)*parseFloat(num3);
 return producto.toFixed(4);
}

// suma dos numeros 
function sumaDosNumeros(num1, num2){
 var resultado = parseFloat(num1) + parseFloat(num2);
 return resultado.toFixed(4);
}

// diferencia de dos numeros 
function restarDosNumeros(num1, num2){
 var resultado = parseFloat(num2) - parseFloat(num1);
 return resultado.toFixed(4);
}


function cambiacolor(nombre,color)
{
	var colorTRover='#b0c4de';
	var colorTRout='white';
	eval("var nuevocolor=color" + color);
	eval(eval('nombre') + ".style.background='" + nuevocolor + "'");
}
	
	
  function selectCell(c)
  {
	c.parentElement.runtimeStyle.backgroundColor = "#6666CC";
    c.parentElement.runtimeStyle.color = "white";	
  }
  
  function deselectCell(c)
  {
    c.parentElement.runtimeStyle.backgroundColor = "white";
    c.parentElement.runtimeStyle.color = "black";
  }
  
 function findCell(e)
  {
    if (e.tagName == "TD")
	{
      return e;
    }
    else if (e.tagName == "BODY")
	{
      return null;
    }
    else
	{
      return findCell(e.parentElement);
    }
  }
  
function Empty(value1)
  { var value2 = eval(value1 + ".value");
    if (trim(value2).length==0)
    {
    alert("El campo no puede estar vacío...");
    eval(value1 + ".select()");
    return false;
    }
    else
    { return true;  }
  }

function Mail(value1)
  {
  if (!Space(value1))
    {
    alert("El Email contiene en su interior espacios en blanco...");
    return false;
    }
  var value1 = eval(value1 + ".value");
  if (value1.indexOf('@', 0) == -1)
    {
        alert("Escribir correctamente el EMail...");
	return false;
    }
  else
    {
    if (value1.indexOf('.', 0) == -1)
      {
        alert("Escribir correctamente el EMail...");
      return false;
      }
    else
      {
      if ((value1.indexOf('@', 0) + 1) == value1.indexOf('.', 0) )
        {
        alert("Escribir correctamente el EMail...");
        return false;
        }
      else
        {
        return true;
        }
      }
    }
  }
function Space(value1){
  var Campo = eval(value1+".value");
  for(var i=0; i<Campo.length; i++){
    var varia = Campo.substring(i,i+1);
    if (varia == " "){
      return false;
    }
  }
  return true;
}
function esFechaValida( fecha ){
	
	var parteFecha = fecha.split('/');
	if( parteFecha.length != 3){
		alert('El formato de fecha debe ser dd/mm/aaaa');
		return false;
	}
	dd = parteFecha[0];
	mm = parteFecha[1];
	yy = parteFecha[2];
	return (esFecha(dd,mm,yy) );
}
//**********************FUNCION DE VERIFICACION DE RUT *****************************

function CheckDigitsKOnly(texto)
	
{
	
	largo = texto.length;
	
	for (i=0; i < largo ; i++ )
	
	{
	
		if (texto.charAt(i) != "0" && texto.charAt(i) != "1" && texto.charAt(i) != "2"
	
			&& texto.charAt(i) != "3" && texto.charAt(i) != "4" && texto.charAt(i) != "5"
	
			&& texto.charAt(i) != "6" && texto.charAt(i) != "7" && texto.charAt(i) != "8"
	
			&& texto.charAt(i) != "9" && texto.charAt(i) !="k" && texto.charAt(i) != "K" )
	
			return false;
	
	}
	
	return true;
	
}
	
function TestLargo(texto,largomin,largomax)
	
{
	
	if ((texto.length < largomin) || (texto.length > largomax))
	
		return false;
	
	else
	
		return true;
	
}
	
function CheckDataFields(fieldRut,dv)
	
{
	rut = fieldRut.value;
	
	if ((CheckDigitsOnly(rut))
	
		&& (CheckDigitsKOnly(dv))

		&& (TestLargo(rut,1,11)) )
	
		return true
	
	else
	
		return false
	
	}
	
function CheckDvUsuario(fieldRut,dv)
	
{
	
	RutUsuario = fieldRut.value;
	
	DvUsuario = dv;
	
	var DvUsuarior = '0'
	
	suma = 0
	
	mul  = 2
	
	for (i= RutUsuario.length -1 ; i >= 0; i--)
	
	{
	
		suma = suma + RutUsuario.charAt(i) * mul

		if (mul == 7)
	
			mul = 2
	
		else
	
			mul++
	
		}
	
		res = suma % 11
	
		if (res==1)
	
			DvUsuarior = 'k'
	
		else if (res==0)
	
			DvUsuarior = '0'
	
		else
	
		{
	
			DvUsuarioi = 11-res
	
			DvUsuarior = DvUsuarioi + ""
	
		}
	
		if ( DvUsuarior != DvUsuario.toLowerCase() )
	
			return false;
	
		else
	
			return true;
	
}
	
	
	
function CheckAll(fieldRut , dv )
{
	
		
	if ( !CheckDataFields(fieldRut,dv) ) {
	
		alert("Lo sentimos,los datos ingresados no son correctos");
		fieldRut.focus();	
		return false;
	
	}
	
	if ( !CheckDvUsuario(fieldRut,dv) ) {
	
		alert("Lo sentimos, el RutUsuario es incorrecto")
		fieldRut.focus();
	
		return false;
	
	}
	return true;
	
}
	
function EliminaPuntos(Rut)

{
	
	var RutAux="";

	for(var i=0;i<Rut.length;i++){

		if(Rut.charAt(i)!="." && Rut.charAt(i)!="," && Rut.charAt(i)!="-")

			RutAux=RutAux+Rut.charAt(i);
	
		}
	
		return RutAux;
	
}
	
	
	
	

function ValidaDv(dv)
	
	{
	
		for(var i=0;i<dv.length;i++){
	
			if(dv.charAt(i)!=0 && dv.charAt(i)!=1 && dv.charAt(i)!=2 && dv.charAt(i)!=3 &&
	
			   dv.charAt(i)!=4 && dv.charAt(i)!=5 && dv.charAt(i)!=6 && dv.charAt(i)!=7 &&
	
			   dv.charAt(i)!=8 && dv.charAt(i)!=9 && dv.charAt(i)!="k" && dv.charAt(i)!="K")
	
					return false;
	
		}
	
		return true;
	
	}
	

function ValidaRut(fieldRut)

{

	Rut = fieldRut.value;	
		for(var i=0;i<Rut.length;i++){
	
			if(Rut.charAt(i)!=0 && Rut.charAt(i)!=1 && Rut.charAt(i)!=2 && Rut.charAt(i)!=3 &&
	
			   Rut.charAt(i)!=4 && Rut.charAt(i)!=5 && Rut.charAt(i)!=6 && Rut.charAt(i)!=7 &&
	
			   Rut.charAt(i)!=8 && Rut.charAt(i)!=9 && Rut.charAt(i)!="k" && Rut.charAt(i)!=0 && Rut.charAt(i)!="." && Rut.charAt(i)!="-" && Rut.charAt(i)!="K")
	
					return false;
	
		}
	
		return true;
	
}

function ValidaDatos( fieldRut )
	
	{
		
		if(ValidaRut(fieldRut.value)==false){
	
			alert("El Rut es incorrecto");
	
			fieldRut.focus();
			return false;
	
		}else if(ValidaDv(fieldRut.value.substring(field.Rut.value.length-1))==false){
	
			alert("El Rut es incorrecto");
	
			fieldRut.focus();
			return false;
	
		}else{
			
			
			login =EliminaPuntos(fieldRut.value).substring(0,EliminaPuntos(fieldRut.value).length-1);
	
			dv = fieldRut.value.substring(fieldRut.value.length-1);
	
			
	
			if(!CheckAll(fieldRut , dv )){
				return false;
	
			}else
	
				return true;
	
		}
	
	}


 
/****************** NUEVA FUNCION QUE VALIDA EL RUT - OSCAR GAMBINI CUEVA *******************/
function calcula_rut( rut ,  dv )  {
//Entrada válida: el rut sin puntos, 11813714
//Objetos:
//rut objeto text, name: Rut
//dv objeto text, name: dv
//Retorna true si el rut es correcto. En caso contrario, false.
		var Sum = 0;
		digito = 0;
		factor = 2;
    	largo = rut.value.length; 	   	
		if(largo < 7 ) {
			alert("¡ El RUT ingresado no es correcto ! ");			
			return false;
		}
		while (largo != 0) {
			
			
			Sum = Sum + (rut.value.substring(largo, largo - 1) * factor);			
			if (factor == 7) {
				factor = 2;
			} else {
				factor = factor + 1;
			}
			largo = largo - 1;
		}
		d = 11 - Sum % 11;
		if (d == "10") {
			digito = "K"; 
		} else {
			if (d == "11") {
				digito = 0;
			} else {
				digito = d;
			}
		}
		if (digito == dv.value.toUpperCase()) { 
			return true; 
		} else {
			alert("¡ El RUT ingresado no es correcto ! ");
			return false;
		}
}//End Function

/****************** NUEVA FUNCION QUE VALIDA EL RUT 1.1 - RICHARD SANCHEZ *******************/
function CalculaRut( rut ,  dv )  {
//Entrada válida: el rut sin puntos, 11813714
//Objetos:
//rut variable text, name: Rut
//dv variable text, name: dv
//Retorna true si el rut es correcto. En caso contrario, false.

		Sum = 0;
		digito = 0;
		factor = 2;
		largo = rut.length;
		if(largo < 8 ) {
			alert("¡ El RUT ingresado no es correcto ! ");			
			return false;
		}
		while (largo != 0) {
			Sum = Sum + (rut.substring(largo, largo - 1) * factor);
			if (factor == 7) {
				factor = 2;
			} else {
				factor = factor + 1;
			}
			largo = largo - 1;
		}
		d = 11 - Sum % 11;
		if (d == "10") {
			digito = "K"; 
		} else {
			if (d == "11") {
				digito = 0;
			} else {
				digito = d;
			}
		}
		if (digito == dv.toUpperCase()) { 
			return true; 
		} else {
			alert("¡ El RUT ingresado no es correcto ! ");
			return false;
		}
}//End Function

//esta funcion completa ceros a la izquierda hasta completar los 12 caracteres así como se almacena los
//docuemtnos en la base de datos
function llenaCerosRut( fieldRut ){

		//largo = fieldRut.value.length;
		rutCompleto = fieldRut.value;
		//while (largo < 12) {
		//	rutCompleto = "0" + rutCompleto;
		//	largo = rutCompleto.length;
		//}
		fieldRut.value = rutCompleto;
}

	/**
	 * Permite validar los caracteres validos a ingresar a un textArea, controla el maximo tamaño de caracteres que pueden ingresarse
	 * @author jespejo - Juan Carlos Espejo Gavilano
	 * @version v1.0, Apr 13, 2005
	 * @param objectTextArea, es el "objeto" text area (no es el value)
	 * @param longitudMaxima, cantidad de caracteres maximos que permitira el textArea
	 * @return, true si el caracter esta dentro de los permitidos, false en caso contrario
	 */
	 function validaControlaTextArea(objectTextArea, longitudMaxima) {
		 var valid = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_.- ñÑáéíóúÁÉÍÓÚ()':<>/#%$&@!¡?¿+-*,;üÜ";
		 var key = String.fromCharCode(event.keyCode);
		 var contenido = objectTextArea.value;

		cortarTextArea(objectTextArea, longitudMaxima);
		if (trim(contenido).length >= longitudMaxima) {
	 		return false;
	 	}
	 	return true;
	 	/*
		if (valid.indexOf(key) == "-1") {
			return false;
		}*/
	}

	/**
	 * Permite controlar el maximo tamaño de caracteres que pueden ingresarse al textArea
	 * @author jespejo - Juan Carlos Espejo Gavilano
	 * @version v1.0, Apr 13, 2005
	 * @param objectTextArea, es el "objeto" text area (no es el value)
	 * @param longitudMaxima, cantidad de caracteres maximos que permitira el textArea
	 */
	 function cortarTextArea(objectTextArea, longitudMaxima) {
		if (objectTextArea.value.length > longitudMaxima)
		{
			objectTextArea.value = objectTextArea.value.substring(0, longitudMaxima);
		}
	 }

	/**
	 * Anula el efecto de la tecla "enter", valido para input type text que hacen submit cuando son el unico
	 * text dentro de su formulario
	 * @author jespejo - Juan Carlos Espejo Gavilano
	 * @version v1.0, Apr 13, 2005
	 * @return true si se presiono la tecla enter, false en caso contrario
	 */
	function disableEnterKey()
	{
		if (window.event.keyCode == 13) {
			window.event.keyCode = 0;
			return true;
		}
		return false;
	}

	/**
	 * Permite controlar los tipos (extensiones) de archivos que se han de subir al servidor en caso de realizar
	 * uploads. Por ejemplo una llamada puede ser: 
	 * controlaExtensionUpload('archivo.pdf', ['jpg', 'jpeg', 'pdf', 'txt'])
	 * @author jespejo - Juan Carlos Espejo Gavilano
	 * @version v1.0, Apr 13, 2005
	 * @param fileName, nombre del archivo a validar
	 * @param fileTypes, arreglo de Strings que contiene los tipos (extensiones) de archivo validos
	 * @return true si el nombre de archivo esta vacio o si cumple con las extensiones permitidas, false en caso 
	 * contrario
	 */
	function controlaExtensionUpload(fileName, fileTypes) {
	    var cadenaMensajeError = 'Debe ingresar archivos que terminen en: \n\n.' + (fileTypes.join(", .")).toUpperCase() + '\nPor favor, elija otro archivo.';
	    var dots;
	    var fileType = '';
	    var isEncontrado = false;
	
	    if (! fileName) { // no hay nombre de archivo
	        return true;
	    }
	    if (fileName.indexOf('.') == -1) { // si no hay un punto dentro del nombre del archivo
	        alert(cadenaMensajeError);
	        return false;
	    }
	    dots = fileName.split(".");
	
	    //get the part AFTER the LAST period.
	    fileType = (dots[dots.length - 1]).toUpperCase();
	    if (! fileType) { // no hay extension indicada
	        alert(cadenaMensajeError);
	        return false;
	    }
	    for (i = 0; i < fileTypes.length; i++) {
	        if (fileType == (fileTypes[i]).toUpperCase()) {
	            isEncontrado = true;
	            break;
	        }
	    }
	    if (! isEncontrado) {
	        alert(cadenaMensajeError);
	    }
	    return isEncontrado;
	}

	/**
	 * Permite seleccionar/deseleccionar todos los checks de un formulario
	 * @author jespejo
	 * @version v1.0, Apr 13, 2005
	 * @param form = formulario
	 * @param nombreObj, nombre del checkbox
	 * @param valor, valor a setear en los checks, true para marcar y false para desmarcar
	 */
	function checkboxSelectionAll(form, nombreObj, valor){
		var objCheck = null;
		

		if (eval("typeof form." + nombreObj + " != 'undefined'")) {
			var total= eval("form." + nombreObj + ".length");

			if (total == null) { // solo hay checkbox a marcar
				objCheck = eval("form." + nombreObj);
				if(objCheck != null) {
					objCheck.checked = valor;
				}
			} else if (total > 0) { // hay mas de una checkbox a marcar
				for (var i=0; i < total; i++) {
					objCheck = eval("form." + nombreObj + "[" + i + "]");
					if (objCheck){
						objCheck.checked = valor;
					}
				}
			}
		}
	}

	/**
	 * Permite verificar si por lo menos un checkbox fue seleccionado	
	 * @author ozamora
	 * @version v1.0, Apr 13, 2005
	 * @param form = formulario
	 * @param nombreObj, nombre del checkbox
	 * @return true si hay un checkbox seleccionado y falso si no
	 */
	function validateCheckboxSelection(form,nombreObj){
		var seleccionados=false;


		if (eval("typeof form." + nombreObj + "!= 'undefined'")){
			var total= eval("form." + nombreObj + ".length");

			if (total==null){
				if(eval("form." + nombreObj + ".checked")){
					seleccionados=true;
				}
			}else if (total>0){
				for (var i=0;i<total;i++){
					if (eval("form."+ nombreObj + "[" + i + "].checked")){
						seleccionados=true;
						i=total;
					}
				}
			}
		}
		return seleccionados;
	}
	
	
	/**
	 * Ejecuta la validación e número de rut	
	 * @author avargas
	 * @version v1.0, May 19, 2005
	 * @param cc_rut : número de rut
	 * @return true si es rut y falso si no
	 */
	 function rutValido(cc_rut)
	 {
/*		  var pos = cc_rut.indexOf("-");
		  if( pos == -1 )
		  {
		   return false;
		  }*/
		  var rut = trim(cc_rut);
		  var valRut = rut.substring(0,(rut.length-1));
		  var digito = rut.substring((rut.length-1),rut.length);
		  var factor = 2;
		  var suma = 0;

		  for( var i = valRut.length-1; i >= 0; i -= 1)
		  {
			   var ch = valRut.substring(i, i + 1);
			   if (ch < "0" || ch > "9")
			   {
			    alert("El RUT ingresado no es válido");
			    return false;
			   }
			   suma = parseInt(ch) * factor + suma;
			   factor = factor + 1;
			   if( factor == 8)
			   {
			    factor = 2;
			   }
		  }
		  suma = suma % 11;
		  suma = 11 - suma;
		  if( suma == 11 )
		  {
		   suma = 0;
		  }
		  if( suma == 10 && ( digito == "k" || digito == "K" ))
		  {
		   return true;
		  }
		  else if( suma == parseInt(digito) )
		  {
		   return true;
		  }
		  alert("El RUT ingresado no es válido");
		  return false;
	 }
	 
	 /**
	 * Inserta un elemento a una control listaDestino. Dicho elemento proviene de otro control listaOrigen
	 * @author fbustamante
	 * @version v1.0, Aug 26, 2005
	 * @param listaOrigen : control origen (select)
 	 * @param listaDestino : control destino (select)
	 * @return
	 */
	 function insertarElementoLista(listaOrigen,listaDestino) {
		var index = listaOrigen.selectedIndex;
		var options = listaOrigen.options;
		var selectedText;
		var selectedValue;
		var i;
	
		if(index >= 0) {
			for(i = 0; i < options.length; i++) {
				if(options[i].selected) {
					selectedText = options[i].text;
					selectedValue = options[i].value;				
					if(listaDestino.options.length == 1) {
						if(listaDestino.options[0].value == -1) {
							listaDestino.options[0].selected = true;
							eliminarElementoLista(listaDestino,true);
						}
					}							
					if(!existeOpcion(listaDestino,selectedValue)) {	
						crearEInsertar(listaDestino,selectedValue,selectedText);
					}
				}
			}
			if(listaDestino.options.length == listaOrigen.options.length) {
				eliminarTodos(listaDestino);
			}
			listaOrigen.selectedIndex = -1;
		}
	
	}
	
	/**
	 * Elimina los elementos seleccionados de la listaDestino. Si tiene permiso tambien elimina el elemento "Todos".
	 * @author fbustamante
	 * @version v1.0, Aug 26, 2005
	 * @param listaDestino : control destino (select)
 	 * @param tienePermiso : flag de control
	 * @return
	 */
	function eliminarElementoLista(listaDestino,tienePermiso) {
		var index = listaDestino.selectedIndex;
		var opcion;
		var i;
		var encontrado;
		var hayMas = true;
	
		if(index >= 0) {
			while(hayMas) {
				i = 0;
				encontrado = false;
				while((!encontrado) && (i < listaDestino.options.length)) {
					if(listaDestino.options[i].selected && ((listaDestino.options[i].value != -1) || ((listaDestino.options[i].value == -1) && tienePermiso))) {
						opcion = listaDestino.options[i];
						listaDestino.removeChild(opcion);
						encontrado = true;					
					}
					else {
						i++;
					}
				}
				if(!encontrado) {
					hayMas = false;
				}
			}
			if((listaDestino.options.length == 0) && !tienePermiso) {
				crearEInsertar(listaDestino,"-1","Todos");
			}
		}
	}
	
	/**
	 * Elimina todos los elementos seleccionados de la listaDestino
	 * @author fbustamante
	 * @version v1.0, Aug 26, 2005
	 * @param listaDestino : control destino (select)
	 * @return
	 */
	function eliminarTodos(listaDestino) {
		var opciones = listaDestino.options;
		var i = opciones.length - 1;
		var nodo;
				
		while(i >= 0) {
			nodo = opciones[i];
			listaDestino.removeChild(nodo);
			i--;
		}
		crearEInsertar(listaDestino,"-1","Todos");
	}
	
	/**
	 * Crea e inserta un nuevo elemento <option> en el control listaDestino (<select>), con
	 * el atributo value="valor" y el label "etiqueta"
	 * @author fbustamante
	 * @version v1.0, Aug 26, 2005
	 * @param listaDestino : control destino (select)
	 * @param valor : valor del option
	 * @param etiqueta : etiqueta del option
	 * @return
	 */
	function crearEInsertar(listaDestino,valor,etiqueta) {
		var nuevoOption;
		var texto;
		
		nuevoOption = document.createElement("option");
		nuevoOption.setAttribute("value",valor);
		texto = document.createTextNode(etiqueta);
		nuevoOption.appendChild(texto);
		listaDestino.appendChild(nuevoOption);	
	}
	
	/**
	 * Verifica si existe la opcion "valor" en la listaDestino, retorna true si lo encuentra,
	 * false en caso contrario
	 * @author fbustamante
	 * @version v1.0, Aug 26, 2005
	 * @param listaDestino : control destino (select)
	 * @param valor : valor a buscar
	 * @return
	 */
	function existeOpcion(listaDestino,valor) {
		var longitud = listaDestino.options.length;
		var encontrado = false;
		var i = 0;
	
		while((i < longitud) && (!encontrado)) {
			if(listaDestino.options[i].value == valor) {
				encontrado = true;
			}
			i++;
		}
		return encontrado;
	}

/**
 * ID: MLORA-CC-05
 * Descripcion: En la variable global validacionDecimalExitosa se almacena el resultado de la validacion.
 				true en caso afirmativo y false en caso contrario.
  * @author Miguel Lora Gurreonero
 * @version 1.0
 * @fecha: Dec 27, 2005
 * @param monto monto a formatear
 * @param enteros numero máximo de enteros. -1 indica que se puede ingresar cualquier cantidad de enteros.
 * @param decimales numero máximo de decimales. -1 indica que se puede ingresar cualquier cantidad de decimales.
 * @param decSep caracter separador de la parte entera y decimal
 * @param groupSep caracter separador de miles
 * @return valor a formateado
 * @throws
 * 
 */
function validaDecimalBD(monto,enteros,decimales, decSep, groupSep)
 {
	var valor=0;
	var indActualizar = false;
	validacionDecimalExitosa = false;
	var caracterSeparadorDecimalDefecto='.';
	var cadenaVacia = '';
	
	

	if (monto.value==undefined){
		//alert("monto.value:"+monto.value);
		valor = trim(monto);
	}
	else{
		valor = trim(monto.value);
		indActualizar = true;
	}
	if(valor==''){
		alert("el valor númerico es obligatorio");
		
		return valor;
	}
	
	//se elimina el caracter separador de miles:
	valor = reemplazarCaracter(valor, groupSep,cadenaVacia);
	//si el caracter separador de la parte entera y decimal es diferente al punto
	//se reemplaza por este. 
	if (decSep!=caracterSeparadorDecimalDefecto){
		valor = reemplazarCaracter(valor,decSep,caracterSeparadorDecimalDefecto);
	}
	//se verifica si es numero:
	if(!isNumber(valor)){
			alert("Debe ingresar un número");
			return valor;
	}
	//se verifica el número de enteros. -1 indica que no se realiza esta validación:
	if (enteros>-1){
		if ( (valor.substring(0, valor.lastIndexOf(caracterSeparadorDecimalDefecto)).length == 0 &&
					valor.length > enteros ) || (
					valor.substring(0, valor.lastIndexOf(caracterSeparadorDecimalDefecto)).length > enteros )) {
				alert("No se permiten más de "+enteros+" posiciones enteras");
				return valor;
		}
	}
	//se verifica el número de decimales. -1 indica que no se realiza esta validación:
	if (decimales>-1){
		if ( valor.substring(valor.lastIndexOf(caracterSeparadorDecimalDefecto)+1, valor.length).length > decimales &&
			 valor.lastIndexOf(caracterSeparadorDecimalDefecto)!=-1) {
			alert("No se permiten más de "+decimales+" posiciones decimales");
			return valor;
		}
	}
	

	if (indActualizar){
		monto.value = valor;
	}
	validacionDecimalExitosa = true;
	return valor;
 }


/**
 * ID: MLORA-CC-05
 * Descripcion: Reemplaza en una cadena el caracter1 por el caracter2.
  * @author Miguel Lora Gurreonero
 * @version 1.0
 * @fecha: Dec 27, 2005
 * @param cadena cadena a modificar
 * @param caracter1 caracter a reemplazar
 * @param caracter2 caracter con el cual se reemplazará al caracter1
 * @return cadena modificada
 * @throws
 * 
 */
   function reemplazarCaracter( cadena, caracter1,caracter2)
   {

   	var regexstring = "\\" + caracter1;
   	var myregexp = new RegExp(regexstring,"g");
	return ((cadena != null) ? cadena.toString().replace(myregexp,caracter2) : null);

   }
//mlam-cc012
/**Esta funcion valida si es que hay suficientes criterios de busqueda,
y envia un mensaje cuando no hay suficientes y por ende va a desencadenar un query
poderoso que va a tardar en devolver la informacion*/
   function validarCantidadCriteriosBusquedaEventos(form){
	
	var pasa = true;
	//var form = document.eventoBusquedaActionForm;
	var sucursal = form.cmbSucursal.options[form.cmbSucursal.selectedIndex].value;
	var tipo_evento = form.cmbTipoEvento.options[form.cmbTipoEvento.selectedIndex].value;
	var codigo_evento = form.txtCodigoEvento.value;
	
	var nombre_cliente = form.txtNombreCliente.value;
	var rut = form.txtNumeroDocumento.value;
	var apellido_paterno = form.txtApellidoPaterno.value;
	var apellido_materno = form.txtApellidoMaterno.value;
	var fecha_evento = form.txtFechaEvento.value;
	var fecha_inscripcion = form.txtFechaInscripcion.value;
	
	var msg = "Esta consulta no tiene filtros definidos, y podria tomar varios segundos completarla\n\t\t              Desea continuar?";
	
	
	if(sucursal == "-1" && tipo_evento == "-1"){
	
		if(codigo_evento==""){
			
			if(	nombre_cliente=="" 
				&& rut == ""
				&& apellido_paterno == ""
				&& apellido_materno == ""
				&& fecha_evento == ""
				&& fecha_inscripcion == ""
			){
				//alert(msg);
				pasa = confirm(msg);
			}
		}
	}
	
	return pasa;	
}

//mlam-cc012
/**Esta funcion valida si es que hay suficientes criterios de busqueda,
y envia un mensaje cuando no hay suficientes y por ende va a desencadenar un query
poderoso que va a tardar en devolver la informacion*/
   function validarCantidadCriteriosBusquedaEventos_02(form){
	
	var pasa = true;
	//var form = document.eventoBusquedaActionForm;
	var sucursal = form.cmbSucursal.options[form.cmbSucursal.selectedIndex].value;
	var tipo_evento = form.cmbTipoEvento.options[form.cmbTipoEvento.selectedIndex].value;
	var codigo_evento = form.txtCodigoEvento.value;
	
	var nombre_cliente = form.txtNombreCliente.value;
	var rut = form.txtNumeroDocumento.value;
	var apellido_paterno = form.txtApellidoPaterno.value;
	var apellido_materno = form.txtApellidoMaterno.value;
	var apellido_paternoC2 = form.txtApellidoPaternoC2.value;
	var apellido_maternoC2 = form.txtApellidoMaternoC2.value;
	var fecha_evento = form.txtFechaEvento.value;
	var fecha_inscripcion = form.txtFechaInscripcion.value;
	
	var msg = "Esta consulta no tiene filtros definidos, y podria tomar varios segundos completarla\n\t\t              Desea continuar?";
	
	
	if(sucursal == "-1" && tipo_evento == "-1"){
	
		if(codigo_evento==""){
			
			if(	nombre_cliente=="" 
				&& rut == ""
				&& apellido_paterno == ""
				&& apellido_materno == ""
				&& apellido_paternoC2 == ""
				&& apellido_maternoC2 == ""
				&& fecha_evento == ""
				&& fecha_inscripcion == ""
			){
				//alert(msg);
				pasa = confirm(msg);
			}
		}
	}
	
	return pasa;	
}
   function validarCantidadCriteriosBusquedaEventos_03(form){
	
	var pasa = true;
	//var form = document.eventoBusquedaActionForm;
	var sucursal = form.cmbSucursal.options[form.cmbSucursal.selectedIndex].value;
	var tipo_evento = form.cmbTipoEvento.options[form.cmbTipoEvento.selectedIndex].value;
	var codigo_evento = form.txtCodigoEvento.value;
	
	var nombre_cliente1 = form.txtNombreCliente1.value;
	var nombre_cliente2 = form.txtNombreCliente2.value;
	var rut = form.txtNumeroDocumento.value;
	var apellido_paterno = form.txtApellidoPaterno.value;
	var apellido_materno = form.txtApellidoMaterno.value;
	var apellido_paternoC2 = form.txtApellidoPaternoC2.value;
	var apellido_maternoC2 = form.txtApellidoMaternoC2.value;
	var fecha_evento = form.txtFechaEvento.value;
	var fecha_inscripcion = form.txtFechaInscripcion.value;
	
	var msg = "Esta consulta no tiene filtros definidos, y podria tomar varios segundos completarla\n\t\t              Desea continuar?";
	
	
	if(sucursal == "-1" && tipo_evento == "-1"){
	
		if(codigo_evento==""){
			
			if(	nombre_cliente1=="" 
				&& nombre_cliente2 == ""
				&& rut == ""
				&& apellido_paterno == ""
				&& apellido_materno == ""
				&& apellido_paternoC2 == ""
				&& apellido_maternoC2 == ""
				&& fecha_evento == ""
				&& fecha_inscripcion == ""
			){
				//alert(msg);
				pasa = confirm(msg);
			}
		}
	}
	
	return pasa;	
}

    function setLabelFiltroNombre() {
		var form = document.eventoBusquedaActionForm;
		var tipo_evento = form.cmbTipoEvento.options[form.cmbTipoEvento.selectedIndex].value;
		if (parseInt(tipo_evento,10)==1) {
		   divNovio.style.display="";
		   divNovia.style.display="";
		   divPadre.style.display="none";
		   divMadre.style.display="none";
		   divCliente1.style.display="none";
		   divCliente2.style.display="none";
		} else {
			if (parseInt(tipo_evento,10)==2) {
			   divNovio.style.display="none";
			   divNovia.style.display="none";
			   divPadre.style.display="";
			   divMadre.style.display="";
			   divCliente1.style.display="none";
			   divCliente2.style.display="none";
			} else {
			   divNovio.style.display="none";
			   divNovia.style.display="none";
			   divPadre.style.display="none";
			   divMadre.style.display="none";
			   divCliente1.style.display="";
			   divCliente2.style.display="";
			}
		}
    }    		
