$(document).ready(function(){
  move();
  var window = $(document).height();
  var all = $("#main").height();
  var height = window/2-(all/2+100);
  if(height > 100)  $("#all").css("top",height);

  $("#main").fadeIn("slow");
  $("#main span.twitterlink").hover(function() {
    $("#main span.content").show("slow");
  });
  
  $("#main").mouseleave(function() {
   $("#main span.content").slideUp("fast");     
  });

  $("#all").hover(function() {
    hideOthers(0);
    $('#unten div .title').css("background","#181818");
	  $('#unten div .title').css("margin-top","0px");
    $('#unten div .title').css("height","1.6em");
    $("#unten").css("height",16);
  });
  $('a.extern').attr('target', '_blank');

  var animating = false;

  $('#unten div.upper').each(function() {
    $(".title",this).hover(function () {
      if(animating == false) {
        animating = true;
	  	  var id = $(this).parent().attr("id");
	  	  hideOthers(id);
	  	  $('#unten div .title').css("background","#181818");
 	    	$('#unten div .title').css("margin-top","0px");
 	  	  $('#unten div .title').css("height","1.6em");
	  	  $(this).css("background","url(menu.png) bottom");
	  	  $(this).css("margin-top","1px");
	  	  $(this).css("height","1.4em");
	  	  $('#unten').css('height',130);
	  	  var div = $(this).parent().children('.inhalt');
 	      div.show("slow",function(){
   	      animating = false;
	      });
 	    }
	  });
  });

  $('#videos').hover(function(){
    $('#videos').css("width","200px");
  });

  function hideOthers(element) {
	  $("#unten div.upper").each(function() {
  	  if(element == "info") {
  	 	  $("#alex").fadeIn("slow");
  	   }
  	   else {
  	 	   if(element == 0) var veloc = element;
  	 	   else veloc = 600;
  	 	   $("#alex").fadeOut(veloc);
  	   }
	     var id = $(this).attr("id");
  	   if(id != element) {
  	 	   $(this).children('.inhalt').hide();
  	   }
    });
  }
	   
  function move() {
	  $("#back").animate({"background-position-x": "+=1px"}, 50,
	  function() {
	    move();
	  });
  }
});

