$(document).ready(function(){

    
    $('a.audioplayer').each(function (i) {
        var audioPlayer = '<object type="application/x-shockwave-flash" data="/flash/audioplayer/player.swf" height="24" width="290">';
        audioPlayer += '<param name="movie" value="/flash/audioplayer/player.swf">';
        audioPlayer += '<param name="FlashVars" value="playerID=' + i + '&soundFile=' + $(this).attr('href') + '&titles=' + $(this).html() + '">';
        audioPlayer += '<param name="quality" value="high">';
        audioPlayer += '<param name="menu" value="false">';
        audioPlayer += '<param name="wmode" value="transparent">';
        audioPlayer += '</object>';
        /*audioPlayer += '<br/><a href=\"' + $(this).attr('href') + '\" target=\"_blank\">download mp3</a>';*/
        $(this).after(audioPlayer).remove();
    });

    $('a.videoplayer').each(function (i) {
        var videoPlayer = '<object type="application/x-shockwave-flash" data="/flash/videoplayer/player.swf" height="370" width="450">';
        videoPlayer += '<param name="movie" value="/flash/videoplayer/player.swf">';
        videoPlayer += '<param name="FlashVars" value="playerID=' + i + '&link=&file=' + $(this).attr('href') + '&titles=' + $(this).html() + '">';
        videoPlayer += '<param name="quality" value="high">';
        videoPlayer += '<param name="menu" value="false">';
        videoPlayer += '<param name="allowfullscreen" value="true">';
        videoPlayer += '</object>';
        /*videoPlayer += '<br/><a href=\"' + $(this).attr('href') + '\" target=\"_blank\">download mp3</a>';*/
        $(this).after(videoPlayer).remove();
    });

    $("#overlay").height($(document).height());
/*----вызовы плагинов----*/
	if($('a').is(".fancy")){              
        $('a.fancy').fancybox();
	}
	if($('select').is("#month,#year")){
		var params = {
				changedEl: "#month,#year",
				scrollArrows: true
		}
		//cuSel(params);
	}
  
  if( jQuery.browser.msie ){
    $(function(){
      $('.main-date-block .date,.main-date-block .event').each(function(){
        var clone = $(this).html();
        $(this).wrapInner('<div class="text"></div>');
         $(this).find('.text').css({'position' :'relative' });
        $(this).prepend('<div class="out">'+clone+'</div>');
        $(this).find('.out').css({
          'color' : '#FFF',
          'position' :'absolute',
          'top' : '-1px',
          'left' : 0
        })
        
      });
    });
  }
  
     //$('#main-welcome-block').find('.close').click(function(){$('#main-welcome-block, #overlay').fadeOut(); return false;});
    $('#main-welcome-block').click(function(){$('#main-welcome-block, #overlay').fadeOut(); return false;});
    $('#main-welcome-block, #overlay').fadeIn();
    $('#overlay').click(function(){
      $("#overlay, #main-welcome-block").fadeOut("fast");
    });

  
  
   $(function(){
    var block = $('.banners-block');
    var items = $('.banners-block .items');

    function flowleft(speed){
      items.find('li').first().animate({'margin-left': "-227px"}, speed,'linear', function(){
        items.append($(this));
        $(this).css({'margin-left': 0});
        flowleft(10000);
      });
    }
    
    function flowright(){
      var elem = items.find('li').last();
      elem.css({'margin-left': '-227px'});
      items.prepend(elem);
      elem.animate({'margin-left': 0}, 10000,'linear',flowright );
    }
    
    //init scroll
    if (items.find('li').size() > 4){
        $('.scroll-right').css({'display' : 'block'});
        $('.scroll-left').css({'display' : 'block'});
      $(function(){
        block.addClass('ltr');
        flowleft(10000);
      });
      
      //add events to conrol arrows
      $('.scroll').click(function(){
        if ($(this).hasClass('right') && !block.hasClass('ltr')) {
          block.toggleClass('rtl ltr');
          items.find('li').stop();
          flowleft();
        }
        if ($(this).hasClass('left') && !block.hasClass('rtl')) {
          block.toggleClass('ltr rtl');
          items.find('li').stop().first().animate({'margin-left': 0},200,'linear');
          flowright();
        }
      });
    } 
    else $('.banners-block .scroll').hide();
    
  });
  
  
 
  
  
})