// 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',
  'imgpop',
  'equalizeheights',
  'x/innerfade',

  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');

     //innerfade
      $('.home .pgmarquee .thumbsview').innerfade({
        animationtype: 'fade',
        speed: 2000,
        timeout: 6000,
        type: 'sequence',
        containerheight: '367px'
      });
      
      //disable click event
      $('.home .pgmarquee .thumbsview a').click(function() {
         return false;
      });
      
      //capture today's date and inject it into menu boxhead
      dateToday = $('.home .datetoday').text();
      $('.home .menu .boxhead').text(dateToday);
      $('.home .datetoday').remove();

    } // 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();
        
    //Media Gallery
    $('.imagelist a:has(img)')
        .each(function() {
          var imgsrc = $(this).find('img').attr('src').replace(/\/[^\/]+\/([^\/]+)$/, '/large/$1');
          $(this).attr('href', imgsrc)
        }) 
        .imgPopper({
            curtainColor : '#ffffff',
            curtainOpacity : '0.75'
          });
          

    //Date splitter
    $('.articlelist.mats-vikunnar').Req(
        'http://codecentre.eplica.is/jquery/quickies/quicky-alistdatesplit-min.js',
        function() {
          $(this).alistDateSplit({ shortMonths: 1, monthAfterDate: 1 });
          $('.y').remove();
        }
      );
        
    //init videolist script
        $('.videolist').Req(
            'http://codecentre.eplica.is/jquery/quickies/quicky-videoplayer-min.js',
            function() {
              $(this).videoList({ 
                  vidWidth: 550,
                  vidHeight: 335,
                  autostart: 'all',
                  defaultImg: ''
                });
            }
          );
            
    //Mediagallery float clearing        
     $('.mediagallery li:nth-child(4n+1)').addClass('clearleft');  

    //Mediagallery thumbnails delete count in album 
     $('.mediagallery .count').each(function() {
        splitter = $(this).text().split(' ');
        $(this).text(splitter[0]);
     });
     
    //Equalizeheights
     $('.pgextra2 .menu, .home .pgmain .articlelist').equalizeHeights();

  }
);
// **** /jqreq *****

