var currentSection="contenido_home";
var intervaloFade;
var fadeElement1;
var fadeElement2;
var alphaactual=100;
var faseIntervalo=0;
var fading=false;

var enlaceSubseccion=false;
var idSubseccion=-1;

function getURL(req_url) {
   if(window.XMLHttpRequest) {
	  try {
 	   netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
   	  } catch (e) {
   	   
   	  }
      xmlhttp = new XMLHttpRequest();
      xmlhttp.open("GET", req_url+"&ms="+new Date().getTime(), false);
      xmlhttp.send(null);
      }
   else if(window.ActiveXObject) {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      xmlhttp.open("GET", req_url+"&ms="+new Date().getTime(), false);
      xmlhttp.send();
   }
   return xmlhttp.responseText;
  }
  
  function iniciaPagina(){
  	var elemento=document.getElementById("contenido_home");
	elemento.innerHTML=dameContenidos("home",null); 
	generaReproductorAudio(null,null);
  }
  
  function muestraBio(){
	cambiaPagina("bio", null);
  }
  
  function muestraContacto(){
  	cambiaPagina("contacto", null);
  }
  
  function muestraHome(){
	cambiaPagina("home", null);
  }
  
  function muestraDiscografia(){
	cambiaPagina("discos", null);
  }
  
  function muestraVideos(){
	cambiaPagina("videos", null);
	if($('last_foto')) $('last_foto').style.display=(inicioFotos<=0)?'none':'';;
	muestraDetalleVideo(null);
  }
  
  function muestraNoticias(){
	cambiaPagina("noticias", null);
	if($('last_foto')) $('last_foto').style.display=(inicioNoticias<=0)?'none':'';
	if($('next_foto')) $('next_foto').style.display=(inicioNoticias+5>=listaNoticias.length)?'none':'';
  }
  
  function muestraZonaMedios(){
	cambiaPagina("zonamedios", null);
	if($('last_foto')) $('last_foto').style.display=(inicioFotos<=0)?'none':'';;
	if($('next_foto')) $('next_foto').style.display=(inicioFotos+8>=listaFotos.length)?'none':'';

  }
  
  function cambiaPagina(identificador, parametros){
  	
		if (identificador=="videos"){
			Element.update($('contenido_reproductoraudio'),'');
		}else if (currentSection=="contenido_videos"){
			Element.update($('contenido_reproductorvideo'),'');
			generaReproductorAudio(null,null);	
		}
  
  		/*evitamos que se lancen varios intervalos*/
  		if (fading)
  			return;
		var elemento=document.getElementById(currentSection);
  		var padre=elemento.parentNode;
  		var nodo=document.createElement("div");
  		nodo.id="contenido_"+identificador;
		nodo.innerHTML=dameContenidos(identificador, parametros);
  		//var datos = eval('(' + getURL('dameajax.php?class=Bio&id=1') + ')');
  		padre.insertBefore(nodo,elemento);
  		nodo.style.display="none";
  		
		if (identificador=="bio"){
			setTimeout(initScroll,200);
		}
		
  		fadeElement1=elemento;
  		fadeElement2=nodo;
  		currentSection="contenido_"+identificador;
  		/*bloqueamos el cambio de pantalla con esto*/
		new Effect.Opacity(fadeElement1.id,{duration:0.5,from:1.0,to:0.0,afterFinish:function(){paginaSeleccionada()}})
  }
  
   function paginaSeleccionada(){
  		fadeElement1.parentNode.removeChild(fadeElement1);
		
		
		
		if (enlaceSubseccion==true){
			if (currentSection=="contenido_discos")
				mouseOnClickDiscoSeleccion(idSubseccion);
				
			if (currentSection=="contenido_noticias"){
				muestraDetalleNoticiaPorId(idSubseccion,$('contenido_noticias'));
				$('contenido_noticias').style.display='';
				}
				
			if (currentSection=="contenido_videos"){
				muestraDetalleVideoPorId(idSubseccion,$('contenido_videos'));
				$('contenido_videos').style.display='';
				}
				
			enlaceSubseccion=false;
			return;
		}
		fadeElement2.style.filter = 'alpha(opacity=' + 0 + ')';
		fadeElement2.style.opacity = 0;  		
		fadeElement2.style.display="";
		new Effect.Opacity(fadeElement2.id,{duration:0.5,from:0.0,to:1.0});
  }
  
  
  function mostrarDetalleDisco(id){
  	
	var contDiscos = $(currentSection);
	contDiscos.style.display="none";
	
	var nodo=document.createElement('div');
	nodo.id="disco_detalle";
	nodo.innerHTML=dameContenidos("disco_detalle",id);
	nodo.style.visibility='hidden';
	contDiscos.parentNode.insertBefore(nodo,contDiscos);
	contDiscos.parentNode.removeChild(contDiscos);
	currentSection="disco_detalle";
	
	var listaAgradecimientos=document.getElementById('lista_agradecimientos');
	if (listaAgradecimientos){
		var anchuraMax=0;
		for (var i=0; i<listaAgradecimientos.childNodes.length;i++){
			anchuraMax=Math.max(anchuraMax,listaAgradecimientos.childNodes[i].firstChild.offsetWidth);
		}
		for (var i=0; i<listaAgradecimientos.childNodes.length;i++){
			listaAgradecimientos.childNodes[i].firstChild.style.width=(anchuraMax+4)+"px";
		}
	}
	
	/*ajustamos las cajas de las titulos para que queden bien*/
	setTimeout('ajustaListaPistasColumnas()',10);
	
	//nodo.style.visibility='visible';
  }
  
  function ajustaListaPistasColumnas(){
  	var listaPistas=document.getElementById('disco_pistas');
	var lista2=document.createElement('div');
	lista2.id="disco_pistas2";
	if (listaPistas.lastChild.offsetTop+listaPistas.lastChild.offsetHeight>listaPistas.offsetHeight){
		listaPistas.style.width="190px";
		listaPistas.parentNode.insertBefore(lista2,listaPistas.nextSibling);
		var numeroHijos=listaPistas.childNodes.length; 
		for (i=numeroHijos-1;i>=0;i--){
			var auxnodo=listaPistas.childNodes[i];
			if (auxnodo.offsetTop+auxnodo.offsetHeight>listaPistas.offsetHeight){
				var miNodo=auxnodo.cloneNode(true);
				lista2.insertBefore(miNodo,lista2.firstChild);
				listaPistas.removeChild(auxnodo);
			}
		}		
	}
	listaPistas.parentNode.style.visibility='';
  }
  
  
  
  
  
  function content(elemento){
  	return (elemento==null)?"":elemento;
  }
  function dameContenidos(identificador, parametros){
	var salida='';
  	switch (identificador){
  		case "home":
  			var datos = eval('(' + getURL('dameajax.php?class=Home&id=1') + ')');
  			return contenidoHome(datos,parametros);
  			break;
  		case "bio":
  			var datos = eval('(' + getURL('dameajax.php?class=Bio&id=1') + ')');
  			return contenidoBio(datos,parametros);
  			break;
		case "discos":
  			var datos = eval('(' + getURL('dameajax.php?class=Disco&accionAjax=dameDiscosTipo') + ')');
  			return contenidoDiscosHome(datos,parametros);
  			break;	
		case "disco_detalle":
  			var datos = eval('(' + getURL('dameajax.php?class=Disco&id='+parametros+'&accionAjax=dameDetallesDisco') + ')');
  			return contenidoDiscosDetalle(datos,parametros);
  			break;
		case "zonamedios":
  			var datos = eval('(' + getURL('dameajax.php?class=Imagen&accionAjax=dameTodasImagenes') + ')');
  			return contenidoZonaMedios(datos.listaImagenes,parametros);
  			break;
		case "noticias":
  			var datos = eval('(' + getURL('dameajax.php?class=Noticia&accionAjax=dameTodasNoticias') + ')');
  			return contenidoNoticias(datos.listaNoticias,parametros);
  			break;
		case "contacto":
  			var datos = eval('(' + getURL('dameajax.php?class=Contacta&id=1') + ')');
  			return contenidoContacto(datos,parametros);
 			break;
		case "videos":
  			var datos = eval('(' + getURL('dameajax.php?class=Video&accionAjax=dameTodosVideos') + ')');
  			return contenidoVideos(datos.listaVideos,parametros);
  			break;

  	}
  }
  

  
