//######################################################################################

var App = function()
{
  //montem les seccions
  if(document.getElementById("competicion_noticias"))
  {
    //fem precache de les imatges
    //$("#competicion_noticias").load("/seccions/competicion_noticias.asp");
  }

  //-----------------------------------------------------------------------------
//   Noticies
  //el detall de les noticies
  if (document.getElementById("noticies_mostra"))
  {
    $("#noticies_mostra").load("seccions/noticies_mostra.asp",{"i":"-1"},
	  function(){
	    $('#pane').jScrollPane({scrollbarWidth:17});
	    //$('a#imatge_noticia').lightBox();
	    //$('a#imatge_noticia').colorbox({transition:'elastic', speed:500});
	    $('a#imatge_noticia').prettyPhoto();
	  }
      );
  }

  //llistes de noticies
  if (document.getElementById("noticies_llista"))
  {
    //alert("hi és");
    $("#noticies_llista").load("seccions/noticies_llista.asp");
  }


// 
// -----------------------------------------------------------------------
// GALERIES
// -----------------------------------------------------------------------
// 
  //el detall de les galeries
  if (document.getElementById("galeries_mostra"))
  {
    //$("#galeries_mostra").load("seccions/galeries_mostra.asp",{"i":"-1"},
	$("#galeries_mostra").load("seccions/galeries_mostra.asp",{"i":galeria_request},
	  function(){
	    $('#pane').jScrollPane({scrollbarWidth:17});
	    //$('a.lightbox').lightBox();
	    
	    //Gràcies als c*****s de Redmon estic obligat a fer servir un altre plugin de JQuery
	    //$('a.lightbox').colorbox({transition:'elastic', speed:500});
	    
	    //2a prova
	    $("a[rel^='pp']").prettyPhoto({animationSpeed: 'fast'});
	    
	    
	  }
      );
  }

  //llistes de galeries
  if (document.getElementById("galeries_llista"))
  {
    //alert("hi és");
    $("#galeries_llista").load("seccions/galeries_llista.asp");
  }



  //wallpapers
  if (document.getElementById("wallpapers_mostra"))
  {
    $("#wallpapers_mostra").load("seccions/wallpapers_mostra.asp",{"i":"-1"},
	  function(){
	    $('#pane').jScrollPane({scrollbarWidth:17});
	    //$('a.lightbox').lightBox();
	    //Gràcies als c*****s de Redmon estic obligat a fer servir un altre plugin de JQuery
	    //$('a.lightbox').colorbox({transition:'elastic', speed:500});
	    
	    //2a prova
	    $("a[rel^='pp']").prettyPhoto();
	  }
      );
  }

  //llistes de galeries
  if (document.getElementById("wallpapers_llista"))
  {
    //alert("hi és");
    $("#wallpapers_llista").load("seccions/wallpapers_llista.asp");
  }


  //******************************************************************
  //Classificació
  if (document.getElementById("classificacio_mostra"))
  {
    //alert("hi és");
    $("#classificacio_mostra").load("seccions/classificacio_seccio.asp",function(){
	    $('#pane').jScrollPane({scrollbarWidth:17});	    
	  });
  }

   //-----------------------------------------------------------------------------
  //   Diari
  //el detall de les diari
  if (document.getElementById("diari_mostra"))
  {
    $("#diari_mostra").load("seccions/diari_mostra.asp",{"i":"-1"},
	  function(){
	    $('#pane').jScrollPane({scrollbarWidth:17});
	    $('a#imatge_diari').prettyPhoto();
	  }
      );
  }

  //llistes de diari
  if (document.getElementById("diari_llista"))
  {
    //alert("hi és");
    $("#diari_llista").load("seccions/diari_llista.asp");
  }


//    -------------------------------------------------------------------------
//       Activitats
//el detall de les galeries
  if (document.getElementById("activitats_mostra"))
  {
    $("#activitats_mostra").load("seccions/activitats_mostra.asp",{"i":"-1"},
	  function(){
	    $('#pane').jScrollPane({scrollbarWidth:17});
	    //$('a.lightbox').lightBox();
	    //Gràcies als c*****s de Redmon estic obligat a fer servir un altre plugin de JQuery
	    //$('a.lightbox').colorbox({transition:'elastic', speed:500});
	    
	    //2a prova
	    $("a[rel^='pp']").prettyPhoto();
	  }
      );
  }

  //llistes de galeries
  if (document.getElementById("activitats_llista"))
  {
    //alert("hi és");
    $("#activitats_llista").load("seccions/activitats_llista.asp");
  }

     //-----------------------------------------------------------------------------
//   Calendari
  //el detall dels circuits
  if (document.getElementById("calendari_mostra"))
  {
    $("#calendari_mostra").load("seccions/calendari_mostra.asp",{"i":"-1"} );
  }

  //llistes de circuits
  if (document.getElementById("calendari_llista"))
  {
    //alert("hi és");
    $("#calendari_llista").load("seccions/calendari_llista.asp");
  }


// ----------------------------------------------------------------------
  //carreguem els efectes si fa falta
  $('#pane').jScrollPane({scrollbarWidth:17});

}

//precache de les imatges
    var imatges = new Array();
    imatges[0] = new Image();
    imatges[0].src = "/images/select-01.png";
    imatges[1] = new Image();
    imatges[1].src = "/images/select-02.png";
    imatges[2] = new Image();
    imatges[2].src = "/images/loader.gif";
    imatges[3] = new Image();
    imatges[3].src = "images/pag-mes-02.gif";
    imatges[4] = new Image();
    imatges[4].src = "images/pag-mes-01.gif";
    imatges[5] = new Image();
    imatges[5].src = "images/pag-menys-02.gif";
    imatges[6] = new Image();
    imatges[6].src = "images/pag-menys-01.gif";

//precache imatges galeries
    imatges[7] = new Image();
    imatges[7].src = "/js/jq/pp/images/prettyPhoto/light_rounded/btnNext.png";
    imatges[8] = new Image();
    imatges[8].src = "/js/jq/pp/images/prettyPhoto/light_rounded/btnPrevious.png";
    imatges[9] = new Image();
    imatges[9].src = "/js/jq/pp/images/prettyPhoto/light_rounded/loader.gif";
    imatges[10] = new Image();
    imatges[10].src = "/js/jq/pp/images/prettyPhoto/light_rounded/sprite.png";
    /*imatges[11] = new Image();
    imatges[11].src = "/js/jq/cb/images/borderTopLeft.png";
    imatges[12] = new Image();
    imatges[12].src = "/js/jq/cb/images/borderTopRight.png";
    imatges[13] = new Image();
    imatges[13].src = "/js/jq/cb/images/borderMiddleLeft.png";
    imatges[14] = new Image();
    imatges[14].src = "/js/jq/cb/images/borderMiddleRight.png";
    imatges[15] = new Image();
    imatges[15].src = "/js/jq/cb/images/controls.png";
    imatges[16] = new Image();
    imatges[16].src = "/js/jq/cb/images/loading.gif";
    imatges[17] = new Image();
    imatges[17].src = "/js/jq/cb/images/loading_background.png";
    imatges[18] = new Image();
    imatges[18].src = "/js/jq/cb/images/overlay.png";
*/
	//inicialitzem l'aplicació

	  $(document).ready(
	      function()
	      {
		        App();
			//loader.kill();
	      }
	  );

function prova()
{
  alert('prova');
}
