// encoding: utf-8
/*@cc_on/*@if(@_jscript_version<5.7)try{document.execCommand('BackgroundImageCache',0,1)}catch(e){}/*@end@*/

Req(
  'eutils', 
  'fontsizer', 
  'autovalidate', 
  'labelizor', 
  'mailtoenabler', 
  'imgpop', 
  'filtertable', 
  'tabswitcher', 
  function(){
    var $ = jQuery;

    $('#qstr').labelizor();
    
    $('.afangalisti table').filterTable();

    if (!window.EPLICA_loggedin) {
      
      //Give all images alt tag for title.
      $('.imgbanner img').each(function () {
          var altToTitle = $(this).attr('alt');
          if (altToTitle.length)
          {
            $(this).attr('title', altToTitle);
          }
        });

      $('div.articlelist img').wrap('<div class="imgwrapper"></div>');

      var articlePics = $('div.article, div.articlelist');
      articlePics.find('a[href$=".pdf"], a[href$=".PDF"]').addClass('pdf');
      articlePics.find('a[href$=".doc"], a[href$=".DOC"], a[href$=".docx"], a[href$=".DOCX"]').addClass('doc');
      articlePics.find('a[href$=".xls"], a[href$=".XLS"], a[href$=".xlsx"], a[href$=".XLSX"]').addClass('xls');


      $('div.article table tr:nth-child(even)').addClass('alt');
      $('div.people table tr:nth-child(odd)').addClass('odd');

      $('div.people').Req('/bitar/common/personas/loadEmployee.js', function(){ this.eplicaEmployeeLoader(); });


      $('div.afangar > .boxbody').run(function() {
          var afangi = $(this);
          $('h2', afangi).each(function(i) {
              $(this).add( $(this).nextUntil('h2, p.buttons') ).wrapAll('<div class="afangatab" id="tab'+ i +'" />');
            })
          $('div.afangatab').makeTabbox().tabSwitcher();
        });


      if($.browser.msie && parseInt($.browser.version) < 7) { 
        $('div.mnav li')
                .bind('mouseenter', function(e){
                    $(this)
                        .addClass('hover')
                  })
                .bind('mouseleave', function(e){
                    $(this)
                        .removeClass('hover')
                  })
      };


      var videoLink = $('a.video');
      if($.browser.msie && parseInt($.browser.version) < 7) {
          var opened = false;
          videoLink.click( function() {
              if(!opened) {
                  opened = true;
                  $(this)
                      .after('<object id="video" width="600" height="450" 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=600&height=450&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=600&height=450&autostart=true&bufferlength=5',"edit","toolbar=0,scrollbars=auto,location=0,status=0,menubar=0,width=600,height=450")
              setTimeout("menuWindow.focus();", 100);
              return false;
          });
      };


      // imgpopup
      $('div.imgbox a:has(img)').imgPopper({
                curtainColor : '#686060',
                curtainOpacity : '0.75'
          });

    }


    $('div.pagestyle').fontsizer({
      minSize      : 0,
      maxSize      : 3,
      defaultSize  : 1,
      currentSize  : 1
    });

    $('#noContentFlashHack').remove();
    $('.netfang').mailtoEnabler();
    $('form').autoValidate();

  }
);