<!--
var clipTop = 0;
var clipWidth = 410;
var clipBottom = 190;
var topper = 130;
var lyrheight = 0;
var time,amount,theTime,theHeight;

function initScroll()
{
	time=0;amount=0;theTime=0;topper = 130;clipTop = 0;clipBottom = 190;
	
	var x = $('bio_bio');
	lyrheight = (Element.getDimensions(x).height+20);
	
	
	if (document.layers)
	{
		x.style.clip.top = clipTop;
		x.style.clip.left = 0;
		x.style.clip.right = clipWidth;
		x.style.clip.bottom = clipBottom;
	}
	else if (document.getElementById || document.all)
	{
		var clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)';
		x.style.clip = clipstring;
	}
	
	x.style.top = topper + 'px';
}
function scrollayer(layername,amt,tim)
{
	
	thelayer = $(layername);
	if (!thelayer) return;
	amount = amt;
	theTime = tim;
	realscroll();
}

function stopScroll()
{
	if (time) clearTimeout(time);
}

function realscroll()
{
	clipTop += amount;
	clipBottom += amount;
	topper -= amount;
	if (clipTop < 0 || clipBottom > lyrheight)
	{
		if (lyrheight < (Element.getDimensions('bio_bio').height+20)){
			lyrheight=(Element.getDimensions('bio_bio').height+20);
			realscroll()
			return;
			}
		clipTop -= amount;
		clipBottom -= amount;
		topper += amount;
		return;
	}
	if (document.getElementById || document.all)
	{
		clipstring = 'rect('+clipTop+'px,'+clipWidth+'px,'+clipBottom+'px,0)'
		thelayer.style.clip = clipstring;
		thelayer.style.top = topper + 'px';
	}
	else if (document.layers)
	{
		thelayer.style.clip.top = clipTop;
		thelayer.style.clip.bottom = clipBottom;
		thelayer.style.top = topper;
	}
	time = setTimeout('realscroll()',theTime);
}

