var jsonNoticias="";function getCarros(b){var a="";$.getJSON("getUltimos.php",{limite:b},function(c){if(c.carros.length>=1){$.each(c.carros,function(d,e){a='<div class="contAnun" id="'+e.valor+'">';a+='<div class="close">X</div>';a+='<div class="img"><img src="anuncios/'+e.valor+'/fren-min.jpg" /></div>';a+='<div class="txt">';a+=e.titulo+"<br />";a+=e.precio+"<br />";a+=e.telefono;a+="</div>";a+="</div>";$("#ultimosPublicados").append(a)})}else{$("#ultimosPublicados").html('<div class="nota">No se encontr&oacute; ning&uacute;n veh&iacute;culo.</div>')}});return a}$(document).ready(function(){var b=0;var a=0;getCarros(6);$(".contAnun .txt,.contAnun .img").live("click",function(){var c=$(this).parents(".contAnun").attr("id");popUp(c);setTimeout("getVisitados();",5000)});$(".close").live("click",function(){$(this).parents(".contAnun").fadeOut(function(){$(this).remove();getCarros(1)})});$(".sc_menu img").live("click",function(){var c=$(this).attr("id");c=c.replace("img","");showNoticias(c)})});function makeScrollable(e,c){var e=$(e),c=$(c);c.hide();var d=$('<div class="loading">Cargando...</div>').appendTo(e);var a=setInterval(function(){var f=c.find("img");var g=0;f.each(function(){if(this.complete){g++}});if(g==f.length){clearInterval(a);setTimeout(function(){d.hide();e.css({overflow:"hidden"});c.slideDown("slow",function(){b()})},1000)}},100);function b(){var h=99;var f=e.width();var j=e.height();var i=c.outerHeight()+2*h;var g;e.mousemove(function(m){g=m.target;var l=e.offset();var k=(m.pageY-l.top)*(i-j)/j-h;if(k<0){k=0}e.scrollTop(k)})}}function showNoticias(c){var a="";var b=jsonNoticias.noticias;a+='<div class="contNoticia">';a+='<div class="img"><img src="getImagen-noticias/'+b[c]["imagen"]+'/1.jpg-291-146" alt="'+b[c]["titulo"]+'"/></div>';a+='<div class="titulo"><a href="noticias/'+b[c]["id"]+'.html">'+b[c]["titulo"]+"</a></div>";a+='<div class="descripcion">'+b[c]["resumen"]+"</div>";a+='<div class="opciones"><a href="noticias/'+b[c]["id"]+'.html">Leer m&aacutes</a></div>';a+="</div>";$(".contNoticia").remove();$(".sc_menu_wrapper").before(a)}function getNoticias(){var a="";if(jsonNoticias==""){$.post("getJSON.php",{zona:"noticias",sector:"index"},function(b){jsonNoticias=b;$.each(b.noticias,function(c,d){a+='<img src="getImagen-noticias/'+d.imagen+'/1.jpg-100-75" border="0" alt="'+d.titulo+'" id="img'+c+'"/>'});$(".sc_menu").html(a);$(".sc_menu img").css({opacity:0.4});$(".sc_menu img").hover(function(){$(this).css({opacity:1})},function(){$(this).css({opacity:0.4})});showNoticias(0);makeScrollable("div.sc_menu_wrapper","div.sc_menu")},"json")}};
