$("document").ready(function() {
   $(".thumb").live("click",function() {
      x = $(this).attr('id').substring(1).split("_");
      $("#i"+x[0]).attr('src',"http://media.elsiglodetorreon.com.mx/media/spacer.gif");
      $.getJSON("/index.php?i="+x[1],function(m) { $("#i"+x[0]).attr({'src': m[0], 'width': m[1], 'height': m[2], 'alt': 'imagen '+m[3] }); });
   });
   $(".theimage").live("click",function() {
      x = $(this).attr('alt').substring(7);
      $("#theimage DIV IMG").attr('src','/wait.gif'); $("#theimage").show();
      $.getJSON("/index.php?s=640&i="+x,function(m) { $("#theimage DIV IMG").attr({ 'src': m[0] }); });
   });
});
function togglefac() {
	if( $("#tablafactura").is(":visible") ) {
		$.post("/_cart.php", { fc : 'no' });
		$("#tablafactura").hide();
		$("#factura").html("requiero factura");
		$("#factura").removeClass("no").addClass("si");
		$('.enviofac').hide();
	} else {
		$.post("/_cart.php", { fc : 'si' });
		$("#tablafactura").show();
		$("#factura").html("no requiero factura");
		$("#factura").removeClass("si").addClass("no");		
		$('.enviofac').show();		
	}
}
/* ping */
var ping=0;
$(document).ready(function(){ var ping = setTimeout("uping()",1000*30); });
function uping() { try {	clearTimeout(ping); } catch(e) { } 
$.ajax({type:'POST',url: '/ping.php',data: 'ping=1', success: function(m) { ping = setTimeout("uping()",1000*30); }}); }
/*
 * Tooltip script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
this.tooltip = function(){        
        /* CONFIG */                
                xOffset = 10;
                yOffset = 20;                
                // these 2 variable determine popup's distance from the cursor
                // you might want to adjust to get the right result                
        /* END CONFIG */                
        $(".tooltip").hover(function(e){                                                                                          
                this.t = this.title;
                this.title = "";                                                                          
                $("body").append("<p id='tooltip'>"+ this.t +"</p>");
                $("#tooltip")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px")
                        .fadeIn("fast");                
    },
        function(){
                this.title = this.t;                
                $("#tooltip").remove();
    });        
        /*$(".tooltip").mousemove(function(e){
                $("#tooltip")
                        .css("top",(e.pageY - xOffset) + "px")
                        .css("left",(e.pageX + yOffset) + "px");
        });*/                        
};



// starting the script on page load
$(document).ready(function(){
        tooltip();
});

