$(function() {
  $('a[rel*=facebox]').click(function() {
    var title = $('img', this).attr('title');
    var html = '<img src="' + this.href + '" width="640" height="480" alt="' + title + '" title="' + title + '"/><br/><br/>';
    html += title;
    $.facebox(html);
    return false;
  });

  function price(n) {
    return n.toFixed(2).replace(/\./, ',') + ' EUR';
  }
  $('.amount').jStepper({
    minValue: 0,
    maxValue: 99
  }).keyup(function() {
    var $this = $(this), count = $this.val(), table = $this.parents('table.preise')[0], id = table.id;

    var fahrstundenpreis = fahrstunde[id]*count;
    var text = fahrstunde[id]*count;
    $('.fahrstundenpreis', table).html(price(text));
    $('.gesamtpreis', table).html(price(fahrstundenpreis+fixkosten[id]));
  }).change(function() {
    var $this = $(this), count = $this.val(), table = $this.parents('table.preise')[0], id = table.id;
    _gaq.push(['_trackEvent', 'Fahrstundenanzahl', id, count]);
  });
});

