function slideSwitch(id) {
    var $active = $('.slideshow'+id+' IMG.active');
    if ( $active.length == 0 ) $active = $('.slideshow'+id+' IMG:last');
    // use this to pull the images in the order they appear in the markup
    //var $next =  $active.next().length ? $active.next(): $('.slideshow IMG:first');
     // показываем картинки случайным образом
     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');
        });
		var id = (id == 1)? 2:1;
		setTimeout( "slideSwitch("+id+")", 10000 );
}

	$(document).ready(function(){
		slideSwitch(1);
		$(".menu-item").hover(
	      function () {
	      	$(this).addClass('active');
	      	$(this).css("background","url('"+ host +"/images/opacity.png')"); //For IE6
	        $(this).find('.submenu').css('display','block');
	      }, 
	      function () {
	      	$(this).removeClass('active');
	      	$(this).css('background','none');
	        $(this).children('.submenu').css('display','none');
	      }
	    );  
	    
		var nice_height = $('#wrapper').height();
		var curr_height = 0;
		$('#wrapper > div').each(function(){
			curr_height = curr_height + $(this).outerHeight(true);
		});
		if (nice_height > curr_height) {
			var diff_height = nice_height - curr_height - 10;
			$('#content').height( $('#content').height() + diff_height);
		}
		
		if (chapter != 'index') $('#content').scrollbar();

	});
