// JavaScript Document

// funcio per redireccionar a apartats dins la pagina
function goto(categoria,subcategoria){
	var parametres;
	
	if(subcategoria!=0) parametres = "cat="+categoria+"&sub="+subcategoria;
	else parametres = "cat="+categoria;
	
	switch(categoria){
		case 1:
			switch(subcategoria){
				case 1:	
					window.location = urlBase+"que_es_inehca/benvinguda/";
					break;
				case 2:
					window.location = urlBase+"que_es_inehca/el_perque_del_nom/";
					break;
				case 3:
					window.location = urlBase+"que_es_inehca/objectius_serveis/";
					break;
				case 4:
					window.location = urlBase+"que_es_inehca/organitzacio/";
					break;
				case 5:
					window.location = urlBase+"que_es_inehca/contacte/";
					break;
				case 6:
					window.location = urlBase+"que_es_inehca/qui_fou_mca/";
					break;
				case 7:
					window.location = urlBase+"que_es_inehca/miquel_coll/";
					break;
				case 8:
					window.location = urlBase+"que_es_inehca/paraules/";
					break;
				case 9:
					window.location = urlBase+"links/";
					break;
				default:
					window.location = urlBase+"que_es_inehca/";
					break;
			}
		break;
		
		case 2:
			switch(subcategoria){
				case 2:	
					window.location = urlBase+"activitats/conferencies/";
					break;
				case 3:
					window.location = urlBase+"activitats/presentacions/";
					break;
				case 4:
					window.location = urlBase+"activitats/taula_rodona/";
					break;
				case 5:
					window.location = urlBase+"activitats/seminaris/";
					break;
				case 6:
					window.location = urlBase+"activitats/cursos/";
					break;
				case 8:
					window.location = urlBase+"activitats/general/";
					break;
				default:
					window.location = urlBase+"activitats/";
					break;
			}
		break;
		
		case 3:
			switch(subcategoria){
				case 1:	
					window.location = urlBase+"publicacions/noticies/";
					break;
				case 2:	
					window.location = urlBase+"publicacions/dialegs/ultim_numero/";
					break;
				default:
					window.location = urlBase+"publicacions/";
					break;
			}
		break;
		
		case 4:
			window.location = urlBase+"blog/";
		break;
		
		case 5:
			window.location = urlBase+"inehcatv/";
		break;
		
		default:
			window.location = urlBase+"index.php?"+parametres;
		break;
	}
	
}

// funcio per redireccionar a subapartats de publicacions
function gotoPublicacions(categoriaPublicacio){
	var parametres;
	
	parametres = "catPub="+categoriaPublicacio;
	
	switch(categoriaPublicacio){
		case 1:
			window.location = urlBase+"publicacions/escola_estiu/";
		break;
		case 2:
			window.location = urlBase+"publicacions/seminari/";
		break;
		case 3:
			window.location = urlBase+"publicacions/documents/";
		break;
		case 4:
			window.location = urlBase+"publicacions/altres/";
		break;

	}
	
}

// funcio per mostrar una publicacio en concret
function mostraPublicacio(idPublicacio){
	window.location = urlBase+"publicacio/"+idPublicacio+"/";
}

// funcio per obrir el google maps a una nova finestra
function veureMapa(){
	var url="http://maps.google.es/maps?daddr=Carrer+de+N%C3%A0pols,+35,+08018,+Barcelona&geocode=&dirflg=&saddr=&f=d&sll=41.392135,2.183769&sspn=0.009015,0.022745&ie=UTF8&ll=41.392055,2.183769&spn=0.009015,0.022745&z=16"
	
	window.open(url,"mapa");
}

// funcio per paginar els posts
function vesA(url){
	//window.location = urlBase+"index.php?"+url;
	window.location = urlBase+url;
}

// funcio per mostrar un post concret
function mostraPost(idPost){
	window.location = urlBase+"entrada/"+idPost+"/";
}

// funcio per mostrar les revistes Diālegs d'un any concret
function carregaDialegs(any){
	window.location = urlBase+"publicacions/dialegs/"+any+"/";
	//window.location = urlBase+"index.php?dial="+any;
}

// funcio per mostrar els articles d'un numero concret de Diālegs
function mostraDialegs(numero){
	if(document.getElementById("dialegs"+numero).style.display == "none"){
		document.getElementById("dialegs"+numero).style.display = "block";
		document.getElementById("fletxa_avall"+numero).style.display = "inline";
		document.getElementById("fletxa_dreta"+numero).style.display = "none";
	}else{ 
		document.getElementById("dialegs"+numero).style.display = "none";
		document.getElementById("fletxa_dreta"+numero).style.display = "inline";
		document.getElementById("fletxa_avall"+numero).style.display = "none";
	}
}

// funcio per mostrar els articles d'un numero concret de Diālegs
function tancaDialegs(numero){
	document.getElementById("dialegs"+numero).style.display = "none";
	document.getElementById("fletxa_dreta"+numero).style.display = "inline";
	document.getElementById("fletxa_avall"+numero).style.display = "none";
}

// funcio que comprova el text a cercar i li passa per post al cercador
function cerca(){
	
	var text = document.getElementById("text_cerca").value;
	var newtext = text.replace(" ", "_");

	if( text.length > 0 ){
		document.cercador.action = urlBase+"cerca/"+newtext+"/";
		//document.cercador.submit(); /* no fem el submit, sino que ho passem per url */
		window.location = urlBase+"cerca/"+newtext+"/";
	}
}

// funcio que redirecciona al rss de noticies
function carrega_rss_noticies(){
	window.location = urlBase+"noticia_feed_rss.php";
}

// funcio que redirecciona al rss de blog
function carrega_rss_blog(){
	window.location = urlBase+"blog_feed_rss.php";
}
