$(document).ready(function() {
	
	
	
	$('.left_menu ul').superfish({
		delay:       1000,                            // задержка в миллисекунду
		animation:   {opacity:'show',height:'show'},  // fade-in и slide-down анимация
		speed:       'slow',                          // увеличение скорости анимации
		autoArrows:  false,                           // отключает стрелку подменю
		dropShadows: false                            // отключает тень
	});
    
	var list = $('li.classes2'); 
	var i = 0; 
	while (i<list.length) { list.slice(i, i+3).wrapAll('<ul class="catalog"></ul>'); i+=3; }; 
	$("ul.catalog").after('<div class="clear"></div>');
	
	
	
	$(".main_slider img:first").attr("class", "active");
	
	/*$("div.main_slider").scrollable({ vertical: false, mousewheel: false, circular: true, speed: 500}).autoscroll({interval: 3000});
    */ 
	$("#vSlider").scrollable({ vertical: true, mousewheel: false, circular: true, speed: 1000}).autoscroll({interval: 4000});
       
    $("#slider").scrollable({ 
		vertical: false, 
		mousewheel: false, 
		circular: true, 
		speed: 1000,
		next: ".next2",
		prev: ".prev2",
		clonedClass: "cloned2"
	});	
	
	setTimeout('hslide("slider")', 2000);
   
	$("a[rel=gallery]").fancybox({
		"changeFade" : "slow",
		"overlayShow" : "false",
		"overlayOpacity" : 0.7,
		"titleShow" : "true",
		"centerOnScroll" : "true"
	}); 
	
	setInterval( "slideSwitch()", 3000 );
	
 });

function hslide(mid) {
    $("#"+mid).autoscroll({interval: 4000}); 
}
/*****/
function slideSwitch() {
    var $active = $('div.main_slider IMG.active');

    if ( $active.length == 0 ) $active = $('div.main_slider IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('div.main_slider IMG:first');

    // uncomment the 3 lines below to pull the images in random order
    
    // var $sibs  = $active.siblings();
    // var rndNum = Math.floor(Math.random() * $sibs.length );
    // var $next  = $( $sibs[ rndNum ] );


    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
