function addBasket(type,id)
{
  $(".box3 div").load('/scripts/add_basket.php',{'type':type,'id':id});
}


jQuery.fn.extend({
	clearFieldOnFocus: function() {
		return this.each(function() { 
			if ( ($(this).attr('title') != undefined) && ($(this).val() == '') )
      {
        $(this).attr('value', $(this).attr('title'));
        $(this).addClass('filled');
      }
			$(this).focus(function() {$(this).removeClass('filled'); if($(this).attr('value') == $(this).attr('title')) $(this).attr('value', ''); });
			$(this).blur(function() { if($(this).attr('value') == '') {$(this).attr('value', $(this).attr('title')); $(this).addClass('filled');} });
		});
	}
});

$(function() {
  $('input.autoFill').clearFieldOnFocus();
  $('body').noContext();
  
  $('.tip').each( function() {
			var c = $(this).attr('rel');						 
			$(this).simpletip({content: c, position: 'bottom', offset: [100,0], boundryCheck: true, fixed: true, showEffect: 'fade'});});
  });

function format(valeur,decimal,separateur)
{
  var deci=Math.round( Math.pow(10,decimal)*(Math.abs(valeur)-Math.floor(Math.abs(valeur)))) ;
  var val=Math.floor(Math.abs(valeur));
  if ((decimal==0)||(deci==Math.pow(10,decimal))) {val=Math.floor(Math.abs(valeur)); deci=0;}
  var val_format=val+"";
  var nb=val_format.length;
  for (var i=1;i<4;i++)
  {
    if (val>=Math.pow(10,(3*i)))
      val_format=val_format.substring(0,nb-(3*i))+separateur+val_format.substring(nb-(3*i));
  }
  if (decimal>0)
  {
    var decim="";
    for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
    deci=decim+deci.toString();
    val_format=val_format+"."+deci;
  }
  if (parseFloat(valeur)<0) {val_format="-"+val_format;}
  return val_format;
}
