
	var imgActual = null;
	var planolActual = null; 
	var numPP = 0;
	var numPF = 0;
	var numPS = 0;
	var numD = 0;
	var llistatVivs = null;

	function canviaPath( casa )
	{	
		parent.header.location = "header.asp?s=3&hb=" + casa;
	}
	
	function enviar() 
	{
		var form = document.getElementById("frmBuscador2");
		form.submit();	
	}
	
	function canviaImatge( nom ) 
	{
		var imatge = document.getElementById("fotogran");
		imatge.src = 'image.asp?path=\documents\\imatges\\' + nom + '&width=405';
		<!--imatge.src = '\documents\\imatges\\' + nom;-->
		imgActual = nom;
	}
	
	function mostraImg()
	{
		/*var imatge = document.getElementById("fotogran");*/
		if (imgActual != null)
		{
			OpenWindow("showimg.asp?i=" + imgActual + "&t=2", 800, 600);
		}
	}
	
	function obre( valor ) 
	{
		var divPS = document.getElementById("divPS");
		var divPP = document.getElementById("divPP");
		var divPF = document.getElementById("divPF");
		var divD = document.getElementById("divD");
		var capa = document.getElementById("divCapa");
		var msg = document.getElementById("messenger");
		var table = document.getElementById("cntTable");
		
		msg.innerHTML = TextNoHiHaElements;
		
		switch(valor) 
		{
			case 1:
				if (divPS.className != "visible") divPS.className = "visible";				
				if (divPP.className != "novisible") divPP.className = "novisible";
				if (divPF.className != "novisible") divPF.className = "novisible";
				if (divD.className != "novisible") divD.className = "novisible";
				if (numPS > 0) msg.innerHTML = TextSeleccionaPlanolSituacio;								
			break;
			case 2:
				if (divPS.className != "novisible") divPS.className = "novisible"; 
				if (divPP.className != "visible") divPP.className = "visible";
				if (divPF.className != "novisible") divPF.className = "novisible";
				if (divD.className != "novisible") divD.className = "novisible";	
				if (numPP > 0) msg.innerHTML = TextSeleccionaPlanolPlanta;		
			break;
			case 3:
				if (divPS.className != "novisible") divPS.className = "novisible"; 
				if (divPP.className != "novisible") divPP.className = "novisible";
				if (divPF.className != "visible") divPF.className = "visible";
				if (divD.className != "novisible") divD.className = "novisible";
				if (numPF > 0) msg.innerHTML = TextSeleccionaPlanolFacana;			
			break;
			case 4:				
				if (divPS.className != "novisible") divPS.className = "novisible"; 
				if (divPP.className != "novisible") divPP.className = "novisible";
				if (divPF.className != "novisible") divPF.className = "novisible";			
				if (divD.className != "visible") divD.className = "visible";
				if (numD > 0) msg.innerHTML = TextSeleccionaDocument;
			break;											
		}
		if (capa.className != "visible") capa.className = "visible";
		if (table.className != "novisible") table.className = "novisible";
		setTimeout("retornar()", 15000);	
	}
	
	function retornar() 
	{	
		var capa = document.getElementById("divCapa");
		var table = document.getElementById("cntTable");
		
		if (capa.className != "novisible") capa.className = "novisible";
		if (table.className != "visible") table.className = "visible";
	}
	
	function planol(nom, pos, tipus)
	{
		var imatge = document.getElementById("planols");
		var capa = document.getElementById("divCapa");
		var table = document.getElementById("cntTable");
		var counter = 0;
		var a = null;
		
		imatge.src = 'image.asp?path=\documents\\planols\\' + nom + '&width=610&height=240';
		if (capa.className != "novisible") capa.className = "novisible";
		if (table.className != "visible") table.className = "visible";		
		planolActual = nom;
		
		if (tipus == "PS")
		{
			counter = numPS;
		}
		else if (tipus == "PP")
		{
			counter = numPP;
		}
		else if (tipus == "PF")
		{
			counter = numPF;
		}
		
		for(i = 1; i <= counter; i++)
		{
			a = document.getElementById("a" + tipus + "_" + i);
			if (i == pos)
			{
				if (a.className != ("aPlans" + tipus + " selectedLink"))
				{
					a.className = "aPlans" + tipus + " selectedLink";
				}
			}
			else
			{
				if (a.className != ("aPlans" + tipus))
				{
					a.className = "aPlans" + tipus;
				}
			}
		}
		
		obteVivendes(nom);
	}
	
	function openPlanol()
	{
		/*var imatge = document.getElementById("fotogran");*/		
		
		if (planolActual != null)
		{
			OpenWindow("planol.asp?i=" + planolActual, 800, 640);
		}
	}
	
	/*function referBuscador() 
	{
		var div1 = document.getElementById("preuItipologia");
		var div2 = document.getElementById("location");
		
		div1.className = "alineat";
		div2.className = "visible";
	}
	*/
	function obteVivendes( nom )
	{
		var ifr = document.getElementById("maker");
		
		ifr.src = "llistat.asp?n=" + nom;
	}
	
	function generaLlistat(llistat)
	{
		var divLlista = document.getElementById("llistatVivendes");
		var objectes = [];
		var elements = [];
		var contingut = "";
		var identificador = "";
		var titol = "";
						
		if (llistat != "")
		{	
			objectes = llistat.split("~");		
			contingut = '<table border="0" cellpadding="0" cellspacing="0" id="tLlistatViv">'; 
			
			for( i = 0; i < objectes.length - 1; i++)
			{
				elements = objectes[i].split("#");
				color = i % 2;
				identificador = elements[1];
				titol = elements[2];
				contingut = contingut + '<tr>';	
				contingut = contingut + '<td class="filesViv color' + color + '"><a href="cartera.asp?v=' + identificador + '" class="aViPromo1"><strong>' + titol + '</strong></a></td>'
				contingut = contingut + '</tr>';
			}											
			
			contingut = contingut + '</table>';	
		}
		
		/*alert(contingut);	*/							
		
		divLlista.innerHTML = contingut;
	}	
	
	function canviaGrup()
		{
			var iOperador = document.getElementById("operador");
			var selectGrup = document.getElementById("selectTipologia");
			
			document.getElementById("divTipologiaPr").style.display="block";
			iOperador.src = "operadorPobProv.asp?cpr=1&g=" + selectGrup.options[selectGrup.selectedIndex].value;
		}
		
		function actualitzaProvincies( llista ) 
		{
			var selectorProvincia = document.getElementById("selectProvincia");
			
			selectorProvincia.length = 0;
			selectorProvincia.options[0] = new Option(TextEsculliProvincia, "-1");
			
			for( i = 0; i < llista.length; i++ )
			{
				selectorProvincia.options[i+1] = new Option(llista[i][0], llista[i][1]);
			}
			
			selectorProvincia.options[selectorProvincia.length] = new Option(TextTotesLesProvincies, "0");
		}
		
		function canviaProvincia()
		{
			var iOperador = document.getElementById("operador");
			var selectGrup = document.getElementById("selectTipologia");
			var selectProvincia = document.getElementById("selectProvincia");		
			
			document.getElementById("divTipologiaPb").style.display="block";
			iOperador.src = "operadorPobProv.asp?cpb=1&pr=" + selectProvincia.options[selectProvincia.selectedIndex].value;
		}
		
		function actualitzaPoblacions( llista ) 
		{
			var selectorPoblacio = document.getElementById("selectMunicipi");
			
			selectorPoblacio.length = 0;
			selectorPoblacio.options[0] = new Option(TextEsculliMunicipi, "-1");
			
			for( i = 0; i < llista.length; i++ )
			{
				selectorPoblacio.options[i+1] = new Option(llista[i][0], llista[i][1]);
			}
			
			selectorPoblacio.options[selectorPoblacio.length] = new Option(TextTotesLesPoblacions, "0");
		}
		
		function canviaMunicipi()
		{
			var iOperador = document.getElementById("operador");
			var selectMunicipi = document.getElementById("selectMunicipi");	
			var selectProvincia = document.getElementById("selectProvincia");
			
			document.getElementById("divTipologia").style.display="block";
			iOperador.src = "operadorPobProv.asp?cg=1&pb=" + selectMunicipi.options[selectMunicipi.selectedIndex].value + "&pr2=" + selectProvincia.options[selectProvincia.selectedIndex].value;
		}
		
		function actualitzaGrups( llista ) 
		{
			var selectorTipologia = document.getElementById("selectTipologia");
			selectorTipologia.length = 0;
			selectorTipologia.options[0] = new Option(TextEsculliTipologia, "-1");
			
			for( i = 0; i < llista.length; i++ )
			{
				selectorTipologia.options[i+1] = new Option(llista[i][0], llista[i][1]);
			}
			
			selectorTipologia.options[selectorTipologia.length] = new Option(TextTotesLesTipologies, "0");
		}
		
		function canviaTipologia()
		{
			var iOperador = document.getElementById("operador");
			var selectTipologia = document.getElementById("selectTipologia");
			var selectMunicipi = document.getElementById("selectMunicipi");
			var selectProvincia = document.getElementById("selectProvincia");
			
			document.getElementById("divTipologiaTp").style.display="block";
			iOperador.src = "operadorPobProv.asp?cg=0&tp=" + selectTipologia.options[selectTipologia.selectedIndex].value + "&pb2=" + selectMunicipi.options[selectMunicipi.selectedIndex].value + "&pr2=" + selectProvincia.options[selectProvincia.selectedIndex].value;
		}
		
		function actualitzaTipus( llista ) 
		{
			var selectorTipus = document.getElementById("selectTipus");
			
			selectorTipus.length = 0;
			selectorTipus.options[0] = new Option(TextEsculliTipus, "-1");
			
			for( i = 0; i < llista.length; i++ )
			{
				selectorTipus.options[i+1] = new Option(llista[i][0], llista[i][1]);
			}
			
			selectorTipus.options[selectorTipus.length] = new Option(TextTotesLesTipus, "0");
		}
