var objeto;
objeto = $(document);
objeto.ready(iniciar);

function iniciar()
{
   var evento;
   formato($("#cuerpo"));
   $("a").click(galeria);
   $("#firma").click(colocaFirma);
   $("#direccion").click(colocaFirma);
   $(window).bind('resize', function() {
      if($("#cuerpo").css("display") != "none") {
         formato($("#cuerpo"));
      } else if($("#galeria").css("display") != "none") {
         formato($("#galeria"));
         formato($("#presentacion"));
      } else if($("#contacto").css("display") != "none") {
         formato($("#contacto"));
      }
   });
}
function formato(capa)
{
   var cuerpo;
   cuerpo = $(capa);
   cuerpo.css({"height": document.getElementById("bdyPrincipal").parentNode.clientHeight - 118});
}
function galeria()
{
   var capas;
   manejaCapas($(this).attr("id"));
   if  ($(this).attr("id") != "contacto"){
      cargarweb($(this).attr("id"));
   }
}
function manejaCapas(opcion){
   if (opcion != "contacto"){ //entra si pulsamos el menu excepto CONTACTO
      if($("#galeria").css("display") == "none") { // entra si no esta visible la galeria
         if($("#cuerpo").css("display") != "none") {// quita la pag ppal
            $("#cuerpo").css("display", "none");
         } else {//quita el contacto
            $("#contacto").css("display", "none");
         }
         $("#galeria").css("display", "block");
         $("#presentacion").css("display", "block");
         formato($("#galeria"));
         formato($("#presentacion"));
      }
   }else {
      if($("#contacto").css("display") == "none") {

         if($("#cuerpo").css("display") != "none") {// quita la pag ppal
            $("#cuerpo").css("display", "none");
         } else {//quita el contacto
            $("#galeria").css("display", "none");
            $("#presentacion").css("display", "none");
         }
         $("#contacto").css("display", "block");
         formato($("#contacto"));
         colocaDireccion();
      }
   }
}
function colocaDireccion(){
   $("#firma").css({"top": document.getElementById("bdyPrincipal").parentNode.clientHeight - 118 - $("#firma").height(), "left": document.getElementById("bdyPrincipal").parentNode.clientWidth - $("#firma").width()});
}
function colocaFirma(){
   if ($("#direccion").css("display") == "none"){
      $("#contenedor").fadeTo("fast", 0.1);
      $("#direccion").css({"left":event.clientX - $("#direccion").width(), "top":event.clientY - $("#direccion").height()});
   } else {
      $("#contenedor").fadeTo("fast", 1);
   }

   $("#direccion").toggle(1000);
}
function cargarweb(opcionMenu)
{
   var arrPrincipal, strImages, opcionMenu;
   var i;
   arrPrincipal = new Array;


   switch (opcionMenu)
   {
      case "entrevistas":
         var strEntrevistas = "1.jpg;4.jpg;13.jpg;63.jpg;82.jpg;101.jpg;111.jpg;A.jpg;ch.jpg;DSC_0118.jpg;DSC_0604_001.jpg;DSC_0661.jpg;DSC_0803.jpg;DSC_0849.jpg;DSC_1031.jpg;DSC_1148.jpg;DSC_1330.jpg;DSC_1669.jpg;DSC_3784.jpg;DSC_3998.jpg;DSC_4004.jpg;DSC_8050.jpg;DSC_8777.jpg;DSC_8821.jpg;i.jpg;mariavillalon1.jpg;n.jpg;orozco.jpg";
         arrPrincipal = strEntrevistas.split(";");
         break;
      case "actores":
         var strActores = "_DSC7516.jpg;_DSC7534.jpg;_DSC7554.jpg;_DSC8061.jpg;13.jpg;170.jpg;220.jpg;244.jpg;279.jpg;ba.jpg;cb.jpg;db.jpg;dc.jpg;DSC_0594.jpg;DSC_0919.jpg;DSC_0993.jpg;DSC_1041.jpg;DSC_1118.jpg;DSC_4594.jpg;DSC_7736.jpg;DSC_8697.jpg;DSC_8742.jpg;e.jpg;j.jpg;l.jpg";
         arrPrincipal = strActores.split(";");
         break;
      case "carteles":
         var strCarteles = "CARTEL_F-30_2009.jpg;Cartel_MARILYN_1.jpg;CRTL.jpg;la_celestina_A5.jpg;LA_IMPORTANCIA_DE_LLAMARSE_ERNESTO_A4.jpg;mi_primera_vez.jpg";
         arrPrincipal = strCarteles.split(";");
         break;
      case "ninyos":
         var strNinyos = "carnaval.jpg;cocinillas.jpg;colorin.jpg;conciencia.jpg;conducta.jpg;integracion.jpg;investigando.jpg;solidaridad.jpg;speak.jpg";
         arrPrincipal = strNinyos.split(";");
         break;
      case "teatro":
         var strTeatro = "celestina1.jpg;celestina3.jpg;DSC_6407.jpg;DSC_8863A.jpg;DSC_8962.jpg;Hansel-1teatro.jpg;mi_primera_vez1.jpg;mi_primera_vez2.jpg;mi_primera_vez3.jpg;mi_primera_vez4.jpg;SELVA_7.jpg;teatro.jpg;triciclo.jpg";
         arrPrincipal = strTeatro.split(";");
         break;
      case "prensa":
         var strPrensa = "carmen_guaita.jpg;consejera_educacion.jpg;DEFENSOR_MENOR.jpg;DSC_0623.jpg;DSC_1273A.jpg;DSC_1965.jpg;DSC_2599.jpg;DSC_3559.jpg;DSC_4179.jpg;DSC_4392a.jpg;DSC_6904.jpg;federico_mayor.jpg;h.jpg;HECTOR_BARBERA.jpg;MINISTRO_EDUCACION_ARGENTINA2.jpg;MINISTRO_EDUCACION_COSTA_RICA2.jpg;MINISTRO_EDUCACION_INGLES2.jpg;PSICOLOGO_JOSE_CABRERA.jpg;simon_pedro_barcelo.jpg;solbes.jpg";
         arrPrincipal = strPrensa.split(";");
         break;
      case "books":
         var strBooks = "_DSC9507.jpg;_DSC9530.jpg;22.jpg;bf.jpg;dd.jpg;df.jpg;DSC_0014.jpg;DSC_0049.jpg;DSC_0055.jpg;DSC_1345.jpg;DSC_1745.jpg;ELENA_LAMONTHE.jpg;DSC_1784.jpg;DSC_3716.jpg;DSC_4620.jpg;DSC_8087.jpg;DSC_9710bn.jpg;DSC_9767.jpg;ea.jpg;eb.jpg;entre_paredes.jpg;f.jpg";
         arrPrincipal = strBooks.split(";");
   }

   i=0;
   strImages="";

   for (i; i<=arrPrincipal.length-1; i++)
   {
      strImages = strImages + "<img src=\"thumbs/" + opcionMenu + "/" + arrPrincipal[i] + "\" onclick=\"document.getElementById('presentacion').style.backgroundImage='url(images/" + opcionMenu + "/" + arrPrincipal[i] + ")'\" /><br />";
     if (i==0) {
         document.getElementById('presentacion').style.backgroundImage="url(images/" + opcionMenu + "/" + arrPrincipal[i] + ")";
     }
   }
   document.getElementById('galeria').innerHTML= strImages;
}

