//JavaScript document valorMinMaxOrden

function number_format( number, decimals, dec_point, thousands_sep ) {
    // Format a number with grouped thousands
    // 
    // +    discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_number_format/
    // +       version: 809.2411
    // +   original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +     bugfix by: Michael White (http://getsprink.com)
    // +     bugfix by: Benjamin Lupton
    // +     bugfix by: Allan Jensen (http://www.winternet.no)
    // +    revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
    // +     bugfix by: Howard Yeend
    // *     example 1: number_format(1234.5678, 2, '.', '');
    // *     returns 1: 1234.57     
	number = number.replace(/,/g,"");
    var n = number, c = isNaN(decimals = Math.abs(decimals)) ? 2 : decimals;
    var d = dec_point == undefined ? "." : dec_point;
    var t = thousands_sep == undefined ? "," : thousands_sep, s = n < 0 ? "-" : "";
    var i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", j = (j = i.length) > 3 ? j % 3 : 0;
    
    return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
}// }}}
//---------------------------------------------------------------------------------------//
function validaEvento(e){
//---------------------------------------------------------------------------------------//
	var keynum;
	if(window.event){ 
		keynum = e.keyCode;
	}
	else if(e.which){ 
		keynum = e.which;
	}
	return keynum;
}

//---------------------------------------------------------------------------------------//
function verCalendario(auxForm,auxText){
//---------------------------------------------------------------------------------------//
	var strFeatures = 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=350,height=230,screenX=150,screenY=150,top=50,left=50';
	//alert (aux.name);
	window.open('../pages/calendario.php?nombreForm='+auxForm.name+'&nombreControl='+auxText.name,"myWin", strFeatures);
}

//---------------------------------------------------------------------------------------//
function validaNumero(texto,evento){//permite digitar solo numeros y el punto
//---------------------------------------------------------------------------------------//    
	var key = validaEvento(evento);
	
	if(key == 8){ return true; }
    if ((key < 48 || key > 57)&&(key!=46)){
        if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){			
			return false;
		}
    }
    if((key==46)&&(texto.value.indexOf('.') > -1)){
        if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){ 
			return false;
		}
    }	
}//end function validaNumero

//---------------------------------------------------------------------------------------//
function validaNumeroHora(texto){//permite digitar solo numeros y el punto 
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada  el valor de la orden
	var key = window.event.keyCode;	
	if ((key < 48 || key > 57)&&(key!=58)){
		window.event.keyCode = 0;
	}
	if((key==58)&&(texto.value.indexOf(':') > -1)){
		window.event.keyCode = 0;
	}
}//end function validaNumeroHora

//---------------------------------------------------------------------------------------//
function validaEnter(evento){	//devuelve true si se ha pulsado enter
//---------------------------------------------------------------------------------------//
	var key = validaEvento(evento);
	var flag = false;
	
	if(key==13){
		flag =  true;
	}
	return flag;
}//end function validaNumeroHora


//---------------------------------------------------------------------------------------//
function validaNumeroFecha(texto,evento){//permite digitar solo numeros y el punto 
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
	var key = validaEvento(evento);
	if ((key < 48 || key > 57)&&(key!=45)){
		if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){ 
			return false;
		}
	}
	guion = texto.value.indexOf('-');
	if(guion > -1){
		if((key==45)&&(texto.value.indexOf('-',guion+1) > 0)){
			if(window.event){ 
				evento.keyCode = 0;
				respuesta = false;
			}
			else if(evento.which){ 
				return false;
			}
		}
	}
}//end function validaNumeroFecha

//---------------------------------------------------------------------------------------//
function validaTipoPorc(texto){//permite digitar solo "V,P,v,p,E,e" 
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
	var key = window.event.keyCode;	
	//alert(key);
	if (!((key==80)||(key==86)||(key==112)||(key==118)||(key==69)||(key==101))){
		window.event.keyCode = 0;
	}// end if
}//end function validaTipoPorc

//---------------------------------------------------------------------------------------//
function validaPunto(texto){
//---------------------------------------------------------------------------------------//
    if(texto.value.indexOf('.') == 0){
        texto.value = texto.value.substr(1);
    }    
}//end function validaPunto

function DisableCtrlKey(e){
	var code = (document.all) ? event.keyCode:e.which;
	var message = "Ctrl key functionality is disabled!";
	// look for CTRL key press
	if (parseInt(code)==17){
		alert(message);
		window.event.returnValue = false;
	}
}
//---------------------------------------------------------------------------------------//
function validaSoloNumero(evento){	
//---------------------------------------------------------------------------------------//
    
	var key = validaEvento(evento);
	//alert(key);
	if(key == 8){ return true; }
	//if ((key < 48 || key > 57)&&(key!=46)){
	if (key < 48 || key > 57){
        if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){			
			return false;
		}
    }	
}//end function validaNumero

//---------------------------------------------------------------------------------------//
function validaLetra(evento){	
//---------------------------------------------------------------------------------------//
	var key = validaEvento(evento);
	//alert(key);
	if ( key != 32){
		if ((key <65  || key > 90)&&(key <97  || key > 122) && (key != 8)&& (key != 241) && (key != 209) && (key != 225) && (key != 233) && (key != 237) && (key != 243) && (key != 250)){			
			if(window.event){ 
				evento.keyCode = 0;
				respuesta = false;
			}
			else if(evento.which){			
				return false;
			}//end if
		}//end if
	}//end if
}//end function

//---------------------------------------------------------------------------------------//
function validaNumeroLetra(evento){
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
	var key = validaEvento(evento);

	if ((key < 48 || key > 57)&& key!=8){		
		if ((key <65  || key > 90)&&(key <97  || key > 122) && key!=8){			
			if(window.event){ 
				evento.keyCode = 0;
				respuesta = false;
			}
			else if(evento.which){			
				return false;
			}//end if window.event
		}//end if key < 65
	}	//end if key < 48
}//end function validaNumero

//---------------------------------------------------------------------------------------//
function validaFecha(evento){//permite digitar solo numeros y el guión (-)
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
	var key = validaEvento(evento);
	if ((key < 48 || key > 57)&&(key!=45)){
		if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){			
			return false;
		}//end if window.event
	}	
	
}//end function validaNumero

//---------------------------------------------------------------------------------------//
function validaFono(){
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
	var key = window.event.keyCode;
	//alert(key);
	if ((key < 48 || key > 57)&&(key!=43&&key!=32)){
		window.event.keyCode = 0;
	}	
}//end function validaNumero

