// 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',
  'popups',

  function(){
    var $ = jQuery,
        body = $('body').addClass('js-active'),

        bVer =   parseInt( $.browser.version, 10 ),
        msie =   $.browser.msie   &&  bVer<9,  // or: $('html').is('.msie');
        msie7 =  msie  &&  bVer<8,
        msie6 =  msie  &&  bVer<7,
        msie67 = msie6 || msie7;



    // labelize search input
    $('#qstr').labelizor();

    //Equalize heights
    $('body:not(.onecol) .pagebody, .pageextra1').equalizeHeights();

    if (!window.EPLICA_loggedin)
    {

      // pngfix for IE6
      if (msie6)
      {
        $('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
            });


    } // 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();


    //video embed thingy
    var videoLink = $('a.video');
    if( msie67 ) {
        var opened = false;
        videoLink.click( function() {
            if(!opened) {
                opened = true;
                $(this)
                    .after('<object id="video" width="500" height="400" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8.0.0.0">' +
                              '<param name="movie" value="/media/flash/mediaplayer/mediaplayer.swf?file=' + videoLink.attr('href') + '&width=500&height=400&autostart=true&bufferlength=5" />' +
                              '<param name="wmode" value="transparent" />' +
                            '</object>'
                    )
                return false;
            } else {
                $('#video').remove();
                opened = false;
                return false;
            }
        })
    } else {
        videoLink.click( function() {
            menuWindow = window.open('/media/flash/mediaplayer/mediaplayer.swf?file=' + videoLink.attr('href') + '&width=500&height=400&autostart=true&bufferlength=5',"edit","toolbar=0,scrollbars=auto,location=0,status=0,menubar=0,width=500,height=400")
            setTimeout("menuWindow.focus();", 100);
            return false;
        });
    };
    
    //popup .popups
    $('.popup').popUps();
    

  }
);
// **** /jqreq *****

