// ACTIVA / DESACTIVA LAYERS - Ifr.Izq
function showHide(nombre){
	var visibilidad = document.getElementById(nombre).style.display;
	if(visibilidad == 'block' || !visibilidad)
		visibilidad = 'none';
	else 
		visibilidad = 'block';
	document.getElementById(nombre).style.display = visibilidad;
}

// ROLLOVER HEADER
<!--
	if(document.images) {
		ftover = new Array(31);
		ftout = new Array(31);
		ftoverCineAire = new Array(31);
		ftoutCineAire = new Array(31);
		for(var n=1;n<=31;n++) {
			ftover[n]=new Image;
			ftout[n]=new Image;
			ftoverCineAire[n]=new Image;
			ftoutCineAire[n]=new Image;
			
			if(n<10){
				ftover[n].src="./multi/img/bt_mult_0"+n+"_off.gif";
				ftout[n].src="./multi/img/bt_mult_0"+n+"_on.gif";
				ftoverCineAire[n].src="./multi/img/bt_mult_0"+n+"_over.gif";
				ftoutCineAire[n].src="./multi/img/bt_mult_0"+n+"_off.gif";
			}
		else{			
			ftover[n].src="./multi/img/bt_mult_"+n+"_off.gif";
			ftout[n].src="./multi/img/bt_mult_"+n+"_on.gif";
			ftoverCineAire[n].src="./multi/img/bt_mult_"+n+"_over.gif";
			ftoutCineAire[n].src="./multi/img/bt_mult_"+n+"_off.gif";
			}
		}
	}
	function tabOn(i) {
		if(document.images) document.images["ft"+i].src=ftover[i].src;
	}
	function tabOff(i) {
		if(document.images) document.images["ft"+i].src=ftout[i].src;
	}
	function tabOnCineAire(i) {
		if(document.images) document.images["ft"+i].src=ftoverCineAire[i].src;
	}
	function tabOffCineAire(i) {
		if(document.images) document.images["ft"+i].src=ftoutCineAire[i].src;
	}
//-->


// ABRE	POPUP
	function popUp(URL, width, Height, left, top, id) {
		window.open(URL, id, 'toolbar=0, scrollbars=1, location=0, status=1, menubar=0, resizable=0, width=' + width + ', height=' + Height + ', left = ' + left + ', top = ' + top);
	}

//PASA UNA CIERTA CANTIDAD DE DIAS EN LOS FRAMES DE LA GRILLA
	function pasaDias(cantidad) {
		frames['hora_grilla'].document.forms['dia'].pasaCantidadDias.value = cantidad; 
		frames['grilla'].document.forms['dia'].pasaCantidadDias.value = cantidad; 
		frames['hora_grilla'].document.forms['dia'].submit(); 
		frames['grilla'].document.forms['dia'].submit(); 
		return true;	
	}

//PASA UNA CIERT CANTIDAD DE MESES EN LOS FRAMES DE LA AGENDA
	function pasaAgenda(cantidad) {
		frames['agenda'].document.forms['mes'].pasaCantidad.value = cantidad;
		frames['agenda'].document.forms['mes'].submit();
		return true;
	}

// SCRIPT PARA QUE LA PAGINA SE RECARGUE CADA X TIEMPO
//enter refresh time in \"minutes:seconds\" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
	function configRefresh(limit) {
		if (document.images) {
			var parselimit=limit.split(":");
			parselimit=parselimit[0]*60+parselimit[1]*1;
			return parselimit;
		}
	}

	function beginrefresh(parselimit) {
		if(!document.images)
			return;
		if(parselimit==1) {
			//window.location.reload();
			frames['fcine'].document.location.reload();
			frames['deportes'].document.location.reload();
			if(frames['faire'] !== null)
				frames['faire'].document.location.reload();
/*			if(frames['central'] !== null) {
				frames['central'].document.location.reload();
			}*/	  
/*			if(frames['grilla'] !== null) {
				frames['grilla'].document.location.reload();
			}*/
		  beginrefresh(configRefresh('30:00'));
		}
		else { 
			parselimit -= 1;
			/*curmin=Math.floor(parselimit/60);
			cursec=parselimit%60;
			if(curmin!=0)
				curtime=curmin+" minutos y " + cursec + " segundos para que la pagina se recargue";
			else
				curtime=cursec + " segundos para que la pagina se recargue";
			window.status=curtime;*/
			setTimeout("beginrefresh(" + parselimit + ")",1000);
		}
	}

