$(document).ready(function() {
  $.fragmentChange(true);
  $(".to_page_1").hide();
  $(document).bind("fragmentChange.page", function() {
    $(".project_details").css( "margin-left", "0px" );
    $(".navigation_item").each(function() {
      $(this).css( "background-image", "url(/images/....jpg)" );
      $(".content", this).slideUp( 400 );
      classname = $(this).attr("class").replace("navigation_item ","");
    });
    $(".navigation_item." + $.fragment().page ).css( "background-image", "url(/images/"+$.fragment().page+".jpg)" );
    $(".navigation_item." + $.fragment().page + " .content" ).slideDown( 500 );
  });
  if ($.fragment().page) {  
    $(document).trigger("fragmentChange.page");  
   } else {  
    $(".home .content").slideDown( 700 );
    $(".home").css( "background-image", "url(/images/home.jpg)" );
    $.setFragment( "" );
  }
  $(".navigation_item h2").click(function() {
    class_name = $(this).parent(".navigation_item").attr("class").replace("navigation_item ","").replace(" ","");
    if (class_name == "home") {
      $(".navigation_item .content").slideUp( 400 );
    	$(".news").css( "margin-left", "758px" );
      $(".home .content").slideDown( 700 );
      $(".navigation_item").css( "background-image", "url(/images/....jpg)" );
      $(".home").css( "background-image", "url(/images/home.jpg)" );
      $.fragmentChange(false);
      $.setFragment( "" );
      $.fragmentChange(true);
    } else {
      $.setFragment( { page : class_name } );
    }
    return false;
  });
  $(".project_list h4, .project_list_2 h4").click(function() {
    $(".project_details ."+$(this).attr("class")).animate({ marginLeft: "0px"}, 500 );
    return false;
  });
  $(".projects h2").click(function() {
    $(".project_details .project").css( "margin-left", "758px" );
    return false;
  });
  $(".to_page_2").click(function() {
    $(".project_list_2").animate({ marginLeft: "0px"}, 500 );
    $(".to_page_2").fadeOut();
    $(".to_page_1").fadeIn();
    return false;
  });
  $(".to_page_1").click(function() {
    $(".project_list_2").animate({ marginLeft: "737px"}, 500 );
    $(".to_page_1").fadeOut();
    $(".to_page_2").fadeIn();
    return false;
  });
  $(".project .close").click(function() {
    $(".project_details .project").animate({ marginLeft: "758px"}, 300 );
    return false;
  });
  $(".toggle_imprint, #imprint .close").click(function() {
    $("#imprint").toggle();
    return false;
  });  
  
  $(".get_news").click(function() {
    $(".news:first").animate({ marginLeft: "0px"}, 500 );
    return false;
  });
  $(".news .close").click(function() {
    $(".news_details .news").animate({ marginLeft: "758px"}, 300 );
    return false;
  });
});