
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* 

_|                  
_|_|_|      _|_|_|  
_|    _|  _|    _|  
_|    _|  _|    _|  
_|_|_|      _|_|_|  
                _|  
            _|_|    

*/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*										 FUNCTIONS GENÈRIQUES 													   */

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$(document).keypress(function (e) {
	//falta script per activar el cercador quan es prem alguna tecla de l'ordinador   
	
	// quan es prèm la tecla INTRO del teclat en el buscador SEARCH	
	$(document).keydown(function (e) {
	
	
		/*alert(e);		 */
		
/*
        if (search_on === false) {
            $('#input_field').blur();
            var keycode = (e.keyCode ? e.keyCode : (e.which ? e.which : e.charCode));
            var next_page = $('a#next');
            var prev_page = $('a#previous');
            if (keycode == 39) {				
                if (next_page.length > 0) {
                    document.location = next_page.attr('href');
                    return false;                }
            } else if (keycode == 37) {
                if (prev_page.length > 0) {
                    document.location = prev_page.attr('href');
                    return false;
                }
            }
        }*/
    });     
    
	});
	
	
function SearchOn() { 	

//		alert("on");

		$('#search-col-1').fadeIn(200);
		$('#search-col-2').fadeIn(200);
		
     /*   if (search_on === false) {*/
            var docTop = $(window).scrollTop();
            if (docTop !== 0) {
                scrollToTop();
            }
            $('#initial').focus();
            //$('#search-col-1').hide();
            //$('#search-col-2').hide();
            $('#fade').fadeIn(100, function () {
                var initvalue = $('#initial').val();
                $('#input_field').focus().val(initvalue);
                $('#initial').val('');
                $('#input_field').keyup(function () {
                    if ($(this).val().length >= 3) {
                       // $('#search-col-1').fadeIn(200);
                       // $('#search-col-2').delay(100).fadeIn(200);
                    } else {
                        //$('#search-col-1').fadeOut(200);
                        //$('#search-col-2').fadeOut(200);
                    }
                });
            });
            search_on = true;
            $('#input_field').blur(function () {
             //   $('#fade').fadeOut(200);
             //   $('#search-col-1').fadeOut(200);
             //   $('#search-col-2').fadeOut(200);
                search_on = false;
            });
       /*}*/
}

function cercadorFadeOut(){
	 $('#fade').fadeOut(200);
     $('#search-col-1').fadeOut(200);
     $('#search-col-2').fadeOut(200);	
}


/* ////////// Function pel pop up dels idiomes //////////////*/

function popupIn(){
	 $('#pop_up').fadeIn(200);
	 $('#popupMessage').fadeIn(200);	 
    
}

function popupOut(){
	 $('#pop_up').fadeOut(200);
 	 $('#popupMessage').fadeOut(200);    
}

/**/
function Desplegar(i) { // FUNCIÓ GENÈRICA DESPLEGABLES MENÚ LATERAL
	
	$("#submenu"+i).slideToggle(500);
	
}