//PARA LA SELECCION DE GENEROS EN LA agenda'
	function alternaSeleccionGrilla(seleccionado) {
		document.getElementById('todosGrilla').className='generog';
		document.getElementById('cineseriesGrilla').className='generog';
		document.getElementById('deportesGrilla').className='generog';
		document.getElementById('documentalesGrilla').className='generog';
		document.getElementById('musicaGrilla').className='generog';
		document.getElementById('infantilesGrilla').className='generog';
		document.getElementById('noticiasGrilla').className='generog';
		document.getElementById('internacionalesGrilla').className='generog';
		document.getElementById('aireGrilla').className='generog';
		document.getElementById('variedadesGrilla').className='generog';
		document.getElementById('adultosGrilla').className='generog';
		document.getElementById('premiumGrilla').className='generog';
		seleccionado.className='tcanalesg';
	}

//PARA SELECIONAR UN DIA Y HORA EN LA GRILLA SABANA
	function cambiaHoraDiaGrilla(pagina) {
		fechaVer = document.forms['selectorGrilla'].seleccionaDia.options[document.forms['selectorGrilla'].seleccionaDia.selectedIndex].value;
		horaVer = document.forms['selectorGrilla'].seleccionaHora.options[document.forms['selectorGrilla'].seleccionaHora.selectedIndex].value;
		tipoGrillaSel = document.forms['selectorGrilla'].seleccionaGenero.options[document.forms['selectorGrilla'].seleccionaGenero.selectedIndex].value;
		//tipoGrillaSel = frames['grilla'].document.forms['dia'].tipoGrilla.value;
		frames['hora_grilla'].location.href = pagina + '?template=fhora_grilla.tpl&verHora=' + horaVer + '&fecha=' + fechaVer + '&tipoGrilla=' + tipoGrillaSel;
		frames['grilla'].location.href = pagina + '?template=fgrilla.tpl&verHora=' + horaVer + '&fecha=' + fechaVer + '&tipoGrilla=' + tipoGrillaSel;
		cambiaTexto(fechaVer);
		return true;
	}
	
//PARA CAMBIAR LA FECHA QUE APARECE
	function cambiaTexto(newTexto)
	{
	var objetoSPAN = document.getElementById("fechaElegida");
	var nummes = newTexto.substring(4,6);
	switch(nummes)
	{
		case "01": var mes = "Enero";break;
	  case "02": var mes = "Febrero";break;
	  case "03": var mes = "Marzo";break;
	  case "04": var mes = "Abril";break;
	  case "05": var mes = "Mayo";break;
	  case "06": var mes = "Junio";break;
	  case "07": var mes = "Julio";break;
	  case "08": var mes = "Agosto";break;
	  case "09": var mes = "Septiembre";break;
	  case "10": var mes = "Octubre";break;
	  case "11": var mes = "Noviembre";break;
	  case "12": var mes = "Diciembre";break;
	}	  
	
	objetoSPAN.innerHTML = newTexto.substring(6) +" de "+ mes +" de " + newTexto.substring(0,4);
	return true;
	}
	


//PARA HACER UN CAMBIO ENTRE OPCIONES DE UN SELECT
function populate(store, nombreForm, inputEste, este)
{
	var boxEste;
	var list = new Array();
	var elem1 = inputEste + '1';
	var elem2 = inputEste + '2';
	var box1 = document.forms[nombreForm].elements[elem1];
	var box2 = document.forms[nombreForm].elements[elem2];
	boxEste = document.forms[nombreForm].elements[este];
	if (!box1.checked && !box2.checked) {
		boxEste.checked = true;
	}
	else {
		if (box1.checked && box2.checked) {
			list = store['X'];
		}
		else {
			if(box1.checked)
				list = store[box1.value];
			else {
				if(box2.checked)
					list = store[box2.value];
			}
		}
	
		var salida = document.forms[nombreForm].genero;
		salida.options.length = 0;
		for(i=0;i<list.length;i+=2)	{
			salida.options[i/2] = new Option(list[i],list[i+1]);
		}
	}
}

