

function showDescription(lan, tipo){
	
	document.getElementById('explicacionConsulta').style.display='block';
	document.getElementById('explicacionConsulta').innerHTML=getDescriptionQuery(lan, tipo);
	setTimeout('document.getElementById("explicacionConsulta").style.display="none";', 3000);
}


function getDescriptionQuery(lan, tipo){
	try{
		if(document.getElementById('_tipoDato')){
			texto=document.getElementById('_tipoDato').options[document.getElementById('_tipoDato').selectedIndex].text;
			switch(lan){
				case 'en':
					switch(texto){
						case 'MONTHLY BALANCES':
							return 'Stocks a the end of every month.';
						case 'YEARLY BALANCES':
							return 'Stocks corresponding to the end of December of every year.';
						case 'QUARTERLY BALANCES':
							return 'Stocks at the end of each quarter (March, June, September, December).';
						case 'MONTHLY FLOWS':
							return 'flow of income/expenditure in a month.';
						case 'YEARLY FLOWS':
							return 'flow of income/expenditure in a year.';
						case 'ACCUMULATED VALUES':
							return 'flow of income/expenditure in a period of several months.';
						case 'WEEKLY RATE':
							return 'average interest rate in one particular week';
						case 'MONTHLY RATE':
							return 'average interest rate in a particular month. Also used for the average monthly exchange rate.';
						case 'YEARLY RATE':
							return 'average interest rate in a particular year. Also used for the average annual exchange rate.';		
						case 'QUARTERLY VALUES':
							return 'In quarterly Balance of Payments and Quarterly GDP, stocks or flows of every quarter.';
						case 'YEARLY VALUES':
							return 'In annual balance of payments, stocks or flows of every year.';
						case 'MONTHLY':
							return 'Calculated as the difference between the value in a month in period t and the one of previous month t-1, divided by the value in t-1';
						case 'YEARLY':
							return 'In monthly numbers is calculated as the difference between the value in a month in period t and the one of twelve months ago t-12, divided by the value in t-12. In annual numbers calculated as the difference between the value of a year t and previous year t-1,  divided by t-1';
						case 'ACCUMULATED[flows]':
							return 'Calculated as the difference between the sum of monthly flows of a period of time “t” and the sum of monthly flows of a previous period (t-1), divided by the sum of monthly flows of the previous period (t-1).';
						case 'ACCUMULATED[balances & index]':
							return 'Calculated as the difference between the value to a month t and the value observed in December of a previous year (it bases), divided by the value to December of the previous year (it bases).';
						case 'PUNTUAL PERIOD':
							return 'it shows to the referred values of a month or quarter of diverse years.Monthly indexes: Values of the index at the end of every  month.';
						case 'MONTHLY INDEX':
							return 'Value at the end of period.';
						}
					break;
				case 'es':
					switch(texto){
						case 'SALDOS MENSUALES':
							return 'Saldos a fin de mes.';
						case 'SALDOS ANUALES':
							return 'Saldos correspondientes a diciembre de cada a&ntilde;o.';
						case 'SALDOS TRIMESTRALES':
							return 'Saldos a fin de trimestre (marzo, junio, septiembre, diciembre).';
						case 'FLUJOS MENSUALES':
							return 'Corriente de ingresos/egresos en un mes.';
						case 'FLUJOS ANUALES':
							return 'Corriente de ingresos/egresos en un a&ntilde;o.';
						case 'FLUJOS ACUMULADOS':
							return 'Corriente de ingresos /egresos en un período de varios meses.';
						case 'TASA SEMANALES':
							return 'Tasa de inter&eacute;s promedio a una semana particular.';
						case 'TASA MENSUALES':
							return 'Tasa de inter&eacute;s promedio a un mes particular. Tambi&eacute;n usada para el tipo de cambio promedio mensual.';
						case 'TASA ANUALES':
							return 'Tasa de inter&eacute;s promedio a un año particular. Tambi&eacute;n usada para el tipo de cambio promedio anual.';		
						case 'VALORES TRIMESTRALES':
							return 'En balanza de pagos trimestral y en PIB trimestral corresponde al flujo/saldo  de cada trimestre.';
						case 'VALORES ANUALES':
							return 'En balanza de pagos anual corresponde al flujo/saldo  de cada a&ntilde;o..';
						case 'MENSUAL':
							return 'Calculado como la diferencia entre el valor en un mes en el período t y el del mes previo t-1, dividido por  el valor en t-1..';
						case 'ANUAL':
							return 'En cifras mensuales calculado como la diferencia entre el valor en un mes en el per&iacute;odo t y el de hace doce meses t-12, dividido por  el valor en t-12.En cifras anuales calculado como la diferencia entre el valor de un a&ntilde;o t y el a&ntilde;o anterior t-1, divido por t-1.';
						case 'ACUMULADA[flujos]':
							return 'Calculado como la diferencia entre la suma de flujos mensuales de un periodo de tiempo t y la suma de flujos mensuales de un periodo anterior t-1, dividido por la suma de flujos mensuales del periodo anterior t-1.';
						case 'ACUMULADA[saldos e indices]':
							return 'Calculado como la diferencia entre el valor a un mes t y el valor observado en diciembre del año anterior (base), dividido por el valor a diciembre del año anterior (base).';
						case 'PERIODO PUNTUAL':
							return 'Muestra los valores referidos a un mes o trimestre de diversos años.';
						case 'INDICES MENSUALES':
							return 'Valor del &iacute;ndice a fin de cada mes.';
						}
						
					break;
				
			}
		}
	}catch(e){
		alert(e);
	}
	
	
}


