//<![CDATA[
//para las opacidades de fondos
var trans = 0;
var suma = 10;
var los_fondos= new Array();
var fondo_actual=0;
var los_fondos=["bharatanatyam_1","bharatanatyam_2","bhakti_1","bhakti_2","navarasa_1","navarasa_2","flordeseo_1","flordeseo_2","lilafoto_1","lilafoto_2","bhumidevi_1","bhumidevi_2"];
aleatorio(los_fondos);
var div_fondo_actual=1;
var profundidad=2;


//sirve para darle un objeto y a qué opacidad quieres cambiarle y fuera
function cambiarOpacidad(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  // IE/Win
  if(document.all){
  obj.style.filter = "alpha(opacity:"+opacity+")";    
  }
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function inicio(pagina){
	//para los fondos de imágenes
	if(pagina=="inicio"){
	  carga_fichero();	  
	}
	//para los eventos
	if (pagina=="espectaculos"){
	  cargar_eventos();
	}	
}


//mostrar las imágenes de espectáculos del inicio
function carga_fichero(){
	
	var ruta="espectaculos/"+los_fondos[fondo_actual]+".jpg";
        
        var foto_cambio=document.getElementById("foto_fondo_"+div_fondo_actual);        
        
        foto_cambio.src=ruta;     

	
	fondo_actual++;
	if(fondo_actual>los_fondos.length-1){
		fondo_actual=0;
	}
        profundidad++;
        trans=0;
}
function aparecer(){
	var fondo=document.getElementById("pagina_fondo_"+div_fondo_actual);
	trans += parseInt((110-trans)/10);
	if (trans<90){
		cambiarOpacidad(fondo, trans);
		var p=setTimeout("aparecer()",50);
	}else{
		trans=100;
		cambiarOpacidad(fondo, trans);
                cambio_fondo_actual();
                var fondo_nuevo=document.getElementById("pagina_fondo_"+div_fondo_actual);
                cambiarOpacidad(fondo_nuevo, 0);
                fondo_nuevo.style.zIndex=String(profundidad);
		var p=setTimeout("carga_fichero()",3000);
	}
	
}
function desaparecer(){
	
	var fondos=document.getElementById("div_"+fondo_ultimo);
	
	trans -= 5;
	
	if (trans>5){
		cambiarOpacidad(fondos, trans);
		var p=setTimeout("desaparecer()",100);
	}else{
		trans = 0;
		cambiarOpacidad(fondos, trans);
		var p=setTimeout("carga_fichero()",100);
	}
}

function cambio_fondo_actual(){
    if(div_fondo_actual==1){
        div_fondo_actual=2;
    }else{
        div_fondo_actual=1;
    }
}

////////////////////////////////////////para fotos eventos////////////////////////////////
function aparecer_evento(cual){
  var que_grupo=cual.substring(0,cual.length-7);
  var que_foto=cual.substring(cual.length-6,cual.length-5);
  alert(que_grupo+","+que_foto);
  //cargar_eventos(que_grupo,que_foto);
}

//aleatoriza un array dado
function cargar_eventos(cual,num){
  
  var que_espectaculo=document.getElementById("espectaculo_actual").value;
  var fotos1_actual=document.getElementById("num_actual_evento_fotos1").value;
  var fotos2_actual=document.getElementById("num_actual_evento_fotos2").value;
  var cuantas_fotos1=document.getElementById("num_evento_fotos1").value;
  var cuantas_fotos2=document.getElementById("num_evento_fotos2").value;
  
  
  var foto1=document.getElementById("evento_fotos1_2_foto");
  foto1.src="espectaculos/fichas/"+que_espectaculo+"A_"+fotos1_actual+".jpg";
  var foto2=document.getElementById("evento_fotos2_2_foto");
  foto2.src="espectaculos/fichas/"+que_espectaculo+"B_"+fotos2_actual+".jpg";
  
}

function aleatorio(array){ 
    var i=array.length;
    while(i--){
        var j=Math.floor( Math.random() * (i+1) );
        var tmp=array[i];
        array[i]=array[j];
        array[j]=tmp;
    }
}


///////////////////////////////
//]]>
