jQuery(document).ready(function() {
  
  //var content_height = jQuery("div.content_wrapper").height();
  //jQuery("div.content_wrapper").css({"height" : content_height+"px"});
  
  
  
  jQuery("div.navi a:eq(0)").attr('href','start.html');  
  
   jQuery(document).ready(function(){ 
        jQuery("ul.sf-menu2").superfish(); 
    });  
  
  jQuery("ul.sf-menu2-submenu:first").css("margin-top","-10px");
     
   var max_height = 0;  
    jQuery('.autoheight').each(function(e) {  
      h = jQuery(this).height();  
        if(typeof(h) != "undefined") {  
            if(h > max_height) {  
                max_height = h;  
          }  
      }  
});
 
if(max_height > 0) {  
 jQuery('.autoheight').height(max_height+100);  
}  

  
  var act_url = document.URL;

  if(act_url == "http://www.typo3-online.eu/") {
    jQuery("div.navi a:first").attr('class','active');
  }
  
  if(act_url == "http://www.typo3-online.eu/kontakt.html" || act_url == "http://www.andre-lanius.de/kontakt.html" || act_url == "http://www.andre-lanius.com/contact.html") {
    jQuery('html, body').animate({scrollTop:450}, 'slow');
    jQuery("img[src='uploads/pics/hand_feder.gif']").css({
      "margin-right" : "20px",
      "margin-top" : "30px",
    });
    jQuery("div.csc-textpic-text:first").css({
      "margin-left" : "45px",
      "padding-top" : "30px"
    });
    
  }

  
  
  var right_column = jQuery("div.right_inner").html();
  if(right_column == "") {
    jQuery("div.right_column").hide();
    jQuery("div.middle_column").css({"width" : "730px"});
  }
  
  jQuery("div.tx_powermail_pi1_fieldwrap_html_file:first").css({
    "margin-bottom" : "20px"
  });
  
  jQuery("div.tx_powermail_pi1_fieldwrap_html_file:last").css({
    "padding" : "4px",
    "background" : "#ffffff",
    "border" : "1px #585858 dashed",
    "margin-bottom" : "20px"
  });
  
  
  jQuery(".easy-accordion-orange dt:eq(0)").append('<div style="position:absolute; top:20px; left:35px;"><img width="30" height="30" src="fileadmin/templates/img/typo3.png" border="0" alt="TYPO3" /></div>');
  jQuery(".easy-accordion-orange dt:eq(1)").append('<div style="position:absolute; top:20px; left:35px;"><img width="30" height="30" src="fileadmin/templates/img/magento.png" border="0" alt="Magento" /></div>');
  jQuery(".easy-accordion-orange dt:eq(2)").append('<div style="position:absolute; top:20px; left:35px;"><img width="30" height="30" src="fileadmin/templates/img/xt-commerce-icon.png" border="0" alt="xt:Commerce" /></div>');
  
  
  jQuery("div.navi a").each(function(index) {
    var link_text = jQuery(this).text();
       if(link_text == "Referenzen") {
         jQuery(this).attr('target','_blank');
       }
       
  });
  
  
  
  
      /*
       * Seiten-Inhalte dynamisch nachladen
       */
       //Auf den ggf. übermittelten Anker reagieren
        if(location.hash) {
                jQuery("div.content").hide();
                jQuery('html, body').animate({scrollTop:450}, 'slow');
                x = location.hash;
                getContent(x.slice(1)+".html");
        }
      jQuery("div.navi a, div.subnavi ul.subnavi a, div.footerlinks a").click(function() {

                if($(this).attr('href') == "referenzen.html") {
                
                }else{
                jQuery("div.pagebrowser").hide();
                jQuery("div.footerlinks a").attr('class','');
                jQuery('html, body').animate({scrollTop:450}, 'slow');
                url = jQuery(this).attr("href");  
                getContent(url);
                jQuery(this).blur();
                return false;
                }
      });
  
  jQuery("div.navi a, div.subnavi ul.subnavi a").click(function() {
      jQuery("div.navi a").css("color","#555555");
      jQuery("div.subnavi ul.subnavi a").css("color","#555555");
      jQuery(this).css("color","#bb2b35");
      if(jQuery(this).hasClass('level_2')) {
         jQuery(this).parents("ul").prev("a").css("color","#bb2b35");
      }
  });
  
  //Slide-Toggle für Subnavi
  jQuery("ul.subnavi_level2").hide();
  jQuery("a.level_1").click(function() {
    if(jQuery(this).next().is(":hidden")) { 
       jQuery("ul.subnavi_level2").slideUp('slow', function() {
           
       });  
       jQuery(this).next().slideDown('slow', function() {
             // Animation complete.
         }); 
    } //if
  });
  
  /*
      jQuery("div.content").delegate("a", "click", function(){
           jQuery("div.footerlinks a").attr('class','');
               jQuery('html, body').animate({scrollTop:450}, 'slow');
                url = jQuery(this).attr("href");
                getContent(url);
                jQuery(this).blur();
                return false;
    });
*/
  
  
  
      jQuery("div.footerlinks a").click(function() {
          jQuery("div.navi a").css("color","#555555");
          jQuery("div.subnavi ul.subnavi a").css("color","#555555");
          jQuery("div.footerlinks a").attr('class','');
          jQuery("div.footerlinks a").attr('class','inactive');  
          jQuery(this).attr('class','active');         
      });
  
  
      //Informieren das etwas passiert
        jQuery("div.content").ajaxStart(function() {
                jQuery(this).fadeOut(function() {
                        jQuery(this)
                                .text("Seite wird geladen ...")
                                .addClass("loading")
                                .fadeIn();
                });
        });
   
  
  
});






function getContent(url) {
        jQuery.ajax({
        //erweitere aufzurufenden Link
        url: url.replace(/\.html/, "/ajax.html"),
        //wenn es geklappt hat
        success: function(html) {
                //Inhalt reinschreiben und anzeigen
                jQuery("div.content")
                        .removeClass("loading")
                        .css("display", "none")
                        .html(html)
                        .fadeIn();
                //Adresszeile aktualisieren
                location.hash = url.replace(/\.html/, "");
                
              var h = jQuery("div.content").height();
              jQuery("div.middle_column").height(h+100);
              jQuery("div.left_column").height(h+100);
              //Title-Tag setzen
              var titletag = jQuery("img.titletag").attr('title');
              jQuery('title').replaceWith('<title>'+titletag+'</title>');
        }
        });
}