//---------------------------------------------------------------------------------------//
function noEspacio(evento){
//---------------------------------------------------------------------------------------//
	//window.event.keyCode valor ascii de tecla pulsada
	//rango de caracteres no numericos ni alfabeticos: 33-47; 58-64; 91-96; 123-127
	var key = validaEvento(evento);
	//alert(key);
	if (key==32){
		if(window.event){ 
			evento.keyCode = 0;
			respuesta = false;
		}
		else if(evento.which){			
			return false;
		}//end if window.event
	}	
}//end function validaNumero



//---------------------------------------------------------------------------------------//
function noAccion(){
//---------------------------------------------------------------------------------------//
	window.event.keyCode = 0;
}

//verificar @ y . en una direccion e-mail
//---------------------------------------------------------------------------------------//
function validar_email(txt){	
//---------------------------------------------------------------------------------------//
	//expresion regular
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
        
    //comentar la siguiente linea si no se desea que aparezca el alert()
    alert("Email " + (b.test(txt)?"":"no ") + "válido.")
        
    //devuelve verdadero si validacion OK, y falso en caso contrario
    return b.test(txt)
}//end validar_email

//---------------------------------------------------------------------------------------//
function email_valido(texto){
//---------------------------------------------------------------------------------------//
	var txt = texto.value;
	//expresion regular
	var b=/^[^@\s]+@[^@\.\s]+(\.[^@\.\s]+)+$/
	
	if(!b.test(txt)){
		alert("Email no válido.");
		texto.focus();
	}//end if
	
	return b.test(txt)
}//end email_valido

//---------------------------------------------------------------------------------------//
function ventanaDialogo(pagina,width,height){
//---------------------------------------------------------------------------------------//
	  if(!width){ width = 400; }
	  if(!height){ height = 350; }
	  var strFeatures = "dialogWidth="+ width +"px;dialogHeight="+height+"px;center=yes;help=no;status=no;scroll=no;edge=sunken;unadorned=yes";
	  window.showModalDialog(pagina,"myWin", strFeatures);	  
}// end ventanaDialogo

///////////////////////////////////
// Rutina para validar Fecha	//

//---------------------------------------------------------------------------------------//
function esDigito(sChr){
//---------------------------------------------------------------------------------------//
	var sCod = sChr.charCodeAt(0);
	return ((sCod > 47) && (sCod < 58));
}

//---------------------------------------------------------------------------------------//
function valSep(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = false;
	bOk = bOk || ((oTxt.value.charAt(4) == "-") && (oTxt.value.charAt(7) == "-"));
//	bOk = bOk || ((oTxt.value.charAt(2) == "-") && (oTxt.value.charAt(5) == "-"));
	//bOk = bOk || ((oTxt.value.charAt(2) == "/") && (oTxt.value.charAt(5) == "/"));
	return bOk;
}

//---------------------------------------------------------------------------------------//
function finMes(oTxt){
//---------------------------------------------------------------------------------------//
	var nMes = parseInt(oTxt.value.substr(5, 2), 10);
	var nRes = 0;
	switch (nMes){
		case 1: nRes = 31; break;
		case 2: nRes = 29; break;
		case 3: nRes = 31; break;
		case 4: nRes = 30; break;
		case 5: nRes = 31; break;
		case 6: nRes = 30; break;
		case 7: nRes = 31; break;
		case 8: nRes = 31; break;
		case 9: nRes = 30; break;
		case 10: nRes = 31; break;
		case 11: nRes = 30; break;
		case 12: nRes = 31; break;
	}
	return nRes;
}

//---------------------------------------------------------------------------------------//
function valDia(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = false;
	var nDia = parseInt(oTxt.value.substr(8, 2), 10);
	//alert(nDia);
	//var nDia = parseInt(oTxt.value.substr(0, 2), 10);
	bOk = bOk || ((nDia >= 1) && (nDia <= finMes(oTxt)));
	return bOk;
}

//---------------------------------------------------------------------------------------//
function valMes(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = false;
	var nMes = parseInt(oTxt.value.substr(5, 2), 10);
	//var nMes = parseInt(oTxt.value.substr(3, 2), 10);
	bOk = bOk || ((nMes >= 1) && (nMes <= 12));
	return bOk;
}

//---------------------------------------------------------------------------------------//
function valAno(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = true;
	var nAno = oTxt.value.substr(0,4);
//	var nAno = oTxt.value.substr(6);
	bOk = bOk && ((nAno.length == 4));
//	bOk = bOk && ((nAno.length == 2) || (nAno.length == 4));
	if (bOk){
		for (var i = 0; i < nAno.length; i++){
		bOk = bOk && esDigito(nAno.charAt(i));
		}
		if (bOk){
			var anio = parseInt(nAno);
			bOk = ((anio >= 1900) && (anio <= 2777));
		}
	}
	return bOk;
}

//---------------------------------------------------------------------------------------//
function valFecha(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = true;
	if (oTxt.value != ""){
		bOk = bOk && (valAno(oTxt));
		bOk = bOk && (valMes(oTxt));
		bOk = bOk && (valDia(oTxt));
		bOk = bOk && (valSep(oTxt));
		if (!bOk){
			alert("Fecha no valida");
			oTxt.value = "";
			oTxt.focus();
			return false;
		}
	}
}

//---------------------------------------------------------------------------------------//
function valFecha2(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = true;
	if (oTxt.value != ""){
		bOk = bOk && (valAno(oTxt));
		bOk = bOk && (valMes(oTxt));
		bOk = bOk && (valDia(oTxt));
		bOk = bOk && (valSep(oTxt));
		if (!bOk){
			alert("Fecha no valida");
			oTxt.value = "";
			oTxt.focus();
			return false;
		}
	}else{
		alert("Fecha no valida");
		oTxt.value = "";
		oTxt.focus();
		return;
	}
}

// Fin Rutina para validar Fecha
///////////////////////////////////
// Rutina para validar Fecha	//
//---------------------------------------------------------------------------------------//
function valSepHora(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = false;
	bOk = bOk || ((oTxt.value.charAt(2) == ":"));
	return bOk;
}
//---------------------------------------------------------------------------------------//
function valHora(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = false;
	var nHora = parseInt(oTxt.value.substr(0, 2), 10);
	bOk = bOk || ((nHora >= 0) && (nHora <= 23));
	return bOk;
}
//---------------------------------------------------------------------------------------//
function valMinuto(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = false;
	var nMin = parseInt(oTxt.value.substr(3, 2), 10);
	bOk = bOk || ((nMin >= 0) && (nMin <= 59));
	return bOk;
}
//---------------------------------------------------------------------------------------//
function valHoras(oTxt){
//---------------------------------------------------------------------------------------//
	var bOk = true;
	if (oTxt.value != ""){
		bOk = bOk && (valHora(oTxt));
		bOk = bOk && (valMinuto(oTxt));
		bOk = bOk && (valSepHora(oTxt));
		if (!bOk){
			alert("Hora no valida");
			oTxt.value = "";
			oTxt.focus();
			return false;
		}
	}
}
// Fin Rutina para validar Hora