function doajax(){
			var xmlhttp=false;
			/* for IE...*/
			try{
				xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
			}catch(e){
				try{
					xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
				}catch(E){
					xmlhttp = false;
				}
			}
			/* for Mozilla...*/
			if(!xmlhttp && typeof XMLHttpRequest!='undefined'){
				xmlhttp = new XMLHttpRequest();
			}
			return xmlhttp;
}

function checkRow(f){
	try{
		if(f){
		}else{
			return "elemento desconocido";
		}
		if(f.rowIndex>2){
			ide=f.id;
				if(ide.length>0){
					ide2=ide.split("_");
					if(ide2[0]=='v'){
						return true;
					}else{
						return false;
					}
				}else{
					return false;
				}
		}else{
			return false;
		}
	}catch(e){
		return false;
	}
}
function subirFila(fila){
	try{
		if(fila.rowIndex>2){
			ide=fila.id;
			if(ide.length>0){
				ide2=ide.split("_");
				if(ide2[0]=='v'){
					if(checkRow(fila.parentNode.parentNode.rows[(fila.rowIndex-1)])){
						sube=fila.cloneNode(true);// fila que sube
						baja=fila.parentNode.parentNode.rows[(fila.rowIndex-1)].cloneNode(true);//fila que baja
						fila.parentNode.replaceChild(sube, fila.parentNode.parentNode.rows[(fila.rowIndex-1)]);//subiendo..
						fila.parentNode.replaceChild(baja, fila);//bjando...
					}
				}else{
					return;
				}
			}
		}
	}catch(e){
	}
}
function getPreviousRow(fila){
	try{
		if(fila.rowIndex>3){
			index=fila.rowIndex;
			while(checkRow(fila.parentNode.parentNode.rows[(index-1)])){
				index-=1;
			}
			return fila.parentNode.parentNode.rows[(index-1)];
		}else{
			return -1;
		}
	}catch(e){
		return -1;
	}
}
function subirCuadro(fila){
	try{
		filasAMover=new Array();
		filasAMover.push(fila.cloneNode(true));
		index=fila.rowIndex;
		tabla=fila.parentNode.parentNode;
		while(checkRow(fila.parentNode.parentNode.rows[(index+1)])){
			filasAMover.push(fila.parentNode.parentNode.rows[(index+1)].cloneNode(true));
			index+=1;
		}
		lastrow=getPreviousRow(fila);
		if(lastrow!=-1){
			index=lastrow.rowIndex;
			filasAMover.push(lastrow.cloneNode(true));
			while(checkRow(lastrow.parentNode.parentNode.rows[(index+1)])){
				filasAMover.push(lastrow.parentNode.parentNode.rows[(index+1)].cloneNode(true));
				index+=1;
			}
			u=lastrow.rowIndex;
			for(i=0; i<filasAMover.length; i++){
				tabla.rows[u].innerHTML=filasAMover[i].innerHTML;
				tabla.rows[u].id=filasAMover[i].id;
				
				u+=1;
			}
			
		}else{
			return;
		}	
	}catch(e){
		alert(e);
	}
}
function bajarFila(fila){
	try{
		if(fila.rowIndex>2){
			ide=fila.id;
			if(ide.length>0){
				ide2=ide.split("_");
				if(ide2[0]=='v'){
					if(checkRow(fila.parentNode.parentNode.rows[(fila.rowIndex+1)])){
						baja=fila.cloneNode(true); // fila que va a bajar
						sube=fila.parentNode.parentNode.rows[(fila.rowIndex+1)].cloneNode(true); // fila que va a subir
						fila.parentNode.replaceChild(baja, fila.parentNode.parentNode.rows[(fila.rowIndex+1)]);// subiendo...
						fila.parentNode.replaceChild(sube, fila);//bajando...
					}
				}else{
					return;
				}
			}
		}
	}catch(e){
	}
}


