        /*Layaouts*/       
        var xmlDocLay;  
        var strXmlLay;  
        function getXMLLayoutOK(result) 
                {  
	                xmlDocLay = loadXMLDoc(result.d); 
                    getWSSxmlData("afterXMLLayaoutOK","afterXMLLayaoutFAIL",'{4F700F25-5CF4-4943-B957-F513B97A664C}','{1EC91D6D-2C24-4980-A77F-2360293C032A}','<Query><Where><Eq><FieldRef Name="title"/><Value Type="Text">' + 'default' + '</Value></Eq></Where></Query>','','0','');
                }  

        function getXMLLayoutFAIL(result) 
				{  
                    alert(result.status + ' ' + result.statusText); 
                    
                }  
        function afterXMLLayaoutOK(result) 
                {  
		            var bannerBusc;
		            var ImgBuscador1;
		            var ImgBuscador2;
		            var ImgBuscador3;
			    var buscadorListadoVersiones;	
			    var buscadorListadoColores;	
			    var buscadorListadoProvincias;
			    var buscadorListadoPrecios;
	                var rows;
				    if(iexplorer)
					    rowsLay = xmlDocLay.getElementsByTagName('z:row');
				    else
					    rowsLay = xmlDocLay.getElementsByTagNameNS('*', 'row');
				    for (var i=0; i<rowsLay.length; i++) 
				    {
				        var element = rowsLay[i];
					if (element.getAttribute('ows_BannerBuscador') == 1)
					{
						bannerBusc = 1;
					}
					if (element.getAttribute('ows_ImgBuscador1') == 1)
					{
						ImgBuscador1 = 1;
					}
					if (element.getAttribute('ows_ImgBuscador2') == 1)
					{
						ImgBuscador2 = 1;
					}
					if (element.getAttribute('ows_ImgBuscador3') == 1)
					{
						ImgBuscador3 = 1;
					}
					if (element.getAttribute('ows_buscadorListadoVersiones') == 1)
					{
						buscadorListadoVersiones = 1;
					}
					if (element.getAttribute('ows_buscadorListadoColores') == 1)
					{
						buscadorListadoColores = 1;
					}
					if (element.getAttribute('ows_buscadorListadoProvincias') == 1)
					{
						buscadorListadoProvincias = 1;
					}
					if (element.getAttribute('ows_buscadorListadoPrecios') == 1)
					{
						buscadorListadoPrecios = 1;
					}
                    }    	            
   	   	            var xmlDoc = loadXMLDoc(result.d);
     			    var rows;
				    if(iexplorer)
					    rows = xmlDoc.getElementsByTagName('z:row');
				    else
					    rows = xmlDoc.getElementsByTagNameNS('*', 'row');
				    var strXml ="<Layout>";
				    for (var i=0; i<rows.length; i++) 
				    {
				    var element = rows[i];
					if (bannerBusc == 1)
					{
						strXml += "<bannerBusc>" + element.getAttribute('ows_BannerBuscador') + "</bannerBusc>";
					}
					if (ImgBuscador1 == 1)
					{
						strXml += "<ImgBuscador1>" + element.getAttribute('ows_ImgBuscador1') + "</ImgBuscador1>";
					}
					if (ImgBuscador2 == 1)
					{
						strXml += "<ImgBuscador2>" + element.getAttribute('ows_ImgBuscador2') + "</ImgBuscador2>";
					}
					if (ImgBuscador3 == 1)
					{
						strXml += "<ImgBuscador3>" + element.getAttribute('ows_ImgBuscador3') + "</ImgBuscador3>";
					}
					if (buscadorListadoVersiones == 1)
					{
						strXml += "<buscadorListadoVersiones>1</buscadorListadoVersiones>";
					}
					if (buscadorListadoColores == 1)
					{
						strXml += "<buscadorListadoColores>1</buscadorListadoColores>";
					}
					if (buscadorListadoProvincias == 1)
					{
						strXml += "<buscadorListadoProvincias>1</buscadorListadoProvincias>";
					}
					if (buscadorListadoPrecios == 1)
					{
						strXml += "<buscadorListadoPrecios>1</buscadorListadoPrecios>";
					}
                 }
 				strXml += "</Layout>";
 				strXmlLay = strXml; 
				DisennoOK();
	            }  
		function afterXMLLayaoutFAIL(result) 
		{  
                alert(result.status + ' ' + result.statusText);  
        }
        /*Fin Layaouts*/  
                      
        /* Filtros de búsqueda  */        
        var filtroColores = false;
        var filtroPrecio = false;
        var filtroVersiones = false;
        function actualizarVisibles()
        {
			
	    	
			//alert(filtroColores + " " + filtroVersiones + " " + filtroPrecio);
			if((filtroColores == false) && (filtroVersiones == false) && (filtroPrecio == false) )
			{

				//creamos la cadena de busqueda                 	
				var coches = $jq(".datos_coche");       	
	        	for (i=0;i<coches.length;i++)
		    	{
	    			$jq(coches[i]).parent().css("display","block");
					$jq(coches[i]).parent().addClass("visible");
		    	}

			}
			else
			{
				//creamos la cadena de busqueda                 	
				var coches = $jq(".datos_coche");       	
				//alert(coches.length);
	        	for (i=0;i<coches.length;i++)
		    	{
	    			$jq(coches[i]).parent().css("display","none");
					$jq(coches[i]).parent().removeClass("visible");
		    	}
				
		        strSearch = (filtroColores ? ".visibleColores" : "") + (filtroVersiones ? ".visibleVersion" : "") + (filtroPrecio ? ".visiblePrecio" : "");
		    	var visibles = $jq(strSearch,$jq(".datos_coche").parent().parent());	
		    	//alert(visibles.length);
		    	for (i=0;i<visibles.length;i++)
		    	{
	    			$jq(visibles[i]).css("display","block");
					$jq(visibles[i]).addClass("visible");			    
				}
			}
        }
        function paginacion()
        {
        	$jq("#buscadorListado  .visible").quickpaginate({ perpage: 4, showcounter: true, pager : $jq(".paginacion") });	
        }
        /* Fin filtros de búsqueda */
        
         jQuery.fn.sort = function() { 
         //alert("sort");
            return this.pushStack([].sort.apply(this, arguments), []); 
        };

        function sortAscendingPrecio(a, b) {
        //alert("e");
        //alert(parseFloat ($jq("a[id^='link']", $jq(a)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(a)).attr("descuento")) + " - " +  parseFloat ($jq("a[id^='link']", $jq(b)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(b)).attr("descuento")));
            precioA = (parseFloat ($jq("a[id^='link']", $jq(a)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(a)).attr("descuento")));
            precioB = (parseFloat ($jq("a[id^='link']", $jq(b)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(b)).attr("descuento")));
            //alert($jq("a[id^='link']", $jq(a)).length);
            return precioA > precioB ? 1 : -1;
        };

        function sortDescendingPrecio(a, b) {
        //alert(parseFloat ($jq("a[id^='link']", $jq(a)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(a)).attr("descuento")) + " - " +  parseFloat ($jq("a[id^='link']", $jq(b)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(b)).attr("descuento")));
            precioA = (parseFloat ($jq("a[id^='link']", $jq(a)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(a)).attr("descuento")));
            precioB = (parseFloat ($jq("a[id^='link']", $jq(b)).attr("Precio")) -  parseFloat ($jq("a[id^='link']", $jq(b)).attr("descuento")));
            //alert($jq("a[id^='link']", $jq(a)).length);
            return precioA < precioB ? 1 : -1;
        };

        function sortAscendingCercania(a, b) {
            precioA = parseFloat ($jq("a[id^='link']", $jq(a)).attr("orden"));
            precioB = parseFloat ($jq("a[id^='link']", $jq(b)).attr("orden"));
            //alert($jq("a[id^='link']", $jq(a)).length);
            return precioA > precioB ? 1 : -1;
        };

        function sortDescendingCercania(a, b) {
            precioA = parseFloat ($jq("a[id^='link']", $jq(a)).attr("orden"));
            precioB = parseFloat ($jq("a[id^='link']", $jq(b)).attr("orden"));
            //alert($jq("a[id^='link']", $jq(a)).length);
            return precioA < precioB ? 1 : -1;
        };