// habilita o deshabilita un campo de un formulario mediante un Check
//---------------------------------------------------------------------------------------//
function disabledCampo(check,campo){
//---------------------------------------------------------------------------------------//
	if ($(check).checked){
		$(campo).disabled = false;
	}else{
		$(campo).disabled = true;
	}// end if
}// end function

var elementos = new Array();
//---------------------------------------------------------------------------------------//
function ajaxCambiarTextos (dir_pagina, refrescar, destinos) {
//---------------------------------------------------------------------------------------//		
		var aux_destinos = new Array();
		var aux_contenidos = new Array();
		var contenido = "";
		
		var fecha = new Date(); 	
		var url = dir_pagina;
		/*-- Establecer los elementos de destino --*/
		
		aux_destinos = destinos.split(';');
		
		elementos.length = 0;//restablecer la variable
		
		for(i=0;i<aux_destinos.length;i++){			
			elementos[i] = $(aux_destinos[i]);
		}		
		/*-- Limpiar elementos de destino --*/
		for(i=0;i<elementos.length;i++){
			if(elementos[i]){
				elementos[i].value = "";
			}
		}//enf for contenido
		
		if (refrescar == 'S'){
			url = url+'/fecha/'+fecha;
		}//end if		
		//prompt('',url);
		//peticion.open("GET", url,sincroniza);
		new Ajax.Request(url, {
					  method: 'GET',
					  asynchronous: true,
					  onSuccess: datosHandler // si peticion se realizo correctamente ejecutar funcion js_successListadoHandler
					 //onFailure: muestraError
					});
		
		//peticion.onreadystatechange = 
	   //peticion.send(null);
	}//end ajaxCambiarTextos

//---------------------------------------------------------------------------------------//
	function datosHandler(transport) {
//---------------------------------------------------------------------------------------//		
		contenido = transport.responseText;
		//alert(peticion.responseText);
		txt = unescape(contenido);
		//txt2 = txt.replace(/\+/gi," ");				
		//alert(txt);
		if(contenido.length == 0 || contenido==""){
			alert("No se encontro el registro");
			return false;
		}
		aux_contenidos = txt.split(';');
		var k=0;
		for(i=0;i<aux_contenidos.length;i++){	
		
			if(elementos[i]){	
				//alert(elementos[i].id + " " + aux_contenidos[i]);
				elementos[i].value = aux_contenidos[i];	
			//----------esta parte solo es para el detalle de la pantalla de facfacturaMantView.php------------------------------// 	
				if (elementos[i].id.substring(0,7)=='ckb_iva'){
			
					if (elementos[i].value==1){
						elementos[i].checked=true;
						k=1;
					
					}else{
						elementos[i].checked=false;	
						k=0				
					}
					
				}// end if 
				
				if (elementos[i].id.substring(0,7)=='hid_iva'){
			
					if (k==1){
						elementos[i].value='1';
					}else{
						elementos[i].value='0';	
					}
				}// end if 		//-------------------------------------------------------------------------------------------------------------------------//		
			}
			
		}//enf for contenido				
		
	}//end datosHandler
//---------------------------------------------------------------------------------------//
	function consulta(ruta,destinos){ 
//---------------------------------------------------------------------------------------//
		ajaxCambiarTextos(ruta,'N',destinos);		
	}//end function

//---------------------------------------------------------------------------------------//
	function examinaDoc(destino){
//---------------------------------------------------------------------------------------//
		$(destino).click();
	}

//---------------------------------------------------------------------------------------//
	function redondear(cantidad, decimales) {
//---------------------------------------------------------------------------------------//
		var cantidad = parseFloat(cantidad);
		var decimales = parseFloat(decimales);		
		var resultado = 0;
		decimales = (!decimales ? 2 : decimales);
		resultado = Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales);		
		return resultado;
	}

//---------------------------------------------------------------------------------------//
	function infoDoc(){
//---------------------------------------------------------------------------------------//
		return true;		 
	}//end if

//---------------------------------------------------------------------------------------//
	function limpiarForm(idFrm){
//---------------------------------------------------------------------------------------//
		//alert(document.forms[idFrm].elements.length);
		for (i=0;i<document.forms[idFrm].elements.length;i++){			
			if(document.forms[idFrm].elements[i].length>0){				
				for(j=0;j<document.forms[idFrm].elements[i].length;j++){
					if ( document.forms[idFrm].elements[i].name.substring(0,3)== "txt" ) {
						document.forms[idFrm].elements[i][j].value="";
					}					
					if ( document.forms[idFrm].elements[i].name.substring(0,3)== "cmb" ) {
						document.forms[idFrm].elements[i][j].selected=false;
						document.forms[idFrm].elements[i].selectedIndex=0;
					}
					if ( document.forms[idFrm].elements[i].name.substring(0,3)== "lst" ) {
						document.forms[idFrm].elements[i][j].selected=false;
						//document.forms[idFrm].elements[i].selectedIndex=0;
					}
					if (document.forms[idFrm].elements[i].name.substring(0,3)== "chk" ||  document.forms[idFrm].elements[i].name.substring(0,3)== "rbt") {
						document.forms[idFrm].elements[i][j].checked=false;
					}
				}
			}else{				
				if ( document.forms[idFrm].elements[i].name.substring(0,3)== "txt" ) {
					document.forms[idFrm].elements[i].value="";
				}					
				if ( document.forms[idFrm].elements[i].name.substring(0,3)== "cmb" ) {
					document.forms[idFrm].elements[i].value=0;
				}
				if ( document.forms[idFrm].elements[i].name.substring(0,3)== "chk" ) {
					document.forms[idFrm].elements[i].checked=false;
				}
			}
		}
	}//end funcion limpiarForm
	
//---------------------------------------------------------------------------------------//	
  function addZero(vNumber){ 
//---------------------------------------------------------------------------------------//
    return ((vNumber < 10) ? "0" : "") + vNumber 
  } 