function activarCarteleraProgramacion(col, activacion){
	var tbody=document.getElementById('carteleraProgramacion');
	if(tbody){
		for(var i=0; i<tbody.rows.length; i++){
			if(activacion){
				tbody.rows[i].getElementsByTagName('td')[col+1].style.backgroundColor ="#ffffff";			
			}else{
				tbody.rows[i].getElementsByTagName('td')[col+1].style.backgroundColor="#777777";
			}
		}
	}
}

//llenarVariablesOptions
function llenarTiposCuadro(contenedor, selectCuadro, sector){
	
		if(contenedor && selectCuadro){
			var req =  doajax();
			if(req){
				req.onreadystatechange=function(){
					if(req.readyState==4){
						contenedor.innerHTML+=req.responseText;
						llenarVariablesOptions(selectCuadro, document.getElementById('_variables'+sector+''), sector)
					}else{
						contenedor.innerHTML="";
					}
				}	
				req.open("GET", root+"jsincronoEstadisticas.php?req=tiposDatosCuadro&cdr="+selectCuadro.value+"&sector="+sector, true);
				req.send(null);		
			}
		}
	
}

function llenarVariablesOptions(selectCuadro, selectVariables, sector){ //agregar una variable a la cartelera en el panel de administración del CMS
	
		if(selectCuadro && selectVariables){
			var req =  doajax();
			if(req){
				req.onreadystatechange=function(){
					if(req.readyState==4){
						//selectVariables.innerHTML='<option value="-'+selectCuadro.value+'">Entrada Manual</option>';
						selectVariables.innerHTML+=req.responseText;
					}else{
						selectVariables.innerHTML="";
					}
				}	
				req.open("GET", root+"jsincronoEstadisticas.php?req=variablesOptions&cdr="+selectCuadro.value+"&sector="+sector, true);
				req.send(null);		
			}
		}
	
}
		
function agregarVariableCartelera(idVar, tbodyy, idcuadro, tipoDato){ //agregar una variable a la cartelera en el panel de administración del CMS
	if(idVar>0){
		var tr=document.createElement("tr");
		tr.className="trCalendario";
		var td=document.createElement("td");
		td.style.textAlign="center";
		td.innerHTML="cargando";
		tr.appendChild(td);
		tbodyy.appendChild(tr);
		var req =  doajax();
		if(req){
			req.onreadystatechange=function(){
				if(req.readyState==4){
					tr.innerHTML=req.responseText;
					
					setPriorities();
				}else{
					td.innerHTML+=".";
				}
			}	
			req.open("GET", root+"jsincronoEstadisticas.php?req=tableVarsUI_carFMI&idVar="+idVar+"&tipoDato="+tipoDato, true);
			req.send(null);		
		}
	}else{
		var tr=document.createElement("tr");
		tr.className="trCalendario";
		var td1=document.createElement("td"); //
		var input1=document.createElement("input"); //prioridad
			input1.type="hidden";
			input1.name="priority[]";
		var input2=document.createElement("input"); //idCuadro
			input2.value=idcuadro;
			input2.type="hidden";
		var input3=document.createElement("input"); //variable
			input3.type="hidden";
			input3.value=idVar;
		var input4=document.createElement("input"); //nombre
			input4.value="-escriba un nombre-"
			input4.type="text";
			input4.style.width="100%";
		td1.appendChild(input1);//prioridad
		td1.appendChild(input2);//idcuadro
		td1.appendChild(input3);//variable
		td1.appendChild(input4);//nombre
		tr.appendChild(td1);
		for(var i=1; i<=6; i++){ //unidad, el fecha ultima, la valor ultimo, el penultimo, la tasa, el info
			var td=document.createElement("td"); //
			var input=document.createElement("input");
			input.type="text";
			td.appendChild(input);
			tr.appendChild(td);
		}
			var input=document.createElement("input");
			input.type="hidden";
			input.value=tipoDato;
			td.appendChild(input);
		var td=document.createElement("td"); //
			td.innerHTML='<a href="#" onclick="javascript:this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);return false">Eliminar<a />'
			tr.appendChild(td);
			tbodyy.appendChild(tr);
		setPriorities();
	}
	
	
}

function setPriorities(){
	var tablas = document.getElementById('carteleraFMI');
	orden=0;
	if(tablas){
		bodies=tablas.getElementsByTagName('tbody');
		if(bodies.length>0){
			for(var i=0; i<bodies.length; i++){
				for(var ii=0; ii<bodies[i].rows.length; ii++){
					if(bodies[i].rows[ii].getElementsByTagName('input').length==0){
						continue;
					}
					inputs=bodies[i].rows[ii].getElementsByTagName('input');
					inputs[0].value=orden;
					for(var a = 1; a<inputs.length; a++){
						inputs[a].name="data"+orden+"[]"
					}
					orden+=1;
				}
			}
		}
	}
}

