
$(document).ready(function() {


if ($("#zusatzstoffe").length < 1 ) $('body').append('<div id="zusatzstoffe" style="position:absolute;top:0;left:0;display:none;">&nbsp;</div>');

  $('.burger_summary sup').live('mousemove', function(event) {


    // Page variables. NOTE: These are the ones
    // that are officially supported by the
    // jQuery Event object.
    var x = event.pageX;
    var y= event.pageY;



    $("#zusatzstoffe").css('left',x+20);
    $("#zusatzstoffe").css('top',y-120);
    $("#zusatzstoffe").fadeIn(500);
  }

  );




  $('.burger_summary sup').live('mouseleave', function(event) {
    $("#zusatzstoffe").fadeOut();
  });

  if ($("#burger_gallery .current").length>0){
    $.current_id = $("#burger_gallery .current").attr("id").split("_")[1];
    $('#subnavigation td a.element_'+$.current_id).css('background','#c8000b');
    $('#subnavigation td a.element_'+$.current_id).css('color','#ffa500');
  }

  Cufon.replace('.burger_summary h1,.top h1,.top h3,.textcontainer>a>h1,#textfeld h1,.csc-header',{fontFamily: 'Eurostile'});
  Cufon.replace('.bottom a',{fontFamily: 'Eurostile'});
  Cufon.replace('#accordion h3',{hover: 'false',fontFamily: 'Eurostile'});
  Cufon.replace('#navigation>ul>li>a',{hover: 'true',fontFamily: 'TrixieCyr'});




  $("#accordion > li:not(.pano)").hover(function(){

    if(false == $(this).next().is(':visible')) {
      $('#accordion > ul').slideUp(300);
    }
    $(this).next().slideDown(300);
    $(this).css('height','28px');
    $("#accordion > li").css('height','32px');
  });


  $("#accordion li:not(.pano)").click(function(){
    //$("#container_location").css("background","url(/fileadmin/images/jim-block-2010/restaurant_b.jpg)");

    $.ajaxSetup ({cache: false });
    var loadUrl = "index.php?eID=restaurant&ort="+$(this).attr("name");
    $("#container_location").fadeOut(500,function(){
      $("#container_location").css("background","url("+$("#cb_media").attr("src")+")");
      $("#container_location").fadeIn(500);});
      $("#news").fadeOut(200);

      $("#loader").fadeIn(200);
      $("#container_location_content").fadeOut(500,function(){
        $("#container_location_content").load(loadUrl,function(){
          $('#accordion > ul').slideUp(800);
          $("#container_location_content").fadeIn(500);
          $("#loader").fadeOut(500);
        });
      });
  });

  // Funktion zum Einblenden des nächsten Burgers
  //$("#next_button").live('click', function() {

  $("#previous_button").click(function(event) {
    $.current_id = $("#burger_gallery .current").attr("id").split("_")[1];
    $.current_pid = $("#burger_gallery .current").attr("name").split("_")[1];


    $.elem = $(this);
    $.elem.fadeOut(1);
    // Animation
    $("div.current").animate({"left": "+=889px"}, "slow");

    $("div.next").animate({"left": "+=889px"}, "slow", function() {
      // Animation complete.
      if(typeof $("#burger_gallery .current").next().attr("id") == 'undefined') {
        $("#burger_gallery .current").removeClass("current").addClass("previous");
        $("#burger_gallery div").first().removeClass("previous").addClass("current");
      }
      else {
        $("#burger_gallery .current").removeClass("current").addClass("previous");
        $("#burger_gallery .next").removeClass("next").addClass("current");
      }
      $("#burger_gallery .current").prev().prev().remove();

      $.current_id = $("#burger_gallery .current").attr("id").split("_")[1];
      $.current_pid = $("#burger_gallery .current").attr("name").split("_")[1];

      $.get("index.php?eID=products&current_id=" + $.current_id + "&current_pid=" + $.current_pid + "&direction=1&page=", function(data) {
        $("#burger_gallery .current").after(data);
        //alert(data + " nachladen");
      });
      $.elem.fadeIn(1);

      $('#subnavigation td a').css('background','transparent');
      $('#subnavigation td a').css('color','#ff7900');
      $('#subnavigation td a.element_'+$.current_id).css('background','#c8000b');
      $('#subnavigation td a.element_'+$.current_id).css('background','#c8000b');
      $('#subnavigation td a.element_'+$.current_id).css('color','#ffa500');


    });

    event.stopImmediatePropagation();
  });

  // Funktion zum Einblenden des vorherigen Burgers
  $("#next_button").click(function(event) {
    $.current_id = $("#burger_gallery .current").attr("id").split("_")[1];
    $.current_pid = $("#burger_gallery .current").attr("name").split("_")[1];

    $.elem = $(this);
    $.elem.fadeOut(1);
    // Animation
    $("div.previous").animate({"left": "-=889px"}, "slow");
    $("div.current").animate({"left": "-=889px"}, "slow", function() {
      // Animation complete.
      if(typeof $("#burger_gallery .current").prev().attr("id") == 'undefined') {
        $("#burger_gallery .current").removeClass("current").addClass("next");
        $("#burger_gallery div").last().removeClass("next").addClass("current");
      }
      else {
        $("#burger_gallery .current").removeClass("current").addClass("next");
        $("#burger_gallery .previous").removeClass("previous").addClass("current");
      }
      $("#burger_gallery .current").next().next().remove();
      $.current_id = $("#burger_gallery .current").attr("id").split("_")[1];
      $.current_pid = $("#burger_gallery .current").attr("name").split("_")[1];

      $.get("index.php?eID=products&current_id=" + $.current_id + "&current_pid=" + $.current_pid + "&direction=-1&page=", function(data) {
        $("#burger_gallery .current").before(data);
        //alert(data + "nachladen");
      });

      $.elem.fadeIn(1);
      $('#subnavigation td a').css('background','transparent');
      $('#subnavigation td a').css('color','#ff7900');

      $('#subnavigation td a.element_'+$.current_id).css('background','#c8000b');
      $('#subnavigation td a.element_'+$.current_id).css('color','#ffa500');
    });

    event.stopImmediatePropagation();
  });


  //$(".widget .middle").delay(1000).slideDown(500);
  //$(".widget .middle").show(500);
  $(".widget .middle").fadeIn(500);


  $('#accordion > ul').hide();
  //$('#accordion > ul:eq(0)').show();

});