//---------------------------------------------------------------------------------------//
  function formatDate(vDate, vFormat){
//---------------------------------------------------------------------------------------//
    var vDay              = addZero(vDate.getDate()); 
    var vMonth            = addZero(vDate.getMonth()+1); 
    var vYearLong         = addZero(vDate.getFullYear()); 
    var vYearShort        = addZero(vDate.getFullYear().toString().substring(3,4)); 
    var vYear             = (vFormat.indexOf("yyyy")>-1?vYearLong:vYearShort) 
    var vHour             = addZero(vDate.getHours()); 
    var vMinute           = addZero(vDate.getMinutes()); 
    var vSecond           = addZero(vDate.getSeconds()); 
    var vDateString       = vFormat.replace(/dd/g, vDay).replace(/MM/g, vMonth).replace(/y{1,4}/g, vYear) 
    vDateString           = vDateString.replace(/hh/g, vHour).replace(/mm/g, vMinute).replace(/ss/g, vSecond) 
    return vDateString 
  } 

//---------------------------------------------------------------------------------------//
function calculaEdad(fecha,idControlx){	
//---------------------------------------------------------------------------------------//
	//fecha actual 
	var hoy = new Date(); 
    //alert('hoy'+hoy) ;	
	var mes = parseInt(hoy.getMonth());//0 es enero y 11 es diciembre
	var dia = parseInt(hoy.getDate());
	var anio = parseInt(hoy.getFullYear());
	mes = mes+1;
	
	if (fecha=='0000-00-00' || fecha==''){
		$(idControlx).value = 0;	
		return false;
	}

    //la fecha que recibo la descompongo en un array 
    var array_fecha = fecha.split("-");
    //si el array no tiene tres partes, la fecha es incorrecta 
    if (array_fecha.length!=3){ 
       return false; 
	}
    //compruebo que los anios, mes, dia son correctos 
    var anionaz; 
    anionaz = parseInt(array_fecha[0],10); 
    if (isNaN(anionaz)){ 
       return false; }
    var mesnaz; 
    mesnaz = parseInt(array_fecha[1],10);
	
    if (isNaN(mesnaz)){ 		
       return false }
    var dianaz; 
    dianaz = parseInt(array_fecha[2],10); 
    if (isNaN(dianaz)){ 
       return false; }
	
	//si el mes es el mismo pero el dia inferior aun no ha cumplido años, le quitaremos un año al actual
	if ((mesnaz == mes) && (dianaz > dia)) { 
	anio=(anio-1); } 
	//si el mes es superior al actual tampoco habra cumplido años, por eso le quitamos un año al actual
	//alert('mesnaz = '+mesnaz+' mes = '+mes)
	if (mesnaz > mes) { 
	anio=(anio-1);} 	
	//ya no habria mas condiciones, ahora simplemente restamos los años y mostramos el resultado como su edad
	
	edad=(anio-anionaz); 
	if(edad < 0){ edad = 0; }
	//return edad; 
	$(idControlx).value = edad;
}

//---------------------------------------------------------------------------------------//
function setFondo(idTabla,op,numTabs){
//---------------------------------------------------------------------------------------//
	var tbl = $(idTabla);
    var lastRow = tbl.rows.length;
	//alert(tbl.rows[0].childNodes.length);//return false;
	if(!numTabs){ numTabs=tbl.rows[0].childNodes.length; }
	for(i=0;i<numTabs;i++){
		tbl.rows[0].childNodes[i].background = "../../INMOWEB-PHP/images/index/fondotdindex.png";
		tbl.rows[0].childNodes[i].style.color = "#FFFFFF";
		if(op==(i+1)){
			tbl.rows[0].childNodes[i].background = "../../INMOWEB-PHP/images/forms/fondo_menusupe.jpg";			
			tbl.rows[0].childNodes[i].style.color = "#000000";
		}
	}
}

//---------------------------------------------------------------------------------------//
function setFondo2(idTabla,idTab,numTabs){
//---------------------------------------------------------------------------------------//
	var tbl = $(idTabla);
    var lastRow = tbl.rows.length;
	//alert(tbl.rows[0].childNodes.length);//return false;
	if(!numTabs){ numTabs=tbl.rows[0].childNodes.length; }
	for(i=0;i<numTabs;i++){
		tbl.rows[0].childNodes[i].className = "mantMenu";			
	}
	$(idTab).className = "mantMenu2";
}

//---------------------------------------------------------------------------------------//
function setFondoFila(idTabla,ind){
//---------------------------------------------------------------------------------------//	
	var tbl = $(idTabla);	
	var color = "";
	color = "#FFFFFF";
	//bgcolor="#CC9999"	
	var indice = parseInt(ind);
	//alert(indice);
	
	if(tbl){
		if(tbl.rows){
    		var Rows = tbl.rows.length;	
		}
	}
	
	//tbl.rows[indice].style.backgroundColor = "#CC9999";

	for(i=0;i<Rows;i++){
		if(i != indice){
			if($('rowSolicitud'+i)){
				$('rowSolicitud'+i).style.backgroundColor = "#FFFFFF";
			}
		}else{
			if($('rowSolicitud'+i)){
				$('rowSolicitud'+i).style.backgroundColor = "#CC9999";
			}
		}
	}//end for
}

//---------------------------------------------------------------------------------------//
function verificarCambios(tipo){
//---------------------------------------------------------------------------------------//
	if($('hid_estadoGrabar')){
		if($('hid_estadoGrabar').value == "S"){
			if(window.confirm('Desea guardar los cambios?')){
				$('hid_estadoGrabar').value = 'N';
				$('lnkGrabar').click();
				return false;
			}
		}
	}	
	frm.hid_estadoGrabar.value = 'N';	
}

//---------------------------------------------------------------------------------------//
function obtenerTextoCombo(combo,destino){
//---------------------------------------------------------------------------------------//	
	var selec = $(combo).options; 
	var indice = $(combo).selectedIndex;
	if ($(combo).value != "0"){
		$(destino).value = selec[indice].text;
	}
}//end function

//---------------------------------------------------------------------------------------//
function setValorTexto(valor,destino){
//---------------------------------------------------------------------------------------//	
	if($(destino)){
		$(destino).value = valor;
	}
	return true;
}//end function

