(function($){
  $(function(){
      /*$('.company-item').each(function(){
          $(this).css('cursor', 'pointer');
          $(this).click(function(){
              window.location = $(this).find('a:eq(0)').attr('href');
          });
      }); */
      
      $('a.arrow').each(function(){
          var text = '<div class="a-arrow"><div class="arrow">></div>';
          text = text + '<a href="'+$(this).attr('href')+'" >'+$(this).text()+'</a>';
          text = text + '</div>';
          $(this).replaceWith(text);
      });
      
      $('#button-print a').click(function(){
          window.print();
          return false;
      });
      
      $('div.company-list').each(function(){
          var timeBig = 150; // Скорость с которой увеличивается элемент
          var companyList = $(this);
          
          var left = 0;
          for (var i=0; companyList.find('.company-item:eq('+i+')').length; i++) {
              companyList.find('.company-item:eq('+i+')').css('left', left+'px');
              companyList.find('.company-item:eq('+i+')').css('position', 'absolute');
              left += 123;
          }
          
          
          companyList.find('.company-item').each(function(){
              var timeout = null;
              var big = 0.26; // На сколько процентов увеличивать элемент            
              var leftSmall = $(this).position().left;
              var topSmall = $(this).position().top;
              var heightSmall = $(this).innerHeight();
              //var heightSmall = 55;
              var widthSmall = $(this).innerWidth();
              var fontSmall =  parseInt($(this).find('.title a').css('font-size'))+'px';
              //console.log(fontSmall);
              var heightBig = heightSmall+(heightSmall*big);
              var widthBig = widthSmall+(widthSmall*big);
              var fontBig =  parseInt(fontSmall)+2+'px';
              var leftBig = leftSmall-(widthBig-widthSmall)/2;
              var topBig = topSmall-(heightBig-heightSmall)/2;
              
              
              $(this).click(function(){
                  var url = $(this).find('a').attr('href');
                  window.location=url;
              });
              
              $(this).mouseover(function(){
                  if (timeout) {
                      clearTimeout(timeout);
                  }
                  if ($(this).is('.big')) {
                      return true;
                  }
                  $(this).addClass('big');
                  $(this).stop();
                  $(this).animate({
                      'left':leftBig, 
                      'top':topBig,
                      'height':heightBig,
                      'width':widthBig
                  },  timeBig); 
                  $(this).find('.title a').animate({
                      'font-size':fontBig
                  },  timeBig);
              });
              
              $(this).mouseout(function(){
                  var mouse = $(this);
                  timeout = setTimeout(function(){
                      mouse.removeClass('big');
                      mouse.stop();
                      mouse.animate({
                          'left':leftSmall, 
                          'top':topSmall,
                          'height':heightSmall,
                          'width':widthSmall,
                          'font-size':fontSmall
                      }, timeBig); 
                      mouse.find('.title a').animate({
                          'font-size':fontSmall
                      },  timeBig);
                  }, 150);
              })
          }); //items.children('div.company-item').each(function(){        
      }); // $('div.company-list').each(function(){
  });
})(jQuery);