function LoadTop() {	 // FUNCIÓ PER ANAR A DALT TOP

	$("#pageTop").ScrollTo(800);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

								/*	FUNCIÓ VISITA EL MUSEU SCROLLTO	*/

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function ScrollLocalitza() {	
	$("#localitza").ScrollTo(800);
}

function ScrollHoraris() {	
	$("#horaris").ScrollTo(800);
}

function ScrollVisites() {	
	$("#visites").ScrollTo(800);
}

function ScrollTarifes() {	
	$("#tarifes").ScrollTo(800);
}

function ScrollServeis() {	
	$("#serveis").ScrollTo(800);
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* 										FUNCTION PER A CARREGAR LES NEWS/VIDEOS MEDIA EN UN DIV 										*/

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function LoadNews(asp, i) {
	
	bnews[i]=0;
	//$("#pageTop").ScrollTo(800);
		
	$("#desplegable1").css('display', 'none');		
	$("#loader1").fadeIn(500);		
	  $("#desplegable1").load(asp,
		   function() { 		   
		   $("#desplegable1").css('display', 'none');	
		   var alsada1 = $("#desplegable1").height();
		   $("#base1").animate({ height: alsada1 }, 500);
		   $("#loader1").fadeOut(500);
		   setTimeout(function () { $("#desplegable1").fadeIn(500); }, 1500);	
	   }); 	  
}

function LoadNewsCopia(asp, i) {
	
	bnews[i]=0;

	$("#desplegable"+i).css('display', 'none');		
	$("#loader"+i).fadeIn(500);		
	  $("#desplegable"+i).load(asp,
		   function() { 		   
		   $("#desplegable"+i).css('display', 'none');	
		   var alsada1 = $("#desplegable"+i).height();
		   $("#base"+i).animate({ height: alsada1 }, 500);
		   $("#loader"+i).fadeOut(500);
		   setTimeout(function () { $("#desplegable"+i).fadeIn(500); }, 1500);	
	   }); 	  
}

function LoadComunity(asp, i) {
	
	//bnews[i]=0;

	$("#desplegable"+i).css('display', 'none');
	$("#loader"+i).fadeIn(500);
	  $("#desplegable"+i).load(asp,
		   function() {
		   $("#desplegable"+i).css('display', 'none');
		   var alsada1 = $("#desplegable"+i).height();
		   $("#base"+i).animate({ height: alsada1 }, 500);
		   $("#loader"+i).fadeOut(500);
		   setTimeout(function () { $("#desplegable"+i).fadeIn(500); }, 1500);
	   }); 	  
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*									FUNCTION LOAD MESSAGES / LA GENT OPINA											*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function loadMessages(asp) {
	

	$("#contMessages").css('display', 'none');
//	alert(asp)
	$("#loader").fadeIn(500);
	  $("#contMessages").load(asp,
		   function() {
		   $("#contMessages").css('display', 'none');
		  // var alsada1 = $("#contMessages").height();
		 //  $("#base"+i).animate({ height: alsada1 }, 500);
		   $("#loader").fadeOut(500);
		   setTimeout(function () { $("#contMessages").fadeIn(500); }, 1500);
	   }); 	  
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*									 Function Comentaris Agenda In/Out							*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



function ComentIn(i) {
	 	  	
//		  $("#boto"+i).css('display', 'none');		
		  $("#comentaris"+i).slideToggle(400);	 // desplegar el div dels comentaris		  	 
		   
		  var alsada1 = $("#desplegable"+i).height();
		  // $("#base"+i).animate({ height: alsada1+250 }, 400); //// desplegar el div base tant com el comentari		  		  
		 
		 
			  ////////////// Funció interruptor per saber si els comentaris estan desplegats o plegats ///////////
			  //alert("obert=1"); //falta fer eval de la variable n+i
			  
			  if(bnews[i]==0){					
	          //alert("ON");
			  //$("#boto"+i).css({'border-bottom': '1px solid #f2f2f2'}); 			   			  
			  $("#base"+i).animate({ height: alsada1+224 }, 400);
			  
			  bnews[i]=1;	 		  
			  //alert(bnews[i]);	 
	
			  } else {
	          //alert("OFF");
			  //alert(eval('bnews'+idboto));
			 // $("#boto"+i).css({'border-bottom': '1px solid #FFFFFF'});
			  $("#base"+i).animate({ height: alsada1-220 }, 400);
			  bnews[i]=0;
		
		  }
		  
		   
}

 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*									 Function per Ensenyar/Amagar el missatge de la home 							*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function MissIn() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
		   setTimeout(function () { $("#missatgeCont").toggle("slow"); }, 4000);
		   setTimeout(function () { $("#missatge").fadeIn(500); }, 4500);
		   
}

function MissOut() {
	
			jQuery.easing.def = 'easeOutQuad';
	
		   	setTimeout(function () { $("#missatge").fadeOut(500); }, 150);
			setTimeout(function () { $("#missatgeCont").toggle("slow"); }, 500);
}


function MissIn2() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
		   setTimeout(function () { $("#missatgeCont2").toggle("slow"); }, 4000);
		   setTimeout(function () { $("#missatge").fadeIn(500); }, 4500);
		   
}

function MissOut2() {
	
			jQuery.easing.def = 'easeOutQuad';
	
		   	setTimeout(function () { $("#missatge").fadeOut(500); }, 150);
			setTimeout(function () { $("#missatgeCont2").toggle("slow"); }, 500);
}

	
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*									 Function per Amagar els Comentaris del Museu Pastilla Vermella          			*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function ComentariOff1() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
		   setTimeout(function () { $("#mesInfo").animate({width: 155}, "slow"); }, 150);
		   setTimeout(function () { $("#formComent2").fadeOut(500); }, 150);	
		   setTimeout(function () { $("#formComent1").fadeIn(500); }, 500);	
		  // setTimeout(function(){ $("#contMesInfo").animate({ paddingRight: 0 },"slow"); },500); 
}

function ComentariOff() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
		   setTimeout(function () { $("#mesInfo").fadeOut(500); }, 150);		    
		   setTimeout(function () { $("#contMesInfo").animate({width: 0}, "slow"); }, 500);
		   setTimeout(function () { $("#contMesInfo").css("display", "none"); }, 1100);
		  // setTimeout(function(){ $("#contMesInfo").animate({ paddingRight: 0 },"slow"); },500); 
}