//---------------------------------------------------------------------------------------//
function currencyFormat(fld, milSep, decSep, e) {
//---------------------------------------------------------------------------------------//
	var sep = 0; 
	var key = ''; 
	var i = j = 0; 
	var len = len2 = 0; 
	var strCheck = '0123456789'; 
	var aux = aux2 = ''; 
	var whichCode = (window.Event) ? e.which : e.keyCode; 
	if (whichCode == 13) return true; // Enter 
	key = String.fromCharCode(whichCode); // Get key value from key code 
	if (strCheck.indexOf(key) == -1) return false; // Not a valid key 
	len = fld.value.length; 
	for(i = 0; i < len; i++) 
	 if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break; 
	aux = ''; 
	for(; i < len; i++) 
	 if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i); 
	aux += key; 
	len = aux.length; 
	if (len == 0) fld.value = ''; 
	if (len == 1) fld.value = '0'+ decSep + '0' + aux; 
	if (len == 2) fld.value = '0'+ decSep + aux; 
	if (len > 2) { 
	 aux2 = ''; 
	 for (j = 0, i = len - 3; i >= 0; i--) { 
	  if (j == 3) { 
	   aux2 += milSep; 
	   j = 0; 
	  } 
	  aux2 += aux.charAt(i); 
	  j++; 
	 } 
	 fld.value = ''; 
	 len2 = aux2.length; 
	 for (i = len2 - 1; i >= 0; i--) 
	  fld.value += aux2.charAt(i); 
	 fld.value += decSep + aux.substr(len - 2, len); 
	} 
	return false; 
} //end function
//<input type="text" name="test" length="15" onKeyPress="return(currencyFormat(this,',','.',event))">

//---------------------------------------------------------------------------------------//
function formatNmb(nNmb){ 
//---------------------------------------------------------------------------------------//
	var sRes = ""; 
	for (var j, i = nNmb.length - 1, j = 0; i >= 0; i--, j++) 
	 sRes = nNmb.charAt(i) + ((j > 0) && (j % 3 == 0)? ".": "") + sRes; 
	return sRes; 
} //end function	

//---------------------------------------------------------------------------------------//
function SimularPopUpModal(){
//---------------------------------------------------------------------------------------//
	//alert(self.focus);
	if (window.opener && window.opener.focus){ 
		window.opener.focus = false; 
		self.focus(); 
	} 
} 

function popupPrueba(){
	winGeneraXML = new Window({className: "alphacube", title: 'Generar XML', 
									  top:20, left:20, width:300, height:150, 
									  url: '/congxml/index', showEffectOptions: {duration:0.5}})
						  
	winGeneraXML.showCenter();
}

//---------------------------------------------------------------------------------------//
function disabledForm2(flag){
//---------------------------------------------------------------------------------------//	
	var tabName = '';
	if($('hid_tab')){
		tabName = $('hid_tab').value;
	}
	if(tabName=='seguimiento' || tabName == 'condiciones'){
		disabledForm(false);
		/*$('txt_referencia').readOnly = true;
		$('cmb_tipoInmueble').disabled = true;
		$('cmb_operacion').disabled = true;
		$('txt_precio').readOnly = true;
		$('btn_calculadora').disabled = true;
		$('cmb_estOperacion').disabled = true;*/
		$('btn_alquiler').disabled = true;
		$('hid_accion').value = 'updG';
		return;
	}
	for (i=0;i < document.frm.elements.length; i++) { 	  	
		if ( document.frm.elements[i].name.substring(0,3)!= "hid" ) {
			document.frm.elements[i].disabled = false;
			document.frm.elements[i].tabIndex = -1;						
			if (document.frm.elements[i].name.substring(0,3)== "txt"){
				document.frm.elements[i].readOnly = true;
			}else{			
				//document.frm.elements[i].disabled = true;
			}			
			//alert(document.frm.elements[i].tabIndex);
		}
	}// end for
	$('btn_alquiler').disabled = true;
}// end function disabledForm2

//---------------------------------------------------------------------------------------//
function compararFechas(Obj1,Obj2){//devuelve true si son iguales
//---------------------------------------------------------------------------------------//
	var retorno = true;
	
	var fecha = Obj1.value;
	var fecha2 = Obj2.value;
	//las fechas que recibo la descompongo en un array 
	var array_fecha = fecha.split("-");
	var array_fecha2 = fecha2.split("-");
	//si el array no tiene tres partes, la fecha es incorrecta 
	if (array_fecha.length!=3){ 
		return false; 
	}
	if (array_fecha2.length!=3){ 
		return false; 
	}
	//compruebo que los anios, mes, dia son correctos 
	var anio; 
	anio = parseInt(array_fecha[0],10); 
	if (isNaN(anio)){ 
		return false; }
	var anio2; 
	anio2 = parseInt(array_fecha2[0],10); 
	if (isNaN(anio2)){ 
		return false; }
		
	var mes; 
	mes = parseInt(array_fecha[1],10); 
	if (isNaN(mes)){ 
		return false }
	var mes2; 
	mes2 = parseInt(array_fecha2[1],10); 
	if (isNaN(mes2)){ 
		return false }
		
	var dia; 
	dia = parseInt(array_fecha[2],10); 
	if (isNaN(dia)){ 
		return false; }
	var dia2; 
	dia2 = parseInt(array_fecha2[2],10); 
	if (isNaN(dia2)){ 
		return false; }

	if (anio>anio2){ 
		retorno = false;
	}

	if ((anio==anio2) && (mes>mes2)){
		retorno = false;
	}
	if ((anio==anio2) && (mes==mes2) && (dia>dia2)){
		retorno = false;
	}
	if(retorno == false){
		return false;
	}
	return true;
}//end function compararFechas

//---------------------------------------------------------------------------------------//
function compararFechas2(Obj1,Obj2){//devuelve 0 si son iguales -1 si la fecha1 es mayor y 1 si la fecha2 es mayor
//---------------------------------------------------------------------------------------//
	var retorno = true;
	
	var fecha = Obj1.value;
	var fecha2 = Obj2.value;
	//las fechas que recibo la descompongo en un array 
	var array_fecha = fecha.split("/");
	var array_fecha2 = fecha2.split("/");
	//si el array no tiene tres partes, la fecha es incorrecta 
	if (array_fecha.length!=3){ 
		return false; 
	}
	if (array_fecha2.length!=3){ 
		return false; 
	}
	//compruebo que los anios, mes, dia son correctos 
	var anio; 
	anio = parseInt(array_fecha[2],10); 
	if (isNaN(anio)){ 
		return false; }
	var anio2; 
	anio2 = parseInt(array_fecha2[2],10); 
	if (isNaN(anio2)){ 
		return false; }
		
	var mes; 
	mes = parseInt(array_fecha[1],10); 
	if (isNaN(mes)){ 
		return false }
	var mes2; 
	mes2 = parseInt(array_fecha2[1],10); 
	if (isNaN(mes2)){ 
		return false }
		
	var dia; 
	dia = parseInt(array_fecha[0],10); 
	if (isNaN(dia)){ 
		return false; }
	var dia2; 
	dia2 = parseInt(array_fecha2[0],10); 
	if (isNaN(dia2)){ 
		return false; }

	if (anio > anio2){ 
		retorno = -1;
	}
	if (anio2 > anio){ 
		retorno = 1;
	}

	if (anio == anio2){
		retorno = 0;
		if(mes > mes2){
			retorno = -1;
		}
		if(mes2 > mes){
			retorno = 1;
		}
		if(mes == mes2){
			retorno = 0;
			if(dia > dia2){
				retorno = -1;
			}
			if(dia2 > dia){
				retorno = 1;
			}
			if(dia == dia2){
				retorno = 0;
			}
		}//end if mes == mes2		
	}//end if anio == anio2
	return retorno;
}//end function compararFechas2

