$(document).ready(function () {
  /* frontpage functions */
  if (window.location.pathname == '/') {
    $("#navigation > ul > li:first").addClass('current_page_item');
    $('#sidebar .widget:first').addClass('noBg');
    $('#navigation .page-item-51').removeClass('current_page_parent'); 
  } else {
  /* external favicons */
  $('#content a[href^="http://"]:not(.no_favicon)').filter(function(){
      return this.hostname && this.hostname !== location.hostname;
   }).each(function() {
     if ($(this).text() == '#') return;
     var link = $(this);
     var faviconURL =
       link.attr('href').replace(/^(http:\/\/[^\/]+).*$/, '$1')+'/favicon.ico';
     var faviconIMG = $('<img src="/wp-content/uploads/2009/08/icon_external.gif" alt="" class="favicon" />')['appendTo'](link);
     var extImg = new Image();
     extImg.src = faviconURL;
     if (extImg.complete)
       faviconIMG.attr('src', faviconURL);
     else
       extImg.onload = function() { faviconIMG.attr('src', faviconURL); };
   });
  }
  
  /* DIN font headlines */
  var fontDinMedium = new Font('din_regular.swf', {tags:'h2,h3,h4'}); 
  fontDinMedium.replace();

  /* thumbs */
  $('.ngg-widget img').each(function () {
    $(this).css('margin-right', '22px');
  });

  /* searchbox */
  $('#search input').click(function () {
    if ($('#search input').attr('value') == 'SUCHE') {
      $('#search input').attr('value', '');
    }
  });

  $("form[action$='wp-pass.php'] input[type='password']").addClass('styledInput');
  $("form[action$='wp-pass.php'] input[type='submit']").addClass('styledButton');

  /* own comments */
  $(".commentbody a.url[href='http://www.andreas-demmer.de']").parent().addClass('own_comment');
});
