var flipped=0;
$(document).ready(function(){
var i = 0;
setInterval(function(){
  var anzahl = $("#header_index img").length;
  $("#header_index img").eq(i).fadeOut("slow");
  i++;
  if (i==(anzahl)) {
    i=0;
  }
  $("#header_index img").eq(i).fadeIn("slow");
  }, 5000);
$("#kontakt").click(function() {
  $("#kontakt div").slideDown("fast");
  $("#booking p,#fanpost p,#titelsuche p,#newsongs p").slideUp("fast");
});
$("#booking").click(function() {
  $("#booking p").slideDown("fast");
  $("#kontakt div,#fanpost p,#titelsuche p,#newsongs p").slideUp("fast");
});
$("#fanpost").click(function() {
  $("#fanpost p").slideDown("fast");
  $("#kontakt div,#booking p,#titelsuche p,#newsongs p").slideUp("fast");
});
$("#titelsuche").click(function() {
  $("#titelsuche p").slideDown("fast");
  $("#kontakt div,#booking p,#fanpost p,#newsongs p").slideUp("fast");
});

$("#gala").click(function() {
  $("#gala img").fadeToggle("slow");
});
var status=0;

setInterval(function(){
  var current = $("#slidebox p.active");
  
  var next = $(current).next();
  if (next.text() === "") {
    var next = $("#slidebox p.notactive:first");
  }
  $(current).css("zIndex","1");
  $(next).css("zIndex","10");
  $(next).animate({marginLeft: '0px'},"normal", function(){
    $(current).removeClass("active").addClass("notactive").css("margin-left","180px");
    $(next).removeClass("notactive").addClass("active");
    });
  }, 4000);
$("#pageflip").hover(function() { //On hover...
      flipped=1;
	    $("#pageflip img , .msg_block").stop()
		    .animate({ //Animate and expand the image and the msg_block (Width + height)
			  width: '500px',
			  height: '493px'
		    }, 500);
	    } , function() {
	  $("#pageflip img").stop() //On hover out, go back to original size 50x52
		  .animate({
			  width: '50px',
			  height: '50px'
		  }, 220);
	  $(".msg_block").stop() //On hover out, go back to original size 50x50
		  .animate({
			  width: '50px',
			  height: '50px'
		  }, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
  });
      
}); 

pageflipper = setInterval("pageflip()",1800);
function pageflip() {
  if(flipped==0){
  $("#pageflip img , .msg_block").stop()
	  .animate({ //Animate and expand the image and the msg_block (Width + height)
		  width: '58px',
			height: '58px'
		  }, 200);
  setTimeout(function () {
    $("#pageflip img").stop()
	  .animate({ //Animate and expand the image and the msg_block (Width + height)
		  width: '50px',
			height: '50px'
		  }, 100);
    
   $(".msg_block").stop()
	  .animate({ //Animate and expand the image and the msg_block (Width + height)
		  width: '50px',
			height: '50px'
		  }, 100); } 
   , 300); }
}
