(function($) {

  if (!window.EPLICA_loggedin) {
  
    $('div.pgmain div.wrap, div.pgextra2 div.wrap').equalizeHeights();

    $('div.pgmain div.article div.boxbody:first, div.pgmain div.articlelist div.boxbody:first').prepend('<div class="fontsizer"><span class="title">Leturstærð</span><ul><li class="up"><a title="Stækka letrið" href="/bitar/c2/style/setStyleCookie.jsp?fontSize=1">+A</a></li><li class="dwn"><a title="Minnka letrið" href="/bitar/c2/style/setStyleCookie.jsp?fontSize=-1">-A</a></li></ul></div>');
    $('div.fontsizer').fontsizer();
    
    $('#qstr').labelizor();
    
    
    $('div.articlelist div.item img').wrap('<span class="imgouter"><span class="imginner"></span></span>');
    
    $('blockquote:not(.noquotes), p.pquote')
        .prepend('<span class="tq"></span>')
        .append('<span class="bq"></span>');
    

    
      // Add "send to facebook" link to articles
      $('p.buttons')
          .append(
            $('<a class="btnfacebook" href="#">Facebook</a>')
                .bind('click', function()  {
                    window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(document.location.href)+'&t='+encodeURIComponent($('h1').text()),'sharer','toolbar=0,status=0,width=626,height=436');
                    return false;
                  })
              );
    
    
    var yearindex = $('div.pgextra2 div.yearindex div.boxbody');
    
    if(yearindex.length) {
    
      yearindex
          .find('p')
              .wrap('<span></span>')
          .end()
          .accordion({
              header         : 'h4',
              selectedClass  : 'boxhead-open',
              animation      : 'easeInOut',
              autoHeight     : false
            });
      
      var thisuri = $.trim(document.location.href).replace('http://www.bjorn.is/','').split('/')[1];
      yearindex
          .find('h4 a').each(function() {
              if($(this).text() === thisuri) {
                $(this).trigger('click')
              }
            })
    }

          
          
      $('div.imgalbum ul a')
          .each(function(){
              var img = $(this).find('img')[0];
              this.href = img.src.replace(/\/[^\/]+\/([^\/]+)$/, '/gallery/$1');
              img.title = img.alt;
              img.alt = $(this).parent().find('p.imgtext').text();
            });
      $('div.imgalbum ul a').imgPopper();
            
            
    
    // pngfix for IE6
    if ($.browser.msie) {
      $('img[scr$=".png"]').ifixpng();
    }
    
    $('form').autoValidate();
  
  }
  
})(jQuery);