

$(document).ready(function(){
                
    //global
    // Pfeile vor die Footer Navigation
    $('#footer .menu .menu-item').prepend('<span>&rsaquo;&nbsp;</span>');
                
    //var text = $(".searchparam.blog").text().replace("Blog", "artundweise-Blog");     
      
    //$(".searchparam.blog").text(text);
                
    //global End
                
                
    //artundweise
    if ($('body#artundweise').length != 0) {
        var offsetPos = $('#artundweise.page-template-start-php #header').offset();
        var width = $('#artundweise.page-template-start-php #header').width();
        var widthContent = $("#artundweise.page-template-start-php #content").width();
                
        var newPosition = (offsetPos.left + width - widthContent -60);
        $("#artundweise.page-template-start-php #content").css( {
            "left": newPosition + "px"
        } );
        $("#artundweise.page-template-start-php #content").show();
                                
                                
                                
        // Border unter dem letzten Presselisteneintrag entfernen
        $("#nav-below").prev().css('border', 'none');

        // Clear nach Widgets einsetzen
        $(".widget-container").append('<br class="clear" />');
        
        if(navigator.platform == 'iPhone' || navigator.platform == 'iPod')
        {
            $("#artundweise.page-template-start-php #content").css('width', '860px');
            $("#artundweise.page-template-start-php #content").css('left', '30px');
            $("#artundweise.page-template-start-php #content .entry-content").css('font-size', '12px');
            $("#artundweise.page-template-start-php #content .entry-content").css('line-height', '13px');
           
            
        }
                                
                                
    }
    //artundweise End
                
    // Agentur
    if ($('body#agentur').length != 0) {
        /*
                                var agenturContainerHeight = $('#agentur #container').height();
                                var agenturPrimaryHeight = $('#agentur #primary').height() + 118;
                                if(agenturContainerHeight >= agenturPrimaryHeight){
                                        $('#agentur #primary').height(agenturContainerHeight);
                                } else {
                                        $('#agentur #content').height(agenturPrimaryHeight) + 118;
                                }
                    */
                                
        $('#container').scale9Grid({
            top:10,
            bottom:10,
            left:15,
            right:10
        });
                                
                                
        // Pipes vor die Referenzen Filter Navigation
        $('#menu-referenzen li').append('<span>|</span>');
        $('#menu-referenzen li span').last().hide();
        $('#menu-referenzen').show();
                                
        var documentHeight = $(document).height();
        $('#top-theme-footer').css("top", documentHeight - 51);
                                     
                                
        //stick the footer at the bottom of the page if we're on an iPad/iPhone due to viewport/page bugs in mobile webkit
        if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod')
        {
            var el = $('#primary .menu-header'),
            top_offset = $('#main').offset().top;

            $(window).scroll(function() {
              var scroll_top = $(window).scrollTop();

              if (scroll_top > top_offset) {
                el.css('top', scroll_top - top_offset +80);
              }
              else {
                el.css('top', '');
              }
            });
        };
        
                                
                                
                                
    }
    //Agentur End
                
                
    //Blog
    if ($('body#blog').length != 0) {
        // Pfeile vor die Blogroll Navigation
        $('ul.xoxo.blogroll a').prepend('<span>&rsaquo;&nbsp;</span>');
    }
    //Blog End
                
    // Publishing
    if ($('body#publishing').length != 0) {
                                
        //global variable, this will store the highest height value
        var maxHeight = 0;
                                 
        function setHeight(col) {
            //Get all the element with class = col
            col = $(".sidebar-header");
                                     
            //Loop all the col
            col.each(function() {       
                                     
                //Store the highest value
                if($(this).height() > maxHeight) {
                    maxHeight = $(this).height();;
                }
            });
                                     
            //Set the height
            col.height(maxHeight);
        }

        setHeight('.sidebar-header');
        $(".sidebar-header").show();
                                
                                
        // navi-container highlighten
        $(".current-menu-item,.current-page-ancestor").parents(".nav-container").addClass("current");
        
        
        
        $('#top-slide-up-wrapper.on-first-load').animate({height: "50"}).removeClass("on-first-load").addClass("small");
        
        


        
        
        
        
        $('#top-slide-up-wrapper').click(function() {
            
          if($(this).hasClass("small")){
          $(this).animate({
            height: '340'
          }, 2000, function() {
            // Animation complete.
            $(this).addClass("jetzt").removeClass("small");
          });
          
          
          } else {
              $(this).animate({
                  height: "50"
              }, 2000).addClass("small");
          }
          
        });
        
        
        
        /*im Tiny aus Images Background Images machen*/
        $(".page-template-image-liste-php .entry-content a").addClass("partner-image");
        $("a.partner-image img").each(function() {
            
            var imageSrc= "url(" + $(this).attr('src') +")";
            $(this).parent().css("background-image", imageSrc);
            $(this).hide();
            
        });

        

        
        
        
        
        
        
        /*
        $('#slide-up-wrapper.on-first-load').animate({height: "50"}).removeClass("on-first-load").addClass("small");
        $('#slide-up-wrapper').click(function() {
            
          if($(this).hasClass("small")){
          $(this).animate({
            height: '340'
          }, 2000, function() {
            // Animation complete.
            $(this).addClass("jetzt").removeClass("small");
          });
          
          
          } else {
              $(this).animate({
                  height: "50"
              }, 2000).addClass("small");
          }
          
        });
        */
        
        
        
       
                                
    }
//Publishing End
                


});

$(window).resize(function() {
    //artundweise
    if ($('body#artundweise').length != 0) {
        var offsetPos = $('#artundweise.page-template-start-php #header').offset();
        //console.log("Header Left Offset= " + offsetPos.left);
        var width = $('#artundweise.page-template-start-php #header').width();
        //console.log("Header width= " + width);
        var widthContent = $("#artundweise.page-template-start-php #content").width();
        //console.log("Content width= " + widthContent);
        var newPosition = (offsetPos.left + width - widthContent -60);
        $("#artundweise.page-template-start-php #content").css( {
            "left": newPosition + "px"
        } );
    //console.log("newPosition= " + newPosition);
    }
    //artunweise End
                
                
    if ($('body#agentur').length != 0) {
                                
        //$('#top-theme-footer').css("top", documentHeight - 70);
        $('#top-theme-footer').css("top", "0");
        var documentHeightResize = $(document).height();
        $('#top-theme-footer').css("top", documentHeightResize - 51);
        
        
        
                   
    }
                

});
