
	// FUNCIONS DE JAVASCRIPT
	var objIMGMENUAUX = new Image();
	//variable pel tema mapa flash
	var ande='';
	
	var icoactiu='';
	function Anar(on){
	
		window.location.href = "index.php?menu=" + on;
	
	}
	
	// FUNCIÓ PER A LA VALIDACIÓ DE FORMULARIS
 	function comprovacio(camps,noms,eltexte,frase,frase_email){
		
		var camps = camps.split(','); 
		var noms = noms.split(',');
		var correcte = 1;

		for(i=0; i<(camps.length); i++){
			
			if(camps[i]=='email')
			{
			
				if ((document.getElementById('email').value =="") || !(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById('email').value)))
				{		
			      	alert(frase_email);
	    		  	return (false);	
	    		}		
			}
			else	if(!document.getElementById(camps[i]).value)
					{
						alert(eltexte+noms[i]);
						document.getElementById(camps[i]).focus();
						correcte = 0;
					}
		}
		
		if(correcte)
		{
			if(confirm(frase)) correcte=1;
			else correcte=0;
		}
		
		if(correcte)
		{	
			return true;	
		}
		else return false;

	}
	
	// FA EL ROLLOVER DEL MENÚ
	function RollOverMenu(objIMG){
		
		var estaSeleccionada = (objIMG.src.indexOf("?") > 0);
		
		if(!estaSeleccionada){
			
			var urlIMG = objIMG.src;
			
			var parts = urlIMG.split("/");
			var parts2 = parts[parts.length - 1].split("_");
			
			var strURL = "";
			
			for(var i=0; i<parts.length - 1; i++)
				strURL += parts[i] + "/";
			
			for(var i=0; i<parts2.length - 1; i++)
				strURL += parts2[i] + "_";
			
			if(parts2[i] == "on.gif")	strURL += "off.gif";
			else	strURL += "on.gif";
		
			objIMG.src = strURL;
			
		}
		
	}
	
	// MOSTRA EL DETALL D'UNA NOTÍCIA
	function VeureNoticia(id){
		
		var strURL = "index.php?menu=noticies&noticia=" + id;
		window.location.href = strURL;
		
	}
		
	//FUNCIÓ PER ACTUALITZAR ELS CENTRES AMB LA POBLACIÓ CORRESPONENT
	function actualitzar_centres (llistat_select, tipus_centre) 
	{
		var id_poblacio;
		var url;
			id_poblacio = llistat_select.options[llistat_select.selectedIndex].value;
			url = "index.php?menu=centres&tipus_centre=" + tipus_centre + "&poblacio=" + id_poblacio
			window.location.href = url;
	}
	
	//FUNCIÓ PER MOSTRAR UNA IMATGE AMPLIADA
	function Ampliar_foto(ruta_foto,amplada,altura)
	{
		var ventana=null;
		var Top=parseInt((screen.height-altura)/2);
		var Left=parseInt((screen.width-amplada)/2);

		ruta_foto = "./includes/tallfoto.php?ruta=." + ruta_foto + "&posx=0&posy=0&width=" + amplada + "&height=" + altura + "&opcio=escala";		
		ventana=window.open("about:blank","foto","scrollbar=no,top="+Top+",left="+Left+",width="+amplada+",height="+altura+",status=no,menubar=no,scrollbar=no,directories=no,toolbar=no,resizable=no,border=no,location=no");
		ventana.document.write("<body style='margin-top:0px; margin-left:0px; margin-right:0px; margin-left:0px;'>");
		ventana.document.write("<img src='" + ruta_foto + "'>");
		ventana.document.write("</body>");
		ventana.focus();
	}
	
	//FUNCIÓ PER REDIRECCIONAR LA PÁGINA AL TIPUS DE PRODUCTE ESCOLLIT
	function Seleccio_producte (tipus_producte) 
	{
		var url;
			url = "index.php?menu=productes&tipus_producte=" + tipus_producte
			window.location.href = url;
	}
	
	//FUNCIÓ PER REDIRECCIONAR LA PÁGINA SEGONS LA PESTANYA TRIADA
	function Seleccionar_seccio (seccio,tipus_producte)
	{
		var url;
			url = "index.php?menu=productes&tipus_producte=" + tipus_producte + "&subcategoria=subcategoria&seccio=" + seccio
			window.location.href = url;						
	}
	
	function Fer_recerca(id_input)
	{
		var url;
		var paraula;
			paraula = document.getElementById(id_input).value;
			url = "index.php?menu=productes&opcio=cerca&cerca=" + paraula;
			window.location.href = url;
	}
	
	function GenerarFlashTop(PathTemplates, lang){
		
		document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='412' height='88'>");
		if(lang == 'esp')
		{
			document.write("<param name='movie' value='" + PathTemplates + "swf/banner_" + lang + ".swf?init=1&n1=Suministros%20Industriales&n2=Acero%20Inoxidable&n3=Aluminio' FlashVars='n1=Suministros%20Industriales&n2=Acero%20Inoxidable&n3=Aluminio' />");
			document.write("<param name='quality' value='high' />");
			document.write("<embed src='" + PathTemplates + "swf/banner_" + lang + ".swf?init=1&n1=Suministros%20Industriales&n2=Acero%20Inoxidable&n3=Aluminio' FlashVars='init=1&n1=Suministros%20Industriales&n2=Acero%20Inoxidable&n3=Aluminio' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='412' height='88'></embed>");
		}
		else if (lang == 'cat')
		{
			document.write("<param name='movie' value='" + PathTemplates + "swf/banner_" + lang + ".swf?init=1&n1=Subministraments Industrials&n2=Acer Inoxidable&n3=Alumini' FlashVars='n1=Subministraments Industrials&n2=Acer Inoxidable&n3=Alumini' />");
			document.write("<param name='quality' value='high' />");
			document.write("<embed src='" + PathTemplates + "swf/banner_" + lang + ".swf?init=1&n1=Subministraments Industrials&n2=Acer Inoxidable&n3=Alumini' FlashVars='init=1&n1=Subministraments Industrials&n2=Acer Inoxidable&n3=Alumini' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='412' height='88'></embed>");
		}
		else if (lang == 'ang')
		{
			document.write("<param name='movie' value='" + PathTemplates + "swf/banner_" + lang + ".swf?init=1&n1=Industrial Supplies&n2=	Stainless steel&n3=Aluminum' FlashVars='n1=Industrial Supplies&n2=Stainless steel&n3=Aluminum' />");
			document.write("<param name='quality' value='high' />");
			document.write("<embed src='" + PathTemplates + "swf/banner_" + lang + ".swf?init=1&n1=Industrial Supplies&n2=Stainless steel&n3=Aluminum' FlashVars='init=1&n1=Industrial Supplies&n2=Stainless steel&n3=Aluminum' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='412' height='88'></embed>");
		}
		document.write("</object>");
		
	}
	
	function GenerarGaleriaImatges(){
	
		document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='658' height='225' id='gimgs' align='middle'>");
		document.write("<param name='allowScriptAccess' value='sameDomain' />");
		document.write("<param name='movie' value='gimgs.swf' />");
		document.write("<param name='quality' value='high' />");
		document.write("<param name='bgcolor' value='#eaeaea' />");
		document.write("<embed src='gimgs.swf' quality='high' bgcolor='#eaeaea' width='658' height='225' name='gimgs' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
		document.write("</object>");
	
	}
	
activat=0;
capaant='';

function apareixacapa(capa){
				//document.getElementById('desc').style.visibility='hidden';
	
	if(document.getElementById(capa).style.visibility=='visible'){
		apareixaTipustipo('');
		document.getElementById(capa).style.visibility='hidden';
		document.getElementById(capa).style.position='absolute';		
	}else{
		document.getElementById(capa).style.visibility='visible';
		document.getElementById(capa).style.position='static';
		apareixaTipustipo(document.getElementById('tipo').value);
	}
}

function apareixacapa2(capa){
				//document.getElementById('desc').style.visibility='hidden';
			
	if(document.getElementById(capa)){
		if(document.getElementById(capa).style.visibility=='visible'){						
			document.getElementById(capa).style.visibility="hidden";
			document.getElementById(capa).style.position="absolute";
		}else{
			document.getElementById(capa).style.visibility='visible';
			document.getElementById(capa).style.position="static";
		}
	}
	
}

function ratlla(capa,capa2){
	if(document.getElementById(capa).style.visibility=='visible'){
		document.getElementById(capa2).className='bordreprodon';		
	}else{
		document.getElementById(capa2).className='bordreprod';
	}
}

function amagaprods(i,total){
	x=0;
		while(document.getElementById('prod'+x+i)){
				document.getElementById('prod'+x+i).style.visibility='hidden';
				document.getElementById('prod'+x+i).style.position='absolute';
		x++;
		}	
}
function foratotes(capa,total,td){	
	
	for(i=0;i<total;i++){
		document.getElementById('linia'+i).style.visibility='hidden';
		document.getElementById('td'+i).className='fonslinia2';
		
	}
	
	document.getElementById(capa).style.visibility='visible';
	document.getElementById(td).className='fonslinia';
	
	
	icoactiu=capa;
}

function aquesta(capa,td){
	document.getElementById(capa).style.visibility='visible';
	document.getElementById(td).className='fonslinia';
}
	
	// FUNCIÓ PER CARREGAR FLASHS I EVITAR EL BUG DE L'EXPLORER
	function LoadFlash(PathMovie, width, Height){
		
		document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='" + width + "' height='" + Height + "' id='FlashMovie' align='middle'>");
		document.write("<param name='allowScriptAccess' value='sameDomain' />");
		document.write("<param name='movie' value='" + PathMovie + "' />");
		document.write("<param name='quality' value='high' />");
		document.write("<param name='bgcolor' value='#eaeaea' />");
		document.write("<embed src='" + PathMovie + "' quality='high' bgcolor='#eaeaea' width='" + width + "' height='" + Height + "' name='FlashMovie' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
		document.write("</object>");
		
	}
	
	function PopupWindow(strURL, w, h){
		
		var left = (screen.width/2) - (w/2);
		var top = (screen.height/2) - (h/2);
		var strPARAMS = "width="+w+",height="+h+",left="+left+",top="+top+",toolbar=no,menubar=no,taskbar=no,allwaysraised=yes";
		window.open(strURL, "", strPARAMS);
		
	}