// encoding: utf-8
/*@cc_on/*@if(@_jscript_version<5.7)try{document.execCommand('BackgroundImageCache',0,1)}catch(e){}/*@end@*/

// ***** jqreq *****
Req(
  'fontsizer',
  'autovalidate',
  'labelizor',
  'x/ifixpng',
  'imgpop',
  'mailtoenabler',
  /*'listscroller',*/
  
  function(){
    var $ = jQuery;

    // labelize search input
    $('#qstr').labelizor();

    if (!window.EPLICA_loggedin)
    {

      // pngfix for IE6
      if ($.browser.msie && $.browser.version < 7) {
        $('img[src$=".png"]').ifixpng();
      }

      //zebra tables
      $('div.people table tr:even, table.zebra tr:even').addClass('alt');

      //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'
            });
    }

    $('body.twocol .mediagallery li img').each(function() {
        var hph = $(this).parent().height() / 2,
            mt = hph - ( hph - ( $(this).height() / 2 ) );
        $(this).css({
            'top' : hph,
            'margin-top' : -mt
            })
      })

    //remove flicker trick
    $('#noflickerCSS').remove();


    //frontpage image carousel
    /*
    $('body.home div.imagelist')
          .listscroller({ 
              item : 'li',
              aspect:      'horizontal',
              paging:      true,
              animation:   'carousel',
              windowSize:  1,
              stepSize:    1, 
              startPos: 'random'
            });
    */
    $.fn.imageLoader = function () {
      var imgbox = $(this);
          
      $('.pgr a', imgbox).each(function() {
          $(this).bind('click', function() {
              $.get(
                $(this).attr('href'),
                { justPicPos: 'pgmain' },
                function(data){
                    var imgboxbody = $(data).find('.imgbox .boxbody');
                    imgbox.html( imgboxbody ).imageLoader();
                  }
              );
              return false;
            })
        });
    };
    $('body.home .imgbox').imageLoader();


    //employee list ajax
    $('div.people').Req('/bitar/common/personas/loadEmployee.js', function(){ this.eplicaEmployeeLoader(); });
    
    $('.netfang').mailtoEnabler();


    // fontsizer
    $('div.pagestyle').fontsizer();

    // validate all forms
    $('form').autoValidate();

  }
);
// **** /jqreq *****
