	
	// JavaScript Document

	//
	//	funcMuseu.js
	//	Fecha de creacion: 16 / 12 / 2010
	//	Descripcion: Contiene funciones genéricas del Museu
	//

	var anteriorActividadSeleccionada = null;
	
	function cercaResultatsAgenda ()
	{
		document.getElementById ('formCercaAgenda').submit ();
	}
	
	function alterWindow ( winRef ) { winRef.focus(); }
	
	function sendFormContacteServEducatiu ( idiomaString )
	{
		var ischecked = document.getElementById('contServEducatiuPolitica').checked;
		
		if ( ischecked )
		{
			var nom			= document.getElementById('contServEducatiuNom').value;
			var centre		= document.getElementById('contServEducatiuCentre').value;
			var mail		= document.getElementById('contServEducatiuEMail').value;
			var texto		= document.getElementById('contServEducatiuText').value;

			if ( validaEmail ( mail ) )
			{
				document.getElementById('formServEducatiu').submit ();
			}
			else
			{
				mostrarAlert ( 'mensajeValidaEmail' );
			}
		}
		else
		{
			mostrarAlert ( 'mensajeContactePolEdad' );
		}
	}
	
	function subsNewsletter ( idiomaString )
	{
		var idioma = null;
		
		switch ( idiomaString )
		{
			case "cat": 	idioma = 1; break;
			case "cas": 	idioma = 2; break;
			case "eng":     idioma = 3; break;
			default:		idioma = 1; break;
		}
		
		var ischecked = document.getElementById('butlletiCheck').checked;
		
		if ( ischecked )
		{
			var nom			= document.getElementById('butlletiName').value;
			var mail		= document.getElementById('butlletiMail').value;
	
			if ( validaEmail ( mail ) )
			{
				alterWindow ( window.open ('http://www.museudelesaigues.com/mailcomercial/subscripcion.php?idioma=' + idioma + '&nom=' + nom + '&mail=' + mail , 'winname' , 'toolbar=no,location=no,status=no,menubar=no, scrollbars=no,resizable=no,width=450,height=150,top=15,left=15' ) ); 
			}
			else
			{
				mostrarAlert ( 'mensajeValidaEmail' );
			}
		}
		else
		{
			mostrarAlert ( 'mensajeSubscriuPolEdad' );
		}
	}
	
	function mostrarJornada ( idJornada )
	{
		if ( $( 'bodyJornada_id' + idJornada ).style.display == 'none' )
		{
			desplegarDiv ( 'bodyJornada_id' + idJornada , 1.0 );
		}
		else
		{
			plegarDiv ( 'bodyJornada_id' + idJornada , 1.0 );
		}
	}
	
	function desplegarBlockElMuseu ( idBlock )
	{
		// Obtenemos la altura del contenido
		var altura = jQuery('#' + idBlock + '_text').height(); 
		
		// Desplegamos el bloque
		$(idBlock).morph('height:' + altura + 'px;');
		
		// Hacemos un switch del resto
		switchDisplayDivs ( idBlock + '_more'  , idBlock + '_hide' );
	}
	
	function plegarBlockElMuseu ( idBlock )
	{
		// Plegamos el bloque
		//$(idBlock).morph ( 'elMuseu_ExpoPermanentBlockExtensBody' );
		$(idBlock).morph('height:150px;');
		
		// Hacemos un switch del resto
		switchDisplayDivs ( idBlock + '_hide'  , idBlock + '_more' );
	}

	function seleccionarCategoriaActividades ( select )
	{
		var idCategoriaSelected = select.value; 
		
		ocultarAllCategoriasActividades ();
		
		document.getElementById ( "actividadesCategID" + idCategoriaSelected ).style.display = "block";
		document.getElementById ( "conteniedoActEducativa" ).style.display = "none";
		document.getElementById ( "conteniedoActEducativa" ).innerHTML = "";
		
		if ( anteriorActividadSeleccionada != null )
		{
			if ( document.getElementById ( anteriorActividadSeleccionada ) )
			{
				document.getElementById ( anteriorActividadSeleccionada ).className = "actEducBlockEscolesInnerRightTableInfoListado_Link";
			}
		}
		
		anteriorActividadSeleccionada = null;
	}

	function mostrarActivitatEducativa ( idActividad )
	{
		if ( document.getElementById( "conteniedoActEducativa" ).style.display != 'block' ) 
		{
			document.getElementById ( "conteniedoActEducativa" ).style.display = "none";
			document.getElementById ( "conteniedoActEducativa" ).innerHTML = arrayStrActividades [ idActividad ];
			
			Effect.Fade( "conteniedoActEducativa" , { 
														duration: 0.6, 
											 		  	from: 0, 
											 		  	to: 1,
													  	afterUpdate: ( function() { $("conteniedoActEducativa").style.display = 'block'; }) 
			});
		}
		else
		{
			Effect.Fade( "conteniedoActEducativa" , { 
														duration: 0.3, 
											 		  	from: 1, 
											 		  	to: 0,
													  	afterUpdate: ( function() { $("conteniedoActEducativa").style.display = 'block'; }),
											 		  	afterFinish: ( function() { 
											 										document.getElementById ( "conteniedoActEducativa" ).innerHTML = arrayStrActividades [ idActividad ];
																					Effect.Fade( "conteniedoActEducativa" , { 
																																duration: 0.6, 
																													 		  	from: 0, 
																													 		  	to: 1,
																															  	afterUpdate: ( function() { $("conteniedoActEducativa").style.display = 'block'; }) 
																															});
																	   			  })
			});
		}
		
		//document.getElementById ( "conteniedoActEducativa" ).innerHTML = arrayStrActividades [ idActividad ];
		//document.getElementById ( "conteniedoActEducativa" ).style.display = "block";
		
		if ( anteriorActividadSeleccionada != null )
		{
			if ( document.getElementById ( anteriorActividadSeleccionada ) )
			{
				document.getElementById ( anteriorActividadSeleccionada ).className = "actEducBlockEscolesInnerRightTableInfoListado_Link";
			}
		}

		if ( document.getElementById ( "linkActEduc" + idActividad ) )
		{
			document.getElementById ( "linkActEduc" + idActividad ).className = "actEducBlockEscolesInnerRightTableInfoListado_Linked";
		}
		
		anteriorActividadSeleccionada = "linkActEduc" + idActividad;
	}