//---------------------------------------------------------------------------------------//
function previewImage(pathField, previewName){
//---------------------------------------------------------------------------------------//
	var imgRe = /^.+\.(jpg|jpeg)$/i;
    var path = pathField.value;
	
    if (path.search(imgRe) != -1){   
        //document[previewName].src = 'file://'+path;
		if($(previewName)){
			$(previewName).src = 'file://'+path;
			$(previewName).style.display = 'inline';
		}
    }else{   
        alert("Solo archivos JPG!");
		return false;
    }   
}//end function previewImage

//---------------------------------------------------------------------------------------//
function valorMinMax(obj,minimo,maximo){
//---------------------------------------------------------------------------------------//
	if(obj.value < minimo){
		alert('Valor no permitido');
			obj.value = "";
			obj.focus();
			return false;
	}else{
		if(obj.value > maximo){
			alert('Valor no permitido');
			obj.value = "";
			obj.focus();
			return false;
		}
	}
	return true;
}

//---------------------------------------------------------------------------------------//
function valorMinMaxOrden(obj,minimo,maximo){
//---------------------------------------------------------------------------------------//
	
	
	if(obj.value < minimo){
		alert('El valor de la orden debe estar entre '+ minimo + ' y '+maximo);
		
			obj.value = $('lbl_total')?$('lbl_total').innerHTML.replace(/^\s+|\s+$/g,""):minimo;
			obj.focus();
			return false;
	}else{
		if(obj.value > maximo){
			alert('El valor de la orden debe estar entre '+ minimo + ' y '+maximo);
			obj.value = $('lbl_total')?$('lbl_total').innerHTML.replace(/^\s+|\s+$/g,""):maximo;
			obj.focus();
			return false;
		}else{
			if(obj.value == '.' ){
				alert('El valor de la orden debe estar entre '+ minimo + ' y '+maximo);				
				obj.value = $('lbl_total')?$('lbl_total').innerHTML.replace(/^\s+|\s+$/g,""):minimo;
				obj.focus();
				return false;
			}//end if
		}//end if
	}//end if
	return true;
}

//---------------------------------------------------------------------------------------//
function clearControles(destinos){
//---------------------------------------------------------------------------------------//
	var aux_destinos = new Array();	
	var elementosform = new Array();
	/*-- Establecer los elementos de destino --*/
	aux_destinos = destinos.split(';');
	for(i=0;i<aux_destinos.length;i++){
		elementosform[i] = $(aux_destinos[i]);
	}		
	/*-- Limpiar elementos de destino --*/
	for(i=0;i<elementosform.length;i++){
		if(elementosform[i]){ 
			elementosform[i].value = "";			
		}
	}//enf for contenido	
}

//---------------------------------------------------------------------------------------//
function verCriterio(cajacheck,destino){
//---------------------------------------------------------------------------------------//	
	if(cajacheck.checked == true){
		visualizar = 'inline';	
	}else{
		visualizar = 'none';
	}
	
	$(destino).style.display = visualizar;
}

//---------------------------------------------------------------------------------------//
function checkearDatoContacto(frm_check,frm_hid){
//---------------------------------------------------------------------------------------//
		var estado = $(frm_hid).value;
		switch(estado){
				case 'con':
					$(frm_hid).value = "ins";
				break;
				case 'ins':
					$(frm_hid).value = "con";
				break;
				case 'del':
					$(frm_hid).value = "upd";
				break;
				case 'upd':
					$(frm_hid).value = "del";
				break;
		}//end switch
	}// end function checkearDatoContacto

//---------------------------------------------------------------------------------------//
function cambiarEstDisabled (destinos,estado) {
//---------------------------------------------------------------------------------------//		
		var aux_destinos = new Array();
		var elementosform = new Array();
		
		/*-- Establecer los elementos de destino --*/		
		aux_destinos = destinos.split(';');
		
		elementosform.length = 0;//restablecer la variable
		
		for(i=0;i<aux_destinos.length;i++){			
			elementosform[i] = $(aux_destinos[i]);
		}		
		/*-- Cambiar estado disabled en elementos de destino --*/
		for(i=0;i<elementosform.length;i++){
			if(elementosform[i]){
				elementosform[i].disabled = estado;
			}
		}//enf for contenido		
		
	}//end cambiarEstDisabled

//---------------------------------------------------------------------------------------//
function getRadioValue(idOrName) {
//---------------------------------------------------------------------------------------//
        var value = null;
        var element = $(idOrName);
        var radioGroupName = null;  
        
        // if null, then the id must be the radio group name
        if (element == null) {
                radioGroupName = idOrName;
        } else {
                radioGroupName = element.name;     
        }
        if (radioGroupName == null) {
                return null;
        }
        //var radios = document.getElementsByTagName('input');
       // for (var i=0; i<radios.length; i++) {
		$$('body input').each( function(input){
                //var input = radios[ i ];    
                if (input.type == 'radio' && input.name == radioGroupName && input.checked) {                          
                        value = input.value;
                        throw $break;
                }
        });
        return value;
}

//--------------------------------------------------------------------------------------------//
function setTogglerCheck(formId,idToggler,idChecks){
//--------------------------------------------------------------------------------------------//
	$(idToggler).observe('click',function (e) {
		var toggle = $(idToggler).checked;
		$$('#'+formId+' input[type=checkbox]').each(function(check) {
			if(check.id.substr(0,idChecks.length) == idChecks){
				check.checked = toggle;
			}//end if
		});
	});
}//end function setTogglerCheck

//---------------------------------------------------------------------------------------------//
function formatNumero(elemento){
//---------------------------------------------------------------------------------------------//

	elemento.value = number_format(elemento.value,2,'.','');
}//end fuction formatNumero

function linkZero(){
	return;
}//end function linkZero

