/* ------------------------------------------------------------
   Diese Datei oder Teile davon dürfen nicht ohne ausdrückliche,
   schriftliche Genehmigung der i.de Internet-Dienstleistungen
   auf Seiten außerhalb der Domain http://www.ralph-mueller-wagner.de
   verwendet werden.

   (c) 2009 by Marko Thümmler, i.de Internet-Dienstleistungen
   alle Rechte vorbehalten
   ------------------------------------------------------------ */


$(document).ready(function(){
  $("noscript").hide(); // fixt Darstellungsfehler in Opera

  var site = location.search;
  site = site.substr(6); // entfernt ?view=

  switch(site) {
    case "js":
      fn_js();
      break;
    case "guestbook":
      fn_gb();
      break;
    case "samples":
      fn_slider();
      break;
    case "stories":
      fn_slider();
      break;
    case "news":
      fn_stories();
      break;
  }

  if(typeof slider != "undefined" && slider) fn_slider();

  function fn_gb() {
    var h = $(window).height();
    var w = $(window).width();
    h = Math.ceil(h/2);
    w = Math.ceil(w/2);

    $("#ajax_tb").attr({href: "/src/old_gb.htm?height=" + h + "&amp;width=" + w});
  }

  function fn_stories() {
    var h = $(window).height();
    var w = $(window).width();
    h = Math.ceil(h*0.8);
    w = Math.ceil(w*0.8);
    if (w > 600) w = 600;

    var number_of_links = $(".thickbox").length;
    for(i=0;i<number_of_links;i++) {
      var linktarget = $(".thickbox")[i].href + "?height=" + h + "&amp;width=" + w;
      $(".thickbox")[i].href = linktarget;
    }
  }

  function fn_slider() {
    $(".dynamic_container .innerdiv").hide();
    $(".dynamic_container h4").css("background","url('/css/img/label_open.png') bottom left no-repeat transparent");
    $(".dynamic_container h4").css("cursor","pointer");
    $(".dynamic_container h4").bind("click",function(){eyecandy(this);});
    $(".dynamic_container h4").bind("mouseover",function(){$(this).css("color","#F90");});
    $(".dynamic_container h4").bind("mouseout",function(){$(this).css("color","#EEE");});

    // in dynamic_container angesprungene Anker "aufklappen"
    if(location.hash) $(location.hash).click();
  }

  function eyecandy(source_element) {
    var element = "#" + source_element.id + " + .innerdiv";
    $(element).slideToggle("slow", function() {
      if ($("#" + source_element.id).css("backgroundImage") == "url(/css/img/label_open.png)") {
        $("#" + source_element.id).css("backgroundImage","url(/css/img/label_close.png)");
      }
      else $("#" + source_element.id).css("backgroundImage","url(/css/img/label_open.png)");
    });
  }


  function fn_js() {
    $("#BackButton").show().bind("click",function() {history.back();});
    $("#testjs").hide();
    $("#nojs").hide();
  }

  $(".isbn").click(function() {$("#sellers").click().scrollTop(10000);});

});

function format_interview() {
  $(".interview p:even").css({
    "margin-top":"2ex",
    "font-style":"italic",
  });
  $(".interview p:odd").css("background","url(/css/img/highlight.png)");
}

function init_home_blocks() {
  $("#content .dc").hide();
  $("#content h3")
  .css({
    "background-image" : "url('/css/img/label_open.png')",
    "background-position" : "bottom right",
    "background-repeat" : "no-repeat",
    "cursor" : "pointer"
    })
  .bind("click",function(){
    $(this).toggleClass("open").next().slideToggle("slow", function() {
      if($(this).prev().attr("class") == "open") $(this).prev().css("background-image","url('/css/img/label_close.png')");
      else $(this).prev().css("background-image","url('/css/img/label_open.png')");
    });
  })
  .bind("mouseout",function(){
    $(this).css("color","#F90");
  })
  .bind("mouseover",function(){
    $(this).css("color","#EEE");
  });

  if(location.hash) $(location.hash).click();
}