function anexarConsulta(){
	if(document.getElementById('_valores') && document.getElementById('setValores')){
		NuevoDiv=document.createElement('div');
		NuevoDiv.style.float='left';
		NuevoDiv.innerHTML=document.getElementById('setValores').innerHTML;
		document.getElementById('_valores').appendChild(NuevoDiv);
		NuevoDiv.getElementsByTagName('tbody')[0].id="_";
	}
}
	
	
	function mostrar_ocultar(elemento){
	
	if (elemento.getElementsByTagName('ul')[0]){
		if(elemento.getElementsByTagName('ul')[0].style.display=='none'){
			elemento.getElementsByTagName('ul')[0].style.display='block';
		}else{
			elemento.getElementsByTagName('ul')[0].style.display='none';
		}
	}

}

function mostrar_ocultar_Obj(elemento){
	
	if (elemento){
		if(elemento.style.display=='none'){
			elemento.style.display='block';
		}else{
			elemento.style.display='none';
		}
	}

}

function getVariablesCalDivulOf(idCuadro, checked, contenedor){
	if(checked){
		contenedor.style.display="block";
		contenedor.innerHTML="cargando.";
		var req =  doajax();
		if(req){
			req.onreadystatechange=function(){
				if(req.readyState==4){
					contenedor.innerHTML=req.responseText;
				}else{
					contenedor.innerHTML+=".";
				}
			}	
			req.open("GET", root+"jsincronoEstadisticas.php?req=varsNamesUI_calDiv&cdr="+idCuadro, true);
			req.send(null);		
		}
	}else{
		contenedor.style.display="none";
		contenedor.innerHTML="";
	}
	
}

function getVariablesCarFMIOf(cdr, checked, contenedor, tipoDato){
	if(checked){
		
		var req =  doajax();
		if(req){
			req.onreadystatechange=function(){
				if(req.readyState==4){
					contenedor.innerHTML=req.responseText;
		
				}
			}	
			req.open("GET", root+"jsincronoEstadisticas.php?req=tableVarsUI_carFMI&cdr="+cdr+"&tipoDato="+tipoDato, true);
			req.send(null);		
		}
	}else{
		
		contenedor.innerHTML="";
	}
	
}

function exists(aguja, pajar){
	for(var i=0; i<pajar.length-aguja.length; i++){
		if(pajar.substr(i, (aguja.length)).toUpperCase()==aguja.toUpperCase()){
			return true;
		}
	}
	return false;
}

function mostrarOcultarFilas(ancla, tag){
	tbodddy=null
	if(mostrarOcultarFilas.arguments[2]){
		tbodddy=mostrarOcultarFilas.arguments[2];
	}else{
		if(document.getElementById('tbl_setNombres')){
			tbodddy=document.getElementById('tbl_setNombres');
		}else{
			return;
		}
	}
		var tbodyN=tbodddy;
		var tbodyV = null;
		if(document.getElementById('tbl_setValores')){
			tbodyV=document.getElementById('tbl_setValores');
		}
		nuevoString = ancla.innerHTML;
		mostrar=false;
		existe=(exists("[+]",ancla.innerHTML));
		if(existe){
			nuevoString=ancla.innerHTML.replace("[+]", "[-]");
			mostrar=true;
		}else{
			nuevoString=ancla.innerHTML.replace("[-]", "[+]");
			mostrar=false;
		}
		/*if(ancla.innerHTML.substr(0, 3).toUpperCase()=="[+]"){
			nuevoString=ancla.innerHTML.replace("[+]", "[-]");
			mostrar=true;
		}else{
			nuevoString=ancla.innerHTML.replace("[-]", "[+]");
			mostrar=false;
		}*/
		ancla.innerHTML=nuevoString;
		//alert(mostrar);
		for(var i=0;i< tbodyN.rows.length; i++){
			if(tbodyN.rows[i].id.substr(0, tag.length+1)==(tag+"_")){
				//alert(tbodyN.rows[i].id.substr(0, tag.length+1)+"=="+tag+"_");
				if(mostrar){
					tbodyN.rows[i].style.display=(navigator.appName=="Microsoft Internet Explorer"?"block":"table-row");
					if(tbodyV!=null){
						if(tbodyV.rows[i]){
							tbodyV.rows[i].style.display=(navigator.appName=="Microsoft Internet Explorer"?"block":"table-row");
						}
					}
				}else{
					tbodyN.rows[i].style.display='none';
					if(tbodyV!=null){
						if(tbodyV.rows[i]){
							tbodyV.rows[i].style.display='none';
						}
					}
				}
				
					
			}
		}
	
}



