// encoding: utf-8
/*@cc_on/*@if(@_jscript_version<5.7)try{document.execCommand('BackgroundImageCache',0,1)}catch(e){}/*@end@*/

Req.localPath = Req.localPath || '/skin/basic/';

// ***** jqreq *****
Req(
  'fontsizer',
  'autovalidate',
  'x/ifixpng',
  'x/innerfade',
  'imgpop',
  'popups',
  'equalizeheights',
  
  function(){
    var $ = jQuery;

    //remove flicker trick
    $('#noflickerCSS').remove();
    
    //dhtml mnav
    $('.mnav ul.level1 > li')
        .bind('mouseenter mouseleave', function (e) {
            var enter = e.type == 'mouseenter';
            $(this)
                .toggleClass('hovered', enter)
                .find('ul.level2')
                    .toggleClass('open', enter);
          });

    if (!window.EPLICA_loggedin)
    {
      
      $('.pgmain .wrap, .pgextra1 .wrap, .pgextra2 .wrap').equalizeHeights();
      $('body').addClass('heightfixed');

      // pngfix for IE6
      if ($.browser.msie && $.browser.version < 7) {
        $('img[src$=".png"]').ifixpng();
      }
      
      
      //popup in articles
      $('div.article div.imgbox a:has(img)')
          .each(function() {
              var imgsrc = $(this).find('img').attr('src').replace(/\/[^\/]+\/([^\/]+)$/, '/large/$1');
              $(this).attr('href', imgsrc)
            }) 
          .imgPopper({
              curtainColor : '#000000',
              curtainOpacity : '0.75'
            });
            
            
      $('a.video').each(function(i) {
          $(this).bind('click', function (e) {
              $('#video').remove();
              var href = $(this).attr('href');
              $(this).after('' +
                  '<p id="video"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8.0.0.0" width="540" height="346">' +
                  '<param name="movie" value="/bitar/common/media/mediaplayer.swf" /><param name="wmode" value="transparent" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" />' +
                  '<param name="flashVars" value="file=' + href + '&type=video&width=580&height=326&bufferlength=8&autostart=true" />' +
                  '<embed src="/bitar/common/media/mediaplayer.swf"' +
                  'flashVars="file=' + href + '&type=video&width=580&height=326&bufferlength=8&autostart=true"' +
                  'width="540" height="346" wmode="transparent" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />' +
                  '</object></p>' +
                '');
              return false;
            });
        });

    }
    
    $('.popup, .glossary')
        .popUps({
            target  : 'bigpopup',
            width   : 550,
            height  : 350,
            minimal : 1
          });
    
    $('.scrolladvert .boxbody')
        .addClass('scrolladvert-active')
        .find('ul')
            .innerfade({
                animationtype: 'fade',
                speed: 1000,
                timeout: 5000,
                type: 'sequence',
                containerheight: '4em'
              });
    
          

      
    // fontsizer
    $('div.pagestyle').fontsizer();

    // validate all forms
    $('form').autoValidate();
          
    //Facebook button injection        
    $('p.buttons')
        .each(function () {
            $('<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;
                  })
                .appendTo(this);
          });

  },

  Req.localPath+'js/konnun2010.js'
);
// **** /jqreq *****