function ComentariOn() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
		   setTimeout(function () { $("#formComent1").fadeOut(500); }, 150);		    
		   setTimeout(function () { $("#mesInfo").animate({width: 680}, "slow"); }, 500);
		   setTimeout(function () { $("#formComent2").fadeIn(500); }, 600);		    
}



/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*									 Function per Amagar el Moduls de l'apartat del Museu							*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function tancarModul1() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
		   setTimeout(function () { $("#contText1").slideToggle(500); }, 100);		   
		   
}


function tancarModul2() {
			
		   jQuery.easing.def = 'easeOutQuad';
			
			 setTimeout(function () { $("#contText2").slideToggle(500); }, 100);
			 
		   /*setTimeout(function () { $("#text2").fadeOut(500); }, 150);			   
		   setTimeout(function () { $("#textDes2").fadeOut(500); }, 150);
		   setTimeout(function () { $("#imatges2").fadeOut(500); }, 150);
		   setTimeout(function () { $("#tancarOn2").fadeOut(500); }, 200);
		   
		   setTimeout(function () { $("#contText2").toggle("slow"); }, 600);		   
		   setTimeout(function () { $("#tancarOff2").fadeIn(500); }, 610);
		   	
		   setTimeout(function () { $("#contText2").css("display", "none"); }, 1200);
		   		   
		   setTimeout(function () { $("#text2Off").fadeIn(500); }, 1800);
		   setTimeout(function () {  $("#modul2").css({'border-top': '1px dotted #7f7f7f'}); }, 2000);		 */ 	
		   
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*									 Function mosaicIn/listIn														*/

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function mosaicIn() {
	
	 $("#llistat").fadeOut(400); 
	 $("#mosaic").fadeOut(400); 
	 setTimeout(function () { $("#loading").css("display", "block"); }, 500);
	 
	 
	 setTimeout(function () { $("#loading").css("display", "none"); }, 1000); 
	 setTimeout(function () { $("#mosaic").fadeIn(400); }, 1200); 
	  setTimeout(function () { $("#mosaicpag").css("display", "block"); }, 1000); 	  
 	  setTimeout(function () { $("#llistatpag").css("display", "none"); }, 1000); 	  	 		
		   
}

function listIn() {
	
	 $("#mosaic").fadeOut(400); 
	 $("#llistat").fadeOut(400);	 
 	 setTimeout(function () { $("#loading").css("display", "block"); }, 500);
	 
	 setTimeout(function () { $("#loading").css("display", "none"); }, 1000); 
	 setTimeout(function () { $("#llistat").fadeIn(400); }, 1200); 	 
	 
	 setTimeout(function () { $("#mosaicpag").css("display", "none"); }, 1000); 	  
 	 setTimeout(function () { $("#llistatpag").css("display", "block"); }, 1000); 	   	 		
		   
}


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////	

/*													document ready 														*/

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////			


$(document).ready(function(){
	
//	$('.uiGrid').hide()
//	$(".uiGrid").css("display", "none");

	/////////////////////////////////////////////////////////////
	
	$('#input_field').focus(function() {		
		$('#input_field').css('color', '#999999'); 
	});
	 
	$('#input_field').blur(function() {		
		$('#input_field').css('color', '#999999'); 
	});

	/////////////////////////////////////////////////////////////
//	bgkeys ESC per sortir del cercador
	document.onkeydown = function(e){
    if (e == null) { // ie
    	keycode = event.keyCode;
    } else { // mozilla
	    keycode = e.which;
    }
    if(keycode == 27){ // escape, close box, esc
    //what you nedd
	 $('#fade').fadeOut(200);
     $('#search-col-1').fadeOut(200);
     $('#search-col-2').fadeOut(200);
    }
    };
	
	//////////////////////////////////////////////////////////
	
	//funció per fer créixer/disminiur la tipografia de la web
	$('#aumentar').fontSizer({
		action: "up",
		elements: "#content",
		max: 36
	});			
	$('#disminuir').fontSizer({
		action: 'down',
		elements: "#content"
	});
	
	// Tupis de transicio dels moviments Jquery		
	jQuery.easing.def = 'easeOutBounce';
	
	MissIn(); // missatge de la home en la pastilla en vermell
	MissIn2(); // missatge de pantalla de Premsa
	setTimeout(function () { $("#contingutDreta").animate({ top: "0px" }, 800 ); }, 1000); //animació de la home del contingut
	//setTimeout(function () { $("#messageSup").animate({ top: "15px" }, 800 ); }, 1000);
	

		
});	