function mostrarOcultarFilas2(ancla, tag, tbbody){
	if(tbbody){
		var tbodyN=tbbody;
		var tbodyV = null;
		if(document.getElementById('tbl_setValores')){
			tbodyV=document.getElementById('tbl_setValores');
		}
		nuevoString = ancla.innerHMTL;
		mostrar=false;
		if(ancla.innerHTML.substr(0, 3).toUpperCase()=="[+]"){
			nuevoString=ancla.innerHTML.replace("[+]", "[-]");
			mostrar=true;
		}else{
			nuevoString=ancla.innerHTML.replace("[-]", "[+]");
			mostrar=false;
		}
		ancla.innerHTML=nuevoString;
		for(var i=0;i< tbodyN.rows.length; i++){
			if(tbodyN.rows[i].id.substr(0, tag.length+1)==(tag+"_")){
				if(mostrar){
					tbodyN.rows[i].style.display=(navigator.appName=="Microsoft Internet Explorer"?"block":"table-row");
					if(tbodyV!=null){
						if(tbodyV.rows[i]){
							tbodyV.rows[i].style.display=(navigator.appName=="Microsoft Internet Explorer"?"block":"table-row");
						}
					}
				}else{
					tbodyN.rows[i].style.display='none';
					if(tbodyV!=null){
						if(tbodyV.rows[i]){
							tbodyV.rows[i].style.display='none';
						}
					}
				}
				
					
			}
		}
	}
}



function chequearHijos(checkbox){
	checks=document.getElementsByName('variable[]');
	for(var i=0; i<checks.length; i++){
		if(checks[i].id.length>checkbox.id.length){
			if(checks[i].id.substr(0, checkbox.id.length+1)==(checkbox.id+"_")){
				checks[i].checked=checkbox.checked;
			}
		}
	}
}

function cambioDeAnoFinal(valor){
	if(document.getElementById('_finAno') && document.getElementById('_inicioAno')){
		
		if(valor>document.getElementById('_inicioAno').value){ // solo si el año final es mayor que el inicial se ponen todos los elementos
			var seleccionado=document.getElementById('_finMes').value;
			meses_opciones=document.getElementById('_finMes').options;
				while(meses_opciones.length>0){
					meses_opciones[0]=null;
				}
			for(var t=0; t<document.getElementById('_inicioMes').options.length; t++){
				meses_opciones[meses_opciones.length]=new Option(document.getElementById('_inicioMes').options[t].text,document.getElementById('_inicioMes').options[t].value);
				if(meses_opciones[meses_opciones.length-1].value==seleccionado){
					meses_opciones[meses_opciones.length-1].selected=true;
				}
				
			}
			
		}
		if(valor==document.getElementById('_inicioAno').value){ // solo si el año final es mayor que el inicial se ponen todos los elementos
			var seleccionado=document.getElementById('_finMes').value;
			meses_opciones=document.getElementById('_finMes').options;
				while(meses_opciones.length>0){
					meses_opciones[0]=null;
				}
			for(var t=document.getElementById('_inicioMes').selectedIndex; t<document.getElementById('_inicioMes').options.length; t++){
				
				meses_opciones[meses_opciones.length]=new Option(document.getElementById('_inicioMes').options[t].text,document.getElementById('_inicioMes').options[t].value);
				if(meses_opciones[meses_opciones.length-1].value==seleccionado){
					meses_opciones[meses_opciones.length-1].selected=true;
				}
				
			}
			
		}
		
	}
	if(periodicidad=="SEMANAL"){
		getSemana(document.getElementById('_finMes').value,  document.getElementById('_finAno').value, document.getElementById('semFin'));
	}
}

function cambioDeMesFinal(){
	if(periodicidad=="SEMANAL"){
		getSemana(document.getElementById('_finMes').value,  document.getElementById('_finAno').value, document.getElementById('semFin'));
	}
}

function getSemana(s, a, contenedor){
	try{
		if(document.getElementById('semIni') && document.getElementById('semFin')){
			var req =  doajax();
			if(req){
				req.onreadystatechange=function(){
					if(req.readyState==4){
						contenedor.innerHTML=req.responseText;
			
					}
				}	
				req.open("GET", root+"jsincronoEstadisticas.php?sem=170882&s="+s+"&a="+a, true);
				req.send(null);		
			}
		}else{
			return;
		}
	}catch(e){
	}
}

