$(function(){
  var preload = [];
  
  preload[0] = document.createElement('IMG');
  preload[0].src = '/i/news-menu.png';
       
  preload[1] = document.createElement('IMG');
  preload[1].src = '/i/news-menu-active.png';
  
  preload[2] = document.createElement('IMG');
  preload[2].src = '/i/news2-menu.png';
       
  preload[3] = document.createElement('IMG');
  preload[3].src = '/i/news2-menu-active.png';
  
  preload[4] = document.createElement('IMG');
  preload[4].src = '/i/news3-menu.png';
       
  preload[5] = document.createElement('IMG');
  preload[5].src = '/i/news3-menu-active.png';
  
  preload[6] = document.createElement('IMG');
  preload[6].src = '/i/news-menu-item.png';
  
  preload[7] = document.createElement('IMG');
  preload[7].src = '/i/news-menu-active-item.png';
  
  preload[8] = document.createElement('IMG');
  preload[8].src = '/i/menu/item_1_active.png';
  
  preload[9] = document.createElement('IMG');
  preload[9].src = '/i/menu/item_2_active.png';
  
  preload[10] = document.createElement('IMG');
  preload[10].src = '/i/menu/item_3_active.png';
  
  preload[11] = document.createElement('IMG');
  preload[11].src = '/i/menu/item_4_active.png';
  
  preload[12] = document.createElement('IMG');
  preload[12].src = '/i/menu/item_5_active.png';
  
  preload[13] = document.createElement('IMG');
  preload[13].src = '/i/menu/item_6_active.png';




  $('.main-menu div').hover(
    function(){
      $(this).children('.drop').show();
    },
    function(){
      $(this).children('.drop').hide();
    }
  );
 
 
 
  
  $('.news-menu li a').hover(
        function(){$(this).parent('li').css('background', 'url(\'/i/news-menu-active-item.png\') center center no-repeat')}, 
        function(){$(this).parent('li').css('background', 'url(\'/i/news-menu-item.png\') left top no-repeat')}
  );
  
  
  
  
  $('.news3').parent('li').hover(
    function(){$(this).children('.drop-news').show()}, 
    function(){$(this).children('.drop-news').hide()}
  );



  var params = {
    changedEl: ".forma select",
    visRows: 15,
    scrollArrows: true
  }
  cuSel(params);
  

  $('#social_list a').each(function(){
    if (!$(this).hasClass('youtube')) {
    class_name = $(this).attr('class');
    tit = $('title').text();
    $(this).attr('href', 'http://share.yandex.ru/go.xml?service='+class_name+'&url='+window.location.href+'&title='+tit);
    }
  });
    
      
//   $('#datepicker').datepicker($.datepicker.regional["ru"],{
//       inline: true
//   });
//     $('#datepicker').datepicker({
//         onSelect: function(){window.location.href = '/calendar/'+$(this).val()}
//     });
  // hightslide begin 
  
  hs.graphicsDir = '/libs/highslide/graphics/';
    hs.align = 'center';
    hs.transitions = ['expand', 'crossfade'];
    hs.outlineType = 'rounded-white';
    hs.fadeInOut = true;
    hs.dimmingOpacity = 0.75;

    // define the restraining box
    hs.useBox = false;
    hs.width = 640;
    hs.height = 480;

    // Add the controlbar
    hs.addSlideshow({
        //slideshowGroup: 'group1',
        interval: 5000,
        repeat: false,
        useControls: true,
        fixedControls: 'fit',
        overlayOptions: {
            opacity: 1,
            position: 'bottom center',
            hideOnMouseOut: true
        }
    });
   // hightslide end

  /*$('.anketa-link').click(function(){
    $('.fade').fadeIn(400);
  });
  $('.close-form').click(function(){
    $('.fade').fadeOut(200);
  });*/ 
  
  $('.privilege a').hover(
    function(){
      $(this).children('div').children('div').children('div').fadeIn(200);
    },
    function(){
      $('.privilege a div div div').fadeOut(200);
    }
  );
  
});
