var urlFinal = "http://www.termcat.cat/";
	
	
function cercaAvancada()
{ 
		var a = document.getElementById('advancedButton');
    var e = document.createEvent('MouseEvents');
    e.initEvent( 'click', true, true );
    a.dispatchEvent(e);
}

function replegaAbreviatures()
{
	var a = document.getElementById('minus');
	var e = document.createEvent('MouseEvents');
	e.initEvent('click', true, true );
	a.dispatchEvent(e);
}


function cercaAvancadaIE()
{ 
		var a = document.getElementById('advancedButton');
    var e = document.createEvent('MouseEvents');
    e.initEvent( 'click', true, true );
    a.dispatchEvent(e);
}

var oldContenidor = 0;

function showContenidorNH3()
{
	var valor = document.getElementById('dicc_lin').value;
	var contenidorNH3 = document.getElementById('contenidorNH3_'+valor);
	 
	if(valor!=0)
		contenidorNH3.className="";
	else
		contenidorNH3.className="dNone";
	
	if(oldContenidor!=0)
	{
		var oldContenidorNH3 = document.getElementById('contenidorNH3_'+oldContenidor);
		oldContenidorNH3.className="dNone";
	}
	
	oldContenidor = valor;
	return false;
}

function showATNH4(tipusBiblio)
{
	var contenidorNH4 = document.getElementById('contenidorNH4');
	contenidorNH4.className="searchForm"
	
	var atNH4_1 = document.getElementById('atNH4_1');
	var atNH4_2 = document.getElementById('atNH4_2');
	var atNH4_3 = document.getElementById('atNH4_3');
	
	atNH4_1.className="dNone";
	atNH4_2.className="dNone";
	atNH4_3.className="dNone";
	
	if(tipusBiblio==2)
		atNH4_2.className="";
	else if(tipusBiblio==3)
		atNH4_3.className="";		
	else
		atNH4_1.className="";
		
	return false;	
}

var current = 1;

function activaMenu(itemMenu)
{
	var currentItem = document.getElementById('item'+current+current);
	var currentContainer = document.getElementById('nh'+current);

	var newItem = document.getElementById('item'+itemMenu+itemMenu);
	var newContainer = document.getElementById('nh'+itemMenu);
	
	currentItem.className = "";
	currentContainer.className = "dNone vHidden";
	
	newItem.className = "active";
	newContainer.className = "";
	
	current = itemMenu;
}
	
function invocaDL(baseURL, idioma, avancada)
{
	var valor = document.getElementById('dicc_lin').value;
	
	if(valor != '' && valor != 0)
	{
		if(avancada == 1)
			var urlNova = baseURL + "/" + idioma + "/Diccionaris_En_Linia/" + valor + "/Fitxes/Avancada/";
		else
			var urlNova = baseURL + "/" + idioma + "/Diccionaris_En_Linia/" + valor + "/";
		
		window.location.href=urlNova;
	}
	
	return false;
}

function invocaBiblioteca(baseURL, idioma)
{
	var tipusBiblioteca = "";
	if(document.getElementById('tipusBiblio3').checked)
	{
		if(document.getElementById('atNH4_3').value!='' && document.getElementById('atNH4_3').value!=0)
			var tipusBiblioteca = "Projectes_En_Curs/Arees_Tematiques/"+document.getElementById('atNH4_3').value+"/";
		else
			var tipusBiblioteca = "Projectes_En_Curs/Arees_Tematiques/";
	}
	else if(document.getElementById('tipusBiblio2').checked)
	{
		if(document.getElementById('atNH4_2').value!='' && document.getElementById('atNH4_2').value!=0)
			var tipusBiblioteca = "Biblioteca_Termcat/Arees_Tematiques/"+document.getElementById('atNH4_2').value+"/";
		else
			var tipusBiblioteca = "Biblioteca_Termcat/Arees_Tematiques/";
	}
	else
	{
		if(document.getElementById('atNH4_1').value!='' && document.getElementById('atNH4_1').value!=0)
			var tipusBiblioteca = "Biblioteca_Terminologica/Arees_Tematiques/"+document.getElementById('atNH4_1').value+"/";
		else
			var tipusBiblioteca = "Biblioteca_Terminologica/Arees_Tematiques/";
	}
	
	
	var urlNova = baseURL + "/" + idioma + "/Biblioteca/" + tipusBiblioteca;
	window.location.href=urlNova;
	
	return false;	
}

function eliminaBenvinguda()
{
	contenidor = document.getElementById('benvinguda');
	contenidor.style.visibility = 'hidden';
	contenidor.style.display = 'none';
}

function canviIdioma(idiomaActual,idiomaNou)
{
	urlActual = window.location.href;
	//urlFinal = "http://www.termcat.cat"
	//urlFinal = "http://momo.keepu.es/TER0109/web/"
	
	//Si estem a l'arrel de la web redirigim a la plana que toca en cada cas
	if(urlActual == urlFinal)
		urlNova = urlActual+idiomaNou;
	else
	{
		idiomaActual = "/"+idiomaActual;
		idiomaNou = "/"+idiomaNou;
		urlNova = urlActual.replace(idiomaActual, idiomaNou);
	}
	
	
	window.location.href=urlNova;
	
	return false;
}

function MostraDiv(capa){
	document.getElementById(capa).style.display='block'; 
	return false;
}

function AmagaDiv(capa){
	document.getElementById(capa).style.display='none'; 
	return false;
}

function isEmpty(campo){
	if (document.getElementById(campo).value == '')
	{
		document.getElementById(campo).focus();
		return false;
	}
	else
	{
		return true;
	}
}

function switchActualitat(origen, desti)
{
	var ori = document.getElementById(origen); 
	var dest = document.getElementById(desti); 
	
	ori.className = "dNone";
	dest.className = "";
}