function cambioDeMesInicial(valor){
	try{
		
		
		if(document.getElementById('_tipoDato').value=='ACUMULADO' || document.getElementById('_tipoDato').value=='TASA DE CRECIMIENTO ACUMULADA'){
				anos_opciones=document.getElementById('_finAno').options;
				while(anos_opciones.length>0){
					anos_opciones[0]=null;
				}
				anos_opciones=document.getElementById('_finAno').options;
				var limite=document.getElementById('_inicioAno').options.length;
				if(lastmonth<document.getElementById('_inicioMes').value){
						limite-=1;
				}
				for(var i=0; i<limite; i++){
						if(document.getElementById('_inicioAno').options[i].value >= document.getElementById('_inicioAno').value){
							anos_opciones[anos_opciones.length]=new Option(
							document.getElementById('_inicioAno').options[i].value,
							document.getElementById('_inicioAno').options[i].value);
						}
				}
				
				return;
		}
		meses_opciones=document.getElementById('_finMes').options;
		while(meses_opciones.length>0){
			meses_opciones[0]=null;
		}
		if(document.getElementById('_finAno').value==document.getElementById('_inicioAno').value){
				for(var t=0; t<document.getElementById('_inicioMes').options.length; t++){
					if(parseInt(document.getElementById('_inicioMes').options[t].value)>=parseInt(valor)){
							meses_opciones[meses_opciones.length]=new Option(document.getElementById('_inicioMes').options[t].text,document.getElementById('_inicioMes').options[t].value);
					}
				}
		}
		if(document.getElementById('_finAno').value > document.getElementById('_inicioAno').value){
				for(var t=0; t<document.getElementById('_inicioMes').options.length; t++){
					meses_opciones[meses_opciones.length]=new Option(document.getElementById('_inicioMes').options[t].text,document.getElementById('_inicioMes').options[t].value);
				}
		}
		
		if(periodicidad=="SEMANAL"){
			getSemana(document.getElementById('_inicioMes').value,  document.getElementById('_inicioAno').value, document.getElementById('semIni'));
		}
	}catch(e){
	}
	
}

function cambioDeAnoInicial(valor){
	try{
		anos_opciones=document.getElementById('_finAno').options;
		document.getElementById('_finAno').value=valor;
		while(anos_opciones.length>0){
			anos_opciones[0]=null;
		}
		anos_opciones=document.getElementById('_finAno').options;
		for(var i=0; i<document.getElementById('_inicioAno').options.length; i++){
			if(document.getElementById('_inicioAno').options[i].value >= valor){
				anos_opciones[anos_opciones.length]=new Option(
				document.getElementById('_inicioAno').options[i].value,
				document.getElementById('_inicioAno').options[i].value);
			}
		}
		cambioDeMesInicial(document.getElementById('_inicioMes').value);
		if(periodicidad=="SEMANAL"){
		getSemana(document.getElementById('_finMes').value,  document.getElementById('_finAno').value, document.getElementById('semFin'));
	}
	}catch(e){
	
	}
}