function vis(val)
{
	var f = new getObj('bio_bio');
	f.style.visibility = val;
}

function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
    this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function muestraLetra(id){
  	var datos = eval('(' + getURL('dameajax.php?class=Pista&id='+id) + ')');
	var padre=document.getElementById('disco_detalle');
	creaVentanaScroll(padre,15,415,290,290,'Letra de &quot;'+datos.titulo+'&quot;',((datos.letra)?datos.letra:"Proximamente ..."));
  }
  
 function muestraAgradecimiento(id){
  	var datos = eval('(' + getURL('dameajax.php?class=Agradecimiento&id='+id) + ')');
	var padre=document.getElementById('disco_detalle');
	creaVentanaScroll(padre,15,415,290,290,datos.titulo,((datos.texto)?datos.texto:"..."));
  }
  
  
 function seguirEnlace(ruta){
 	var partes = ruta.split('@');
	
	var seccion="";
	if (partes[1]){
		enlaceSubseccion=true;
		idSubseccion=parseInt(partes[1]);
	}else
		enlaceSubseccion=false;
		
	
	switch (partes[0]){
		case "Noticia":muestraNoticias();break;
		case "Bio":muestraBio();break;
		case "Disco":muestraDiscografia();break;
		case "Video":muestraVideos();break;
		case "Imagen":muestraZonaMedios();break;
		case "Contacta":muestraContacto();break;
	}
 	
 }
  
  