$(document).ready(function(){
		$('#mycarousel li').css({'cursor':'pointer'})
		
		$("#lista_menu li div").bind("mouseover",function(){
			$(this).stop();									  
			$(this).animate({marginTop:"-41px"},250);												  
		})
		$("#lista_menu li div").bind("mouseout",function(){
			$(this).stop();									  
			$(this).animate({marginTop:"0px"},250);										  
		})
		
		if(typeof Page == "undefined"){
		}else{
			switch(Page){
				case 'Autos':
					Autos();
				break;
			}
		}
		
		function Autos(){
			$.getJSON("clases/_json.php",{lista: "Autos", rango: "0,10000"},function(json){
				var $total 	= 0; 
				var $ip		= 18; //items por pagina
				
				$total =  (json.length / $ip );
				$num = parseInt( (json.length / $ip ) );
				if($total > $num){
					$total += 1;
				}
				
				PageClick = function(number) {
					$("#paginacion").pager({ pagenumber: number, pagecount: $total, buttonClickCallback: PageClick });
					Cargar({lista:"Autos", rango:""+((number-1)*$ip)+","+$ip });
				}
				$("#paginacion").pager({ pagenumber: 1 , pagecount: $total , buttonClickCallback: PageClick });
			});
			Cargar({ lista:"Autos",rango:"0,18" });
		}
		
		function Cargar(opciones){
			var $page = $("#lista_autos");
			$page.fadeOut();
			$.getJSON("clases/_json.php", {lista: opciones.lista, rango: opciones.rango} ,function(json){
				$lista = "";
				for(var i in json){
					$lista += '<li class="auto_item" >'+
									'<table width="121" border="0" cellpadding="0" cellspacing="0">'+
									 '<tr>'+
										'<td colspan="3" align="center">'+
										'<a href="popup_ventas.php?auto='+json[i].id+'" onclick="return hs.htmlExpand(this,{objectType: \'iframe\', height:610, width:880,  objectLoadTime: \'after\', allowWidthReduction: 1} )">'+
											'<img class="thumb_auto" style="cursor:pointer"  src="images/autos/'+json[i].thumbnail+'" width="104" height="75" alt="Ver Auto" border="0" />'+
										'</a>'+
										'</td>'+
									  '</tr>'+
									  '<tr>'+
										'<td width="91">'+json[i].marca+'</td>'+
										'<td width="9"></td>'+
										'<td width="22"></td>'+
									  '</tr>'+
									  '<tr>'+
										'<td class="modelo_item" >'+json[i].modelo+'</td>'+
										'<td></td>'+
										'<td >'+json[i].anio+'</td>'+
									 '</tr>'+
									  '<tr class="precio_item">'+
										'<td>US$</td>'+
										'<td>'+json[i].precio+'</td>'+
										'<td></td>'+
									  '</tr>'+
									'</table>'+
								'</li>'
				}
				$page.fadeIn().html($lista);
			})	
			$.Log("Mostrando Autos...",{clear :true});

		}
		
		$("img.tooltip").mouseover(function(e){
											
			$tool   =  $(this).next();
			if($.browser.msie && $.browser.version=="7.0"){
				$tool.css({top: "-120px" , marginLeft : "-125px" });
			}else{
				$tool.css({top: "-120px" , marginLeft : "-50px" });
			}
			$tool.show().animate({ top: "-105px" },200);
		})
		
		$("img.tooltip").mouseout(function(){
			$(this).next().hide();
		})
		$(".servicios_item").live("mouseover",function(){
			$("#dv_menu").show();	
		})
		
		$(".servicios_item").live("mouseout",function(){
			$("#dv_menu").hide();	
		})
		
	$("#cont_carrusel").css({'visibility':'visible','width':'682px'});
        		   
			
});
function cargar(url){
	$("#dv_menu").fadeOut("fast");
	var contenedor = $("#cabecera_general");
	$("#img_base").attr("src","images/base.jpg")
	contenedor.hide();
	$.post(url,function(rs){
		contenedor.html(rs);
		contenedor.show();
                $.Log("Cargando.. (OK)",{clear:true});
	});
}
$.Imprimir = function(titulo){
	var html = "<center><table border=0 ><tr><td><img src='images/cabecera_impresion.png'/><br /></td></tr><tr><td>"+$("#foto_g").html()+"</td></tr>"+$("#contenido_pop").html()+"</center>" ;
	var imprimir = window.open('','IMPRIMIR','width=auto,height=620,left=200,top=100,menubar=1,resizable=1,width=650,scrollbars=1');
	imprimir.document.write('<html><head><title>'+titulo+'</title></head><body style="color:#666;font-family:arial;font-size:10px" onload="window.print();">'+html+'</body></html>');
	imprimir.document.close();
	imprimir.focus();
	$.Log("Imprimiendo",{clear:true});
}
$.VerFoto = function(foto){
	$("#foto_auto").fadeOut().attr("src","images/autos/"+foto).fadeIn();
}
/*
$.Datos = function(auto){
	$.post("cotizacion_autos.php",{auto:auto},function(html){
		$("#conte_auto").html(html);
		$.Log("Mostrando detalle",{clear:true})
	})
	
}*/