function selectDato(dato){
	try{
		if(post==false){
		cambioDeMesInicial(document.getElementById('_inicioMes').value);
	}
	if(periodicidad.toUpperCase()=="MENSUAL" 
		|| periodicidad.toUpperCase()=="TRIMESTRAL"
		|| periodicidad.toUpperCase()=="SEMANAL"
		|| periodicidad.toUpperCase()=="DIARIA"){
		
		//peri=peri.toUpperCase();
		var txt1=document.getElementById('txt1');
		var txt2=document.getElementById('txt2');
		var txt3=document.getElementById('txt3');
		var txt4=document.getElementById('txt4');
		
		if (dato.toUpperCase()=="TASA DE CRECIMIENTO ANUAL"){
			document.getElementById('inicioMes_').style.display='block';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='block';
			document.getElementById('finAno_').style.display='block';
			txt1.innerHTML=(langg=='es'?'Desde':'From');
			txt2.innerHTML='';
			txt3.innerHTML=(langg=='es'?'Hasta':'To');
			txt4.innerHTML='';
		}
		if (dato.toUpperCase()=="TASA DE CRECIMIENTO PERIODO"){
			document.getElementById('inicioMes_').style.display='block';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='block';
			document.getElementById('finAno_').style.display='block';
			txt1.innerHTML=(langg=='es'?'Desde':'From');
			txt2.innerHTML='';
			txt3.innerHTML=(langg=='es'?'Hasta':'To');
			txt4.innerHTML='';
		}
		if (dato.toUpperCase()=="ACUMULADO"){
		
			document.getElementById('inicioMes_').style.display='block';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='none';
			document.getElementById('finAno_').style.display='block';
			if(periodicidad.toUpperCase()=="MENSUAL"){
				txt1.innerHTML=(langg=='es'?'Enero hasta':'January to');
			}
			if(periodicidad.toUpperCase()=="TRIMESTRAL"){
				txt1.innerHTML=(langg=='es'?'Desde Trim I hasta':'From IQ to');
			}
			if(periodicidad.toUpperCase()=="SEMANAL"){
				txt1.innerHTML=(langg=='es'?'S-1 hasta':'W-1 to');
			}
			if(periodicidad.toUpperCase()=="DIARIA"){
				txt1.innerHTML=(langg=='es'?'1er dia hasta':' to');
			}
			txt2.innerHTML=(langg=='es'?'Desde':'From');
			txt3.innerHTML=''
			txt4.innerHTML=(langg=='es'?'Hasta':'To');
				anofinal=document.getElementById('_finAno').value;
				anos_opciones=document.getElementById('_finAno').options;
				while(anos_opciones.length>0){
					anos_opciones[0]=null;
				}
				anos_opciones=document.getElementById('_finAno').options;
				var limite=document.getElementById('_inicioAno').options.length;
				if(lastmonth<document.getElementById('_inicioMes').value){
						limite-=1;
				}
				for(var i=0; i<limite; i++){
						if(document.getElementById('_inicioAno').options[i].value >= document.getElementById('_inicioAno').value){
							anos_opciones[anos_opciones.length]=new Option(
							document.getElementById('_inicioAno').options[i].value,
							document.getElementById('_inicioAno').options[i].value);
						}
				}
				if(post==true){
					document.getElementById('_finAno').value=anofinal;
				}
				
				
			
		}
		if (dato.toUpperCase()=="PERIODO PUNTUAL"){
			document.getElementById('inicioMes_').style.display='block';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='none';
			document.getElementById('finAno_').style.display='block';
			txt1.innerHTML='';
			txt2.innerHTML=(langg=='es'?'Deste':'From');
			txt3.innerHTML=''
			txt4.innerHTML=(langg=='es'?'Hasta':'To');
		}
		if (dato.toUpperCase()=="CIFRAS ANUALES"){
			document.getElementById('inicioMes_').style.display='none';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='none';
			document.getElementById('finAno_').style.display='block';
			txt1.innerHTML='';
			txt2.innerHTML=(langg=='es'?'Deste':'From');
			txt3.innerHTML=''
			txt4.innerHTML=(langg=='es'?'Hasta':'To');
		}
		if (dato.toUpperCase()=="TASA DE CRECIMIENTO ACUMULADA"){
			document.getElementById('inicioMes_').style.display='block';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='none';
			document.getElementById('finAno_').style.display='block';
			if(periodicidad.toUpperCase()=="MENSUAL"){
				txt1.innerHTML=(langg=='es'?'Enero hasta':'January to');
			}
			if(periodicidad.toUpperCase()=="TRIMESTRAL"){
				txt1.innerHTML=(langg=='es'?'Desde Trim I hasta':'From IQ to');
			}
			if(periodicidad.toUpperCase()=="SEMANAL"){
				txt1.innerHTML=(langg=='es'?'S-1 hasta':'W-1 to');
			}
			if(periodicidad.toUpperCase()=="DIARIA"){
				txt1.innerHTML=(langg=='es'?'1er dia hasta':' to');
			}
			txt2.innerHTML=(langg=='es'?'Desde':'From');
			txt3.innerHTML=''
			txt4.innerHTML=(langg=='es'?'Hasta':'To');
				
				anofinal=document.getElementById('_finAno').value;
				anos_opciones=document.getElementById('_finAno').options;
				while(anos_opciones.length>0){
					anos_opciones[0]=null;
				}
				anos_opciones=document.getElementById('_finAno').options;
				var limite=document.getElementById('_inicioAno').options.length;
				if(lastmonth<document.getElementById('_inicioMes').value){
						limite-=1;
				}
				for(var i=0; i<limite; i++){
						if(document.getElementById('_inicioAno').options[i].value >= document.getElementById('_inicioAno').value){
							anos_opciones[anos_opciones.length]=new Option(
							document.getElementById('_inicioAno').options[i].value,
							document.getElementById('_inicioAno').options[i].value);
						}
				}
				if(post==true){
					document.getElementById('_finAno').value=anofinal;
				}
				
		}
		if (dato.toUpperCase()=="SALDOS" 
			|| dato.toUpperCase()=="FLUJOS"
			|| dato.toUpperCase()=="PRODUCCION BRUTA|CONSUMO INTER.|VALOR AGREGADO"
			|| dato.toUpperCase()=="TENDENCIA CICLO|SIMPLE"
			|| dato.toUpperCase()=="CREDITOS|DEBITOS|SALDO"
			|| dato.toUpperCase()=="TENDENCIA CICLO"
			|| dato.toUpperCase()=="SIMPLE"
			|| dato.toUpperCase()=="PRECIOS CORRIENTES|PRECIOS CONSTANTES"
			|| dato.toUpperCase()=="TASA"
			|| dato.toUpperCase()=="INDICES"
			|| dato.toUpperCase()=="TASA DE CRECIMIENTO ACUMULADA[ESP]"
			|| dato.toUpperCase()=="ACUMULADO[ESP]"){
			
			document.getElementById('inicioMes_').style.display='block';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='block';
			document.getElementById('finAno_').style.display='block';
			
			txt1.innerHTML=(langg=='es'?'Desde':'From');
			
			txt2.innerHTML='';
			
			txt3.innerHTML=(langg=='es'?'Hasta':'To');
			
			txt4.innerHTML='';
			
		}
		
	}
	if(periodicidad=="ANUAL"){
		txt1=document.getElementById('txt1');
		txt2=document.getElementById('txt2');
		txt3=document.getElementById('txt3');
		txt4=document.getElementById('txt4');
		txt1.innerHTML='';
		txt2.innerHTML=(langg=='es'?'Desde':'From');
		txt3.innerHTML='';
		txt4.innerHTML=(langg=='es'?'Hasta':'To');
		if (dato.toUpperCase()=="TASA DE CRECIMIENTO ANUAL"){
			document.getElementById('inicioMes_').style.display='none';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='none';
			document.getElementById('finAno_').style.display='block';
			
		}
		if (dato.toUpperCase()=="TASA DE CRECIMIENTO PERIODO"){
			document.getElementById('inicioMes_').style.display='none';
			document.getElementById('inicioAno_').style.display='block';
			document.getElementById('finMes_').style.display='none';
			document.getElementById('finAno_').style.display='block';
		}
	}
		
	}catch(e){
		
	}
}


