$(document).ready(function(){$("a[id^='filterPrecio']").each(function(){$(this).click(function(){if(validateRangoPrecio()){var val="";if($(this).attr("id").indexOf("Pesos")!=-1){val=1}else{val=2}is_filter_by_precio_active=true;removeHidden(current_page_input,false);appendHidden(precio_moneda_input,val,false);appendHidden(precio_desde_input,$("#precio_desde").val(),false);appendHidden(precio_hasta_input,$("#precio_hasta").val(),true)}return false})});$("img.thumb").each(function(){var $img=$(this);var width=$img.width();var height=$img.height();var widthFactor=width/thumbnailWidth;var heightFactor=height/thumbnailHeight;var factor;if(widthFactor>heightFactor){factor=widthFactor}else{factor=heightFactor}$img.width(Math.round(width/factor)).height(Math.round(height/factor))});loadSortState();$("#order_select").change(function(){var $this=$(this);var value=eval("("+$this.val()+")");removeHidden(current_page_input,false);appendHidden(sort_by_input,value.Property,false);appendHidden(sort_direction_input,value.Direction,true)});$("div.ListadoCont").each(function(){var $this=$(this);var $lis=$this.find("ul > li:gt(2)");var $verMas=$this.find("div.BtnVer > a");if($lis.length<1){$verMas.hide();return}$lis.hide();$verMas.click(function(){var $link=$(this);if($link.hasClass("VerMas")){$link.removeClass("VerMas").addClass("VerMenos");$link.text("Ver Menos");$lis.show()}else{$link.removeClass("VerMenos").addClass("VerMas");$link.text("Ver Mas");$lis.hide()}})});$("div.Boton").click(function(){var $this=$(this);if($this.hasClass("Boton")){$this.removeClass("Boton").addClass("Baja");$this.next().hide()}else{$this.removeClass("Baja").addClass("Boton");$this.next().show()}});var $divContenido=$("div.Contenido");$divContenido.find("div.Listado,div.Separador").show();var $ver=$divContenido.find("div.Ver > a");if($divContenido.find("div.Listado").length<=3){$ver.hide()}else{$ver.show()}$("div.Ver > a").click(function(){var $this=$(this);if($this.hasClass("VerMas")){$this.removeClass("VerMas").addClass("VerMenos").text("Ver Menos");$("div.Contenido").find("div.Listado:gt(2),div.Separador:gt(2)").show()}else{$this.removeClass("VerMenos").addClass("VerMas").text("Ver Mas");$("div.Contenido").find("div.Listado:gt(2),div.Separador:gt(2)").hide()}})});function loadSortState(){$sort_property=findHiddenByName(sort_by_input);$sort_direction=findHiddenByName(sort_direction_input);if($sort_property.length>0&&$sort_direction.length>0){$("#order_select").children().each(function(){var $this=$(this);var value=eval("("+$this.val()+")");if(value.Property==$sort_property.val()&&value.Direction==$sort_direction.val()){$this.attr("selected",true)}})}}function applyFilter(a){removeHidden(current_page_input,false);appendHidden(activeFilterInputPrefix+a,a,true)}function appendHidden(c,d,b){var a=$("#formGrid");var e=findHiddenByName(c);if(e.length==0){e=$("<input />").attr("type","hidden").attr("name",c).appendTo(a)}e.val(d);if(b){a.submit()}}function findHiddenByName(a){return $('input[name="'+a+'"]')}function removeFilter(a){removeHidden(current_page_input,false);removeHidden(activeFilterInputPrefix+a,true)}function clearHidden(b,a){$('input[name="'+b+'"]').val("");if(a){$("#formGrid").submit()}}function removeHidden(b,a){$('input[name="'+b+'"]').remove();if(a){$("#formGrid").submit()}}function removePrecio(){removeHidden(current_page_input,false);removeHidden(precio_moneda_input,false);clearHidden(precio_desde_input,false);clearHidden(precio_hasta_input,true)}function removeIdOrigen(){removeHidden(idOrigen_input,true)}function removeVendedor(){removeHidden(current_page_input,false);removeHidden(vendedor_input,true)}function EliminarFiltros(){removeHidden(current_page_input,false);$("input[name^='"+dynamicFilterId+"']").remove();$("input[name='"+precio_moneda_input+"']").remove();$("input[name='"+precio_desde_input+"']").remove();$("input[name='"+precio_hasta_input+"']").remove();$("input[name='"+idOrigen_input+"']").remove();$("input[name='"+sinResultados_input+"']").remove();$("#formGrid").submit()}function preview(c,d){var b=$("#div_preview_"+d);var a=$("#liPreview_"+c);if(b.attr("desplegado")=="true"){b.attr("desplegado","false");a.removeClass();b.hide();return}if(b.attr("cargado")=="true"){b.attr("desplegado","true");a.addClass("Exp");b.show();return}$.ajax({type:"POST",url:urlPreview,data:"idPropiedad="+c,dataType:"html",success:function(e){b.html(e);b.attr("desplegado","true");b.attr("cargado","true");a.addClass("Exp");var f=b.parent().find(".detailsLink").attr("href");b.find("[name='linkDetails']").attr("href",f);b.show()}})}function validateRangoPrecio(){var a=parseInt($("#precio_desde").val(),10);var b=parseInt($("#precio_hasta").val(),10);if(!isNaN(a)&&!isNaN(b)&&a>=0&&b>=0){if(a>b){$("#precio_desde").val(b);$("#precio_hasta").val(a)}else{$("#precio_desde").val(a);$("#precio_hasta").val(b)}return true}$("#precio_desde").addClass("input-validation-error");$("#precio_hasta").addClass("input-validation-error");alert("Debe ingresar un precio válido.");return false}function setHistoryBacks(){$("a[name^='linkDetails_'], a[name^='thumbnailLinkDetails_']").each(function(){var c=$(this).attr("href");var d=$(this).clone();var b=c.indexOf("?");var a=(b!=-1?c.substring(0,b):c)+"?hb=1";d.attr("href",a);$(this).before(d);$(this).remove()})}function setPageParams(a){if($(jquery_id(current_page_input)).length==0){appendHidden(current_page_input,a,false)}else{$(jquery_id(current_page_input)).val(a)}}function setSortParams(a){if($(jquery_id(sort_by_input)).length==0&&$(jquery_id(sort_direction_input)).length==0){appendHidden(sort_by_input,a.Property,false);appendHidden(sort_direction_input,a.Direction,false)}else{$(jquery_id(sort_by_input)).val(a.Property);$(jquery_id(sort_direction_input)).val(a.Direction)}}function setHashKeyValue(b,a,c){var d=window.location.hash.replace(new RegExp(b),"");window.location.hash=d+"/"+a+"="+c}function loadPage(a){setHashKeyValue("/sp.CurrentPage=(\\d+)","sp.CurrentPage",a);setPageParams(a);loadListAjax();return false}setHistoryBacks();$(document).ready(function(){$("#buscar").attr("src","../../content/1024/img/Hd/im_BuscarOn.gif");$("#order_select").removeAttr("disabled")});function updateLista(){$("a[name*='Fav']").each(function(){var a=$(this).attr("name");var c=null;var b=a.indexOf("agregar")>=0;if(b){c=a.substring(10,a.length)}else{c=a.substring(11,a.length)}mostrarFavAction(this,c,b)})}Login.AddHandler(updateLista);function loadListAjax(){$("#resultadoBusqueda > div").block({message:"<h1>Cargando...</h1>",overlayCSS:{opacity:0.1}});$.ajax({type:"POST",url:urlListAjax,data:$("#formGrid").serializeArray(),success:function(a){$("#resultadoBusqueda").html(a);loadSortState();setHistoryBacks();$("#resultadoBusqueda").unblock()}});return true}function bindSort(){$("#order_select").change(function(){var $this=$(this);var sortParams=eval("("+$this.val()+")");var hash=window.location.hash;hash=hash.replace(/\/sp.SortBy=(\w*)/,"");hash=hash.replace(/\/sp.SortDirection=(\w*)/,"");hash+="/"+sort_by_input+"="+sortParams.Property;hash+="/"+sort_direction_input+"="+sortParams.Direction;window.location.hash=hash;setSortParams(sortParams);setPageParams(1);setHashKeyValue("/sp.CurrentPage=(\\d+)","sp.CurrentPage",1);loadListAjax()})}$(document).ready(function(){var c=document.location.hash.replace("#","");if(c!=""){var a;if(c.match(/\/sp.CurrentPage=(\d+)/)!=null){a=c.match(/\/sp.CurrentPage=(\d+)/)[1]}if(c.match(/\/sp.SortBy=(\w+)/)!=null&&c.match(/\/sp.SortDirection=(\w+)/)!=null){var b=c.match(/\/sp.SortBy=(\w+)/)[1];var d=c.match(/\/sp.SortDirection=(\w+)/)[1];if(b!=""&&d!=""){setSortParams({Property:b,Direction:d})}}if(a!=""){setPageParams(a)}loadListAjax()}});