evaluar = "";
//---------------------------------------------------------------------------------------//
function ajaxRespuesta (dir_pagina, refrescar){//llama a actions que retornen si o no y evalua script por SI
//---------------------------------------------------------------------------------------//
		var aux_contenidos = new Array();
		var contenido = "";
		
		var fecha = new Date(); 	
		var url = dir_pagina;
				
		if (refrescar == 'S'){
			url = url+'&fecha='+fecha;
		}//end if		
		//prompt('',url);
		//peticion.open("GET", url,sincroniza);
		new Ajax.Request(url, {
					  method: 'GET',
					  asynchronous: false,
					  onSuccess: successRespuestaSta
					 //onFailure: muestraError
					});
		
		//peticion.onreadystatechange = 
	   //peticion.send(null);
	}//end ajaxCambiarTextos
	
function successRespuestaSta(transport){	
	if(transport.responseText=='si'){
		evaluar.evalScripts();
		evaluar = "";
	}else{
		return false;	
	}
}//end successRespuestaSta

var winPlancta = null;
//-------------------------------------------------------------------------------------------------------------------------------//
function js_popupPlancta(destinos,fila){ 
	/*var aleatorio = Math.round(Math.random()*10);
				   window.open('/conplancta/consultarcuenta?destinos='+destinos,'DescripciondeFoto'+aleatorio,
				  'menubar=yes,location=no,resizable=yes,scrollbars=1,status=yes,width=800, height=600' );*/
	var  titulo = 'Buscar Cuentas Contables' ; 
	var  ancho  =  800 ; 
	var  largo  =  500 ;
	winPlancta = new Window({className: "alphacube", title: titulo, 
					  width:ancho, height:largo, 					  
					  maximizable: false, resizable: false,minimizable: false,
					  url: '/conplancta/consultarcuenta?destinos='+destinos, 
					  showEffectOptions: {duration:0.5}})
		  
	winPlancta.showCenter();
}//end js_popupPlancta

var winPersona = null;
//-------------------------------------------------------------------------------------------------------------------------------//
function js_popupPersona(destinos,fila){ 
	/*var aleatorio = Math.round(Math.random()*10);
				   window.open('/cxcpersona/consultarPopap?destinos='+destinos,'DescripciondeFoto'+aleatorio,
				  'menubar=yes,location=no,resizable=yes,scrollbars=1,status=yes,width=800, height=600' );*/
	var  titulo = 'Buscar Personas' ; 
	var  ancho  =  800 ; 
	var  largo  =  500 ;
	winPersona = new Window({className: "alphacube", title: titulo, 
					  width:ancho, height:largo, 					  
					  maximizable: false, resizable: false, minimizable: false,
					  url: '/cxcpersona/consultarPopap?destinos='+destinos, 
					  showEffectOptions: {duration:0.5}});
	winPersona.showCenter();
}//end js_popupPersona

var winTipRetencion = null;
//---------------------------------------------------------------------------------------------------------------------------//
function js_popupTipRetencion(destinos,fila){ 
//---------------------------------------------------------------------------------------------------------------------------//
	var  titulo = 'Buscar Tipos Retencion' ; 
	var  ancho  =  650 ; 
	var  largo  =  500 ;
	winTipRetencion = new Window({className: "alphacube", title: titulo, 
					  width:ancho, height:largo, 					  
					  maximizable: false, resizable: false, minimizable: false,
					  url: '/conretencion/consultarPopap?destinos='+destinos, 
					  showEffectOptions: {duration:0.5}});	
	winTipRetencion.showCenter();
}//end js_popupTipRetencion

//---------------------------------------------------------------------------------------------------------------------------//
function validarDocumento(campo) {
//---------------------------------------------------------------------------------------------------------------------------//
		numero = campo.value;
		var suma = 0;
		var residuo = 0;
		var pri = false;
		var pub = false;
		var nat = false;
		var numeroProvincias = 22;
		var modulo = 11;
		
		/* Verifico que el campo no contenga letras */
		if(isNaN(parseInt(numero))){
			return false;
		}
/*		var ok=1;
		for (i=0; i<numeroProvincias; i++){
			alert('El código de la provincia (dos primeros dígitos) es inválido'); return false;
		}
*/		
		/* Aqui almacenamos los digitos de la cedula en variables. */
		d1 = numero.substr(0,1);
		d2 = numero.substr(1,1);
		d3 = numero.substr(2,1);
		d4 = numero.substr(3,1);
		d5 = numero.substr(4,1);
		d6 = numero.substr(5,1);
		d7 = numero.substr(6,1);
		d8 = numero.substr(7,1);
		d9 = numero.substr(8,1);
		d10 = numero.substr(9,1); 
		
		/* El tercer digito es: */
		/* 9 para sociedades privadas y extranjeros */
		/* 6 para sociedades publicas */
		/* menor que 6 (0,1,2,3,4,5) para personas naturales */ 
		
		if (d3==7 || d3==8){
			//alert('El tercer dígito ingresado no es válido');
			return false;
		} //end if
		
		/* Solo para personas naturales (modulo 10) */
		if (d3 < 6){
			nat = true;
			p1 = d1 * 2; if (p1 >= 10) p1 -= 9;
			p2 = d2 * 1; if (p2 >= 10) p2 -= 9;
			p3 = d3 * 2; if (p3 >= 10) p3 -= 9;
			p4 = d4 * 1; if (p4 >= 10) p4 -= 9;
			p5 = d5 * 2; if (p5 >= 10) p5 -= 9;
			p6 = d6 * 1; if (p6 >= 10) p6 -= 9;
			p7 = d7 * 2; if (p7 >= 10) p7 -= 9;
			p8 = d8 * 1; if (p8 >= 10) p8 -= 9;
			p9 = d9 * 2; if (p9 >= 10) p9 -= 9;
			modulo = 10;
		} 
		
		/* Solo para sociedades publicas (modulo 11) */
		/* Aqui el digito verficador esta en la posicion 9, en las otras 2 en la pos. 10 */
		else if(d3 == 6){
			pub = true;
			p1 = d1 * 3;
			p2 = d2 * 2;
			p3 = d3 * 7;
			p4 = d4 * 6;
			p5 = d5 * 5;
			p6 = d6 * 4;
			p7 = d7 * 3;
			p8 = d8 * 2;
			p9 = 0;
		} 
		
		/* Solo para entidades privadas (modulo 11) */
		else if(d3 == 9) {
			pri = true;
			p1 = d1 * 4;
			p2 = d2 * 3;
			p3 = d3 * 2;
			p4 = d4 * 7;
			p5 = d5 * 6;
			p6 = d6 * 5;
			p7 = d7 * 4;
			p8 = d8 * 3;
			p9 = d9 * 2;
		}
		
		suma = p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
		residuo = suma % modulo; 
		
		/* Si residuo=0, dig.ver.=0, caso contrario 10 - residuo*/
		digitoVerificador = residuo==0 ? 0: modulo - residuo; 
		
		/* ahora comparamos el elemento de la posicion 10 con el dig. ver.*/
		if (pub==true){
			if (digitoVerificador != d9){
				//alert('El ruc de la empresa del sector público es incorrecto.');
				return false;
			}
			/* El ruc de las empresas del sector publico terminan con 0001*/
			if ( numero.substr(9,4) != '0001' ){
				//alert('El ruc de la empresa del sector público debe terminar con 0001');
				return false;
			}
		}
		else if(pri == true){
			if (digitoVerificador != d10){
				//alert('El ruc de la empresa del sector privado es incorrecto.');
				return false;
			}
			if ( numero.substr(10,3) != '001' ){
				//alert('El ruc de la empresa del sector privado debe terminar con 001');
				return false;
			}
		} 
		
		else if(nat == true){
			if (digitoVerificador != d10){
				//alert('El número de cédula de la persona natural es incorrecto.');
				return false;
			}
			if (numero.length >10 && numero.substr(10,3) != '001' ){
				//alert('El ruc de la persona natural debe terminar con 001');
				return false;
			}
		}
		return true;
}//end function validardocumento