function entrar_intercepcion2(celda){
	var	tbodyV=celda.parentNode.parentNode;
	celda.style.bgColor="#ffffff";
	if(!(tbodyV)){
		return;
	}
	for(var i=0; i<tbodyV.rows.length; i++){
		for(var u=1;u < tbodyV.rows[i].cells.length; u++){
			if(tbodyV.rows[i].cells[u].cellIndex==celda.cellIndex || tbodyV.rows[i].cells[u].parentNode.rowIndex==celda.parentNode.rowIndex){
				tbodyV.rows[i].cells[u].bgColor="#ffffff";
			}else{
				tbodyV.rows[i].cells[u].bgColor="#999999";
			}
		}
				
	}
}


function tipp(e){
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY){
		posx = e.pageX;
		posy = e.pageY;
	}else if (e.clientX || e.clientY){
		posx = e.clientX;
		posy = e.clientY;
	}
	tp=document.getElementById('tipCelda');
	tp.style.left = posx;
	tp.style.top = posy;
	
}

function entrar_intercepcion(celda){
	/*try{
		tp=document.getElementById("tipCelda");
		tp.style.display="block";
		tp.innerHTML+=celda.style.top;
	}catch(e){
	}*/
	
	
	var tbodyN=document.getElementById('tbl_setNombres');
	var	tbodyV=document.getElementById('tbl_setValores');
	if(!(tbodyN && tbodyV)){
		return;
	}
	for(var i=0; i<tbodyN.rows.length; i++){
		tbodyN.rows[i].cells[0].style.backgroundColor="white";
	}
	tbodyN.rows[celda.parentNode.rowIndex-2].cells[0].style.backgroundColor="yellow";
	for(var i=2; i<=tbodyV.rows.length; i++){
		if((i-2)!=(celda.parentNode.rowIndex-2)){
			for(var o=0; o<tbodyV.rows[i-2].cells.length; o++){
				if(o==celda.cellIndex){
					tbodyV.rows[i-2].cells[o].style.backgroundColor="yellow";
				}else{
					tbodyV.rows[i-2].cells[o].style.backgroundColor="white";
				}
			}
		}else{
			for(var o=0; o<tbodyV.rows[i-2].cells.length; o++){
				tbodyV.rows[i-2].cells[o].style.backgroundColor="yellow";
			}
		}
	}
	
	
}
function dejar_intercepcion(celda){
	try{
		document.getElementById("tipCelda").style.display="none";
	}catch(e){
	}
}


function mostrar_ocultarHijos(ulHijos){
	if(ulHijos){
		if(ulHijos.style.display=='none'){
			ulHijos.style.display='block';
		}else{
			ulHijos.style.display='none';
		}
	}
}

//*******************************FUNCIONES PARA LA PARTE DE LOS CUADROS EN EL ADMINISTRADOR*************************//

function ocultar_mostrarContentCuadro(textArea){
	//alert(textArea)
	if(textArea){
		if(textArea.style.display=='none'){
			textArea.style.display='block';
		}else{
			textArea.style.display='none';
		}
	}
}

//*******************************FUNCIONES PARA LA PARTE DE LOS VARIABLES EN EL ADMINISTRADOR*************************//

function mostrar_ocultarArbolDeVariables(divVariables){
	//alert(textArea)
	if(divVariables){
		if(divVariables.style.display=='none'){
			divVariables.style.display='block';
		}else{
			divVariables.style.display='none';
		}
	}
}



