var last_product_id;
jQuery(function() {

	if(!tooltips)return;
	jQuery(".tt").tooltip({

	    bodyHandler: function() {
			ID = jQuery(this).attr("tt");
			getProductStock(ID, false);
			return '<b>Chargement en cours...</b>';
	    },

		track: true,
		delay: 450,
		showURL: false,
		fixPNG: false
	});
});

var ttTimeoutID;
function getProductStock(ID, exec)
{
	//jQuery('#tooltip').html('oki');

	if(last_product_id == ID)return;

	if(!exec)
	{
		ttTimeoutID = setTimeout("getProductStock(ID, true)", 2500); // 5s
		jQuery('#tooltip').html('<b>Chargement en cours...</b>');
	}
	else
	{
		//alert("load ajax content !");
		if(jQuery('#tooltip').is(":visible"))
		{
			last_product_id = ID;
			jQuery('#tooltip').load('/_tooltip_stock.srv.php?ID='+ID);
		}
		clearTimeout(ttTimeoutID);
	}
	
}