jQuery.fn.extend({
    disableSelection : function() {
            this.each(function() {
                    this.onselectstart = function() { return false; };
                    this.unselectable = "on";
                     jQuery (this).css('-moz-user-select', 'none');
            });
    },
    enableSelection : function() {
            this.each(function() {
                    this.onselectstart = function() {};
                    this.unselectable = "off";
                     jQuery (this).css('-moz-user-select', 'auto');
            });
    }
});

jQuery.noConflict();
jQuery(document).ready(function($){
$('.mainlevel').mouseenter(function(){
if ($(this).next().hasClass('canopen'))
{
$(this).next().stop(true, true);
$(this).next().slideDown(500);
$(this).next().removeClass('hidden_canopen');

$(this).parent().mouseleave(function(){
$(this).find('.canopen').delay(1000).slideUp(500); // добавлена задежка в 1000 мс
});

};
});


$('#slider-one').movingBoxes({
	startPanel   : 3,      // start with this panel

	wrap         : true,   // if true, the panel will "wrap" (it really rewinds/fast forwards) at the ends
	buildNav     : false,   // if true, navigation links will be added
	navFormatter : function(){ return ""; } // function which returns the navigation text for each panel
});



$('.videoline_right_arrow_button').mousedown(function(){
	$('body *').disableSelection();
	width_minus = $('.videoline_content_div').outerWidth() - $('.videoline_content_elements').outerWidth();
	if (width_minus < 0)
	{
	speed = ((width_minus - parseInt($('.videoline_content_elements').css('left')))/ width_minus)*6000; 
		$('.videoline_content_elements').animate({'left': width_minus}, speed);
	};	
}).mouseup(function(){
	$('body *').enableSelection();
	$('.videoline_content_elements').stop();
}).mouseleave(function(){
	$('body *').enableSelection();
	$('.videoline_content_elements').stop();
});



$('.videoline_left_arrow_button').mousedown(function(){
	$('body *').disableSelection();
	width_minus = $('.videoline_content_div').outerWidth() - $('.videoline_content_elements').outerWidth();
	if (parseInt($('.videoline_content_elements').css('left')) < 0)
	{
		
		speed = (parseInt($('.videoline_content_elements').css('left'))/width_minus)*6000; 
		
		$('.videoline_content_elements').animate({'left': 0}, speed);
	};
}).mouseup(function(){
	$('body *').enableSelection();
	$('.videoline_content_elements').stop();
}).mouseleave(function(){
	$('body *').enableSelection();
	$('.videoline_content_elements').stop();
});


$('.webinar_help').mouseover(function(){
$('.webinar_help_content').stop(true, true);
$('.webinar_help_content').fadeIn('300');
}).mouseout(function(){
$('.webinar_help_content').stop(true, true);
$('.webinar_help_content').fadeOut('300');
});;


function arrow_init(){

$('.timetable_calendar').find('td').hover(function(){
$('.many_dates_text').not( $(this).find('.many_dates_text') ).stop(true, true);
$('.many_dates_text').not( $(this).find('.many_dates_text') ).fadeOut(100);

if ($(this).find('.many_dates').length > 0){
	if ($(this).find('.many_dates_text').css('display') != 'block'){
		$(this).find('.many_dates_text').fadeIn(300);
	}else{
		$(this).find('.many_dates_text').fadeOut(300);
	};
}else if ($(this).find('a').length > 0){
	//document.location.href=$(this).find('a').attr('href'); // Вернуть если нужно сделать как раньше
};
});


$('.timetable_calendar').find('td').mouseenter(function(){
$(this).addClass('active');
}).mouseleave(function(){
$(this).removeClass('active');
});

$('.arrow_right').click(function(){
$('.many_dates_text').remove();
$('.arrow_right').unbind();
$('.arrow_left').unbind();
	$.getJSON('/ajax/calendar.php?date='+$('#month_year').val()+'&next=1', function(data){
		old_current_month_year = $('.month_year_text');
		new_current_month_year = $('<div class="month_year_text" style="left:120px;">'+data.date+'</div>').appendTo('.month_year');	
		old_current_month_year.animate({'left' : '-120'}, 400, function(){ $(this).remove(); });
		new_current_month_year.animate({'left' : '0'}, 400);
		$('#month_year').val(data.date_text);
	
		$('.timetable_calendar_container').css('overflow', 'hidden');
		
		old_timetable_calendar = $('.timetable_calendar');
		new_timetable_calendar = $(data.table).css('left', '185px').appendTo('.timetable_calendar_container');
		old_timetable_calendar.animate({'left' : '-185'}, 400, function(){ $(this).remove(); arrow_init(); });
		new_timetable_calendar.animate({'left' : '0'}, 400, function(){ $('.timetable_calendar_container').css('overflow', 'visible'); });
	});
});

$('.arrow_left').click(function(){
$('.many_dates_text').remove();
$('.arrow_right').unbind();
$('.arrow_left').unbind();
	$.getJSON('/ajax/calendar.php?date='+$('#month_year').val()+'&prev=1', function(data){
		old_current_month_year = $('.month_year_text');
		new_current_month_year = $('<div class="month_year_text" style="left:-120px;">'+data.date+'</div>').appendTo('.month_year');	
		old_current_month_year.animate({'left' : '120'}, 400, function(){ $(this).remove();});
		new_current_month_year.animate({'left' : '0'}, 400);
		$('#month_year').val(data.date_text);
		$('.timetable_calendar_container').css('overflow', 'hidden');
		old_timetable_calendar = $('.timetable_calendar');
		new_timetable_calendar = $(data.table).css('left', '-185px').appendTo('.timetable_calendar_container');
		old_timetable_calendar.animate({'left' : '185'}, 400, function(){ $(this).remove(); arrow_init(); });
		new_timetable_calendar.animate({'left' : '0'}, 400, function(){ $('.timetable_calendar_container').css('overflow', 'visible'); });
	});
});

};

arrow_init();




$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 10000, true);  








});
