// JavaScript Document	
function selecciona(numName,menuPosition,longitud){
	
		var identificacio = menuPosition + numName;
		
		if(menuPosition == "mh"){
	    	for (var i = 0; i < longitud; i++){
				if( document.getElementById(menuPosition + i).className == "seleccionatMH");
					document.getElementById(menuPosition + i).className = "";		
			}
			deseleccionarMH(longitud);
			document.getElementById(identificacio).className = "seleccionatMH";
			
		}
		if(menuPosition == "mv"){
			for (var i = 0; i < 6; i++){
				if( document.getElementById(menuPosition + i).className == "seleccionatMV");
					document.getElementById(menuPosition + i).className = "MenuVertical";		;		
			}
			
			document.getElementById(identificacio).className = "seleccionatMV";
		}	
	}
	
	function deseleccionarMH(longitud){
		for(var i = 0; i <longitud;i++)
			document.getElementById("mh"+i).className = "";	
	
	}
	
	function hidePestanya(longitud){
		
		
		
		deseleccionarMH(longitud);
		var pestanya = document.getElementById('Ipestanya');
		pestanya.innerHTML="";
		pestanya.style.background = "";
    }
	
	
	function canviarFonsSala(numSala){
		
		
		var fons = document.getElementById('IcontenidorInfo');
		
		if(document.getElementById('Ipestanya')!= null)
			hidePestanya();
		else
			fons.innerHTML="<div id=\"Ipestanya\"></div>";		
				
		if(numSala == 0){
			
			fons.style.background = "url(fotosInfo/fotoRecepcio.jpg) no-repeat";
		}
			
		else if(numSala == 1){
			fons.style.background = "url(fotosInfo/salaDespera.jpg) no-repeat";
		}
			
		else if(numSala == 2){
			fons.style.background = "url(fotosInfo/fotoRentacaps.jpg) no-repeat";
		}
			
		else if(numSala == 3){
			fons.style.background = "url(fotosInfo/fotoZonapelu.jpg) no-repeat";
		}
			
		else if(numSala == 4){
			fons.style.background= "#FFFFFF url(fotosInfo/fotoNoticies.jpg) no-repeat right";
		}
			
		else if(numSala == 5){// VISITA VIRTUAL
			fons.style.background = "#000000";
            fons.style.borderTop = "1px solid #FFFFFF";
            insertarVisitaVirtual();
		}
		else if(numSala == 6){
			fons.style.background = "url(fotosInfo/fotoGaleria.jpg) no-repeat";
		}
		else if(numSala == 7){
			fons.style.background = "url(fotosInfo/fotoExposicio.jpg) no-repeat";
		}
	}
	
	
	function insertarGaleries(posMV){
	
		contenidorGaleries = document.getElementById('LcontenidorLeftGaleria');
		
		if(posMV == 1) // s'ha seleccionat Sala d'espera, per tant hem d' insertar les exposicions
		{
			contenidorGaleries.innerHTML = exposicio(false,0);
		}
		else if(posMV == 3){
			contenidorGaleries.innerHTML = galeria(false,0);
		}
		else if(posMV == 4){
			contenidorGaleries.innerHTML = galeria_noticia(false,0);
		}
		else{
			contenidorGaleries.innerHTML="";	
		}
			
}
	function menuHoritzontal(opcio0,opciob0,opcio1,opciob1,opcioc1,opcio2,opciob2,opcio3,opciob3,opcioc3,opcio4,opciob4,posMV,longitud){
		
		contenidorTop = document.getElementById('TcontenidorTop');
		var tHtml;
		if(opcio0 == "aromaterapia"){
			var opcioAccent = "aromater&agrave;pia";
		}
		else
			opcioAccent = opcio0;
		
        if(longitud == 0)
            tHtml = "<div id=\"CantonadaLeftTop\"></div>";
		if(longitud >= 1)
			tHtml = "<div id=\"CantonadaLeftTop\"></div><ul><li id=\"mh0\"><a href = \"#\"   onclick=\"showPestanya"+opcio0+opciob0+"(); selecciona(0,'mh',"+longitud+")\" >"+opcioAccent+" "+opciob0+"</a></li>";
		
		if(longitud >= 2)
			tHtml = tHtml+"<li id=\"mh1\"><a href = \"#\"   onclick=\"showPestanya"+opcio1+opciob1+opcioc1+"(); selecciona(1,'mh',"+longitud+")\" >"+opcio1+" "+opciob1+" "+opcioc1+"</a></li>";
		
		if(longitud >= 3)
			tHtml = tHtml+"<li id=\"mh2\"><a href = \"#\"   onclick=\"showPestanya"+opcio2+opciob2+"(); selecciona(2,'mh',"+longitud+")\" >"+opcio2+" "+opciob2+"</a></li>";
				
		if(longitud >= 4)
			tHtml = tHtml+"<li id=\"mh3\"><a href = \"#\"   onclick=\"showPestanya"+opcio3+opciob3+opcioc3+"(); selecciona(3,'mh',"+longitud+")\" >"+opcio3+" "+opciob3+" "+opcioc3+"</a></li>";
		
		if(longitud >= 5)
			tHtml = tHtml+"<li id=\"mh4\"><a href = \"#\"   onclick=\"showPestanya"+opcio4+opciob4+"(); selecciona(4,'mh',"+longitud+")\" >"+opcio4+" "+opciob4+"</a></li>";
			
		
		
		tHtml = tHtml +"</ul><div id=\"CantonadaRightTop\"></div>";
		
		contenidorTop.innerHTML = tHtml;
		deseleccionarMH(longitud);
		selecciona(posMV,'mv',6);
		canviarFonsSala(posMV);
		//insertarGaleries(posMV); // Activa el menu de galeries a l'esquerre (sota elmenu vertical)
		document.getElementById('IcontenidorInfo').style.borderBottom ="";	
		
	}

// PER LA VISITA VIRTUAL
function insertarVisitaVirtual(){

    var contenidor = document.getElementById('IcontenidorInfo');
    var textHTML;
        
    textHTML = "<div align=center class=\"contenidorFlashVisitaVirtual\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\"500\" height=\"240\" title=\"Visita Virtual Vigart\"><param name=\"movie\" value=\"visitavirtual.swf\" /><param name=\"quality\" value=\"high\" /><embed src=\"visitavirtual.swf\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"500\" height=\"240\"></embed></object></div><div align=\"center\"></div>";
    contenidor.innerHTML = textHTML;     
}

// ROLLOVER FUNCTIONS:

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}