//---------------------------------------------------------------------------------------------------------------------------//
function validarCedula(obj){
//---------------------------------------------------------------------------------------------------------------------------//
		if (validarDocumento(obj)==false){
			alert("Numero de Identificacion es Incorrecto");
			//obj.value = '';
			obj.focus();
			return false;
		}//end if
		return true;
}//End validarCedula

//---------------------------------------------------------------------------------------------------------------------------//
function js_consultaMov(idFrm){
//---------------------------------------------------------------------------------------------------------------------------//
	/*var parametros=$(idFrm).serialize();
	new Ajax.Request('/conmovimiento/index?consulta=1', {
			  method: 'post',
			  asynchronous: true,
			  parameters: parametros,
			  onSuccess: successconsultaMovHandler
			 //onFailure: muestraError
			});*/
/*	if ($('btn_grabar') && $('btn_grabar').className != 'button'){  // si el boton grabar esta desabilitado no realiza la accion
		return;
	}*///end if 
	$(idFrm).action = '/conmovimiento/index?consulta=1';
	//alert($(idFrm).action);
	$(idFrm).submit();
}//end function js_consultaMov

//---------------------------------------------------------------------------------------------------------------------------//
function ValidaCedula(cedula){
//---------------------------------------------------------------------------------------------------------------------------//
	alert(cedula);
	var NC, LM_Cont, valor01;

	//Se valida que la longitud no sea igual a CERO
	if (cedula.length == 0){
		       //alert('cedula incorrecta');
		       return false;          
	}//end if


	//Se valida que el número de cédula sea numérico

	if (isNaN(cedula)){
		       //alert('cedula incorrecta!!');
		       return false;
	}//end if

	len_cedula = (parseFloat(cedula) + '').length;
	switch (len_cedula){
		       case 1:
		       case 2:
		       case 3:
 		       case 4:
		       case 5:
		       case 6:
		       case 7:
		       case 8:
		       case 11:
			       //alert('Cédula no válida');
			       return false;
			       break;
	      			 default:
			       if ((len_cedula==15)&&(cedula.substring(0,1)==9)){
				      //alert('cedula correcta');
				      return true;
			       }//end if
		       switch (len_cedula){
				      case 9:
					      NC = '00'+ parseFloat(cedula);
					      break;
				      case 10:
					      NC = '0'+ parseFloat(cedula);                                                                   
					      break;
				      case 12:
					      NC = '0'+ parseFloat(cedula);
					      break;
				      case 13:
					      NC = ''+ parseFloat(cedula);
					      break;
		       }//end switch
       var Total1, Total2;
       var R1, R2, NU;
       Total1=0;
       for (LM_cont=1;LM_cont <= NC.length - 2;LM_cont=LM_cont+2){
	      valor01 =  NC.substring(LM_cont,LM_cont+1); 
	      R1 = parseFloat(valor01) * 2;                                                             
	      if (R1>9){
			      R1 = R1 + '';
			      Rx = R1;
			      R1 = parseFloat(R1.substring(0,1));
			      if (Rx.length==2){
				   R1 = parseFloat(R1) + parseFloat(Rx.substring(1,2))
			      }//end if
	      }//End if
	      R2 =  R1 + '';
	      Total1 = Total1 + parseFloat(R2.substring(R2.length-1,R2.length));
       }//end for
       Total2 = Total1;
       for (ML_cont=0;ML_cont<=NC.length-2;ML_cont=ML_cont+2){
	      valor01 = NC.substring(ML_cont, ML_cont+1);
	      Total2 = Total2 + parseFloat(valor01);
       }//End for
       NU = Total2+'';
       Total2 = 10 - NU.substring(NU.length-1,NU.length);
       NU = Total2+'';
       //alert(cedula);
       if (cedula.length>11){                                                  
		      //alert('cedula correcta');
		      return true;
       }else{
	      if ((NU.substring(NU.length-1, NU.length))==(NC.substring(NC.length-1, NC.length))){
		      //alert('cedula correcta');                                                            
		      return true;
	      }else{
		      //alert('Digito Verificar Incorrecto');
		      return false;
	      }//end if
       }//end if
	}//end switch
	// alert('Moronitor');
}//end ValidaCedula


//---------------------------------------------------------------------------------------------------------------------------
function mostrarSubmenu(idMenu){
//---------------------------------------------------------------------------------------------------------------------------
	if($('trDet_'+idMenu)){
		//alert('antes '+$('trDet_'+idMenu).visible());
		if(!$('trDet_'+idMenu).visible()){
			$('imgArr_'+idMenu).src = 'images/flechita_up.gif';
			new Effect.Appear($('trDet_'+idMenu), 
       			{duration:1, from:0, to:1.0});
			new Ajax.Request('proveedores_menu_estado.asp?opcion=A', {
					  method: 'GET',
					  asynchronous: true/*,
					  onSuccess: datosHandler // si peticion se realizo correctamente ejecutar funcion js_successListadoHandler
					 //onFailure: muestraError*/
			});
		}else{
			$('imgArr_'+idMenu).src = 'images/flechita_down.gif';
			$('trDet_'+idMenu).toggle();
			new Ajax.Request('proveedores_menu_estado.asp?opcion=O', {
					  method: 'GET',
					  asynchronous: true/*,
					  onSuccess: datosHandler // si peticion se realizo correctamente ejecutar funcion js_successListadoHandler
					 //onFailure: muestraError*/
			});
		}//end if		
	}//end if
}//end function mostrarSubmenu
