// encoding: utf-8
/*@cc_on/*@if(@_jscript_version<5.7)try{document.execCommand('BackgroundImageCache',0,1)}catch(e){}/*@end@*/

// ***** jqreq *****
Req(
  'fontsizer',
  'autovalidate',
  'labelizor',
  'x/ifixpng',
  'imgpop',
  function(){
    var $ = jQuery;
    
    // labelize search input
    $('#qstr').labelizor();
    
    if (!window.EPLICA_loggedin) {
    
      // pngfix for IE6
      if ($.browser.msie && $.browser.version < 7) {
        $('img[src$=".png"]').ifixpng();
      }
      
      //zebra tables
      $('div.article table tr:even').addClass('alt');
    }
    
    //remove flicker trick
    $('#noflickerCSS').remove();

    // fontsizer
    $('div.pagestyle').fontsizer();

    // validate all forms
    $('form').autoValidate();

    // imgpopper
    $('.map a').imgPopper();
  
  
    if(window.EPLICA_loggedin)
    {
    
      EPLICA.inlineEditor.addEvent('Save', function (e) {
        var editElm = $(e.target);
        if (e.targetType == 'html')
        {
          // footnotes
          var heimildir = $('.heimild', editElm);
          var index = 1;
          
          if(heimildir.length)
          {
            if(!$('ol.footnotes', editElm).length)
            {
              editElm
                  .append('<h3 class="heimildir">Heimildir</h3><ol class="footnotes"></ol>');
            }
            else
            {
              index = parseInt($('ol.footnotes li', editElm).length, 10) + 1;
            }
            
            heimildir.each(function(){
              
              $('ol.footnotes', editElm)
                .append('<li id="fn' + index +'">' + $(this).html() + '</li>');
                
              $(this)
                  .after('<a class="footnote" href="#fn'+ index +'">['+ index +']</a>')
                  .remove();
                  
              index++;
              
            });
          }
        }
      });
    }
  
  }
);
// **** /jqreq *****


