// encoding: utf-8
/*@cc_on/*@if(@_jscript_version<5.7)try{document.execCommand('BackgroundImageCache',0,1)}catch(e){}/*@end@*/

// ***** jqreq *****
Req.localPath = Req.localPath || '/skin/basic/'
Req(
  'eutils',
  'fontsizer',
  'autovalidate',
  'labelizor',
  'listscroller',
  'imgpop',
  'mailtoenabler',
  'http://codecentre.eplica.is/jquery/quickies/quicky-alistdatesplit.js',


  function(){
    var $ = jQuery;

    // labelize search input
    $('#qstr').labelizor();

    if (!window.EPLICA_loggedin)
    {

      // pngfix for IE6
      if ($.browser.msie && $.browser.version < 7) {
        $('img[src$=".png"]').Req('x/ifixpng', function(){
            $(this).ifixpng();
          });
      }

      //zebra tables
      $('tbody tr:nth-child(2n-1)').addClass('odd');
      //$('tbody tr:nth-child(2n)').addClass('even');


      //popup in articles
      $('.article .imagebox a.img')
          .each(function() {
            var imgsrc = $(this).find('img').attr('src').replace(/\/[^\/]+\/([^\/]+)$/, '/large/$1');
            $(this).attr('href', imgsrc)
          })
          .imgPopper({
              curtainColor : '#ffffff',
              curtainOpacity : '0.75',
              yOffset: 15
            });
            
      //listscroller on main page
      $('.listscroller')
            .listscroller({
              animation:        'crossfade',
              autoScrollDelay:  4000,
              item:             '.item',
              jumpPager:        'true',
              paging:           'true',
              stepSize:         1,
              startPos:         0,
              windowSize:       1
            })
            .find('.item').each(function () {
                $(this).find('h3, .summary').wrapAll('<div class="contentwrap" />');
              });
      
      //alistdates
      $('.home .articlelist')
          .alistDateSplit({
              skortMonths: 1, 
              monthAfterDate: 1
            });
            
      //mailtoenabler
      $('.netfang').mailtoEnabler();
      


    } // end loggedin

    //sitemap collapser
    $('.sitemap').Req('treecollapse', function() { 
        $(this).treeCollapse({ 
            branch: 'li:has(ul)', 
            doTogglers: 1, 
            toggler: '> a.expand',
            startOpen: 'ul.level1 > li:has(ul)'
          }); 
        });

    //remove flicker trick
    $('#noflickerCSS').remove();

    // fontsizer
    $('.pagestyle').fontsizer();

    // validate all forms
    $('form').autoValidate();


  }
);
// **** /jqreq *****

