function theRotator() {
	//Устанавливаем прозрачность всех картинок в 0
	$('div#header-bg-main ul li').css({opacity: 0.0});
 
	//Берем первую картинку и показываем ее (попути включаем полную видимость)
	$('div#header-bg-main ul li:first').css({opacity: 1.0});
 
	//Вызываем функцию rotator для запуска слайдшоу, 5000 = смена картинок происходит раз в 5 секунд
	setInterval('rotate()',5000);
}
 
function rotate() {	
	//Берем первую картинку
	var current = ($('div#header-bg-main ul li.show')?  $('div#header-bg-main ul li.show') : $('div#header-bg-main ul li:first'));
 
	//Берем следующую картинку, когда дойдем до последней начинаем с начала
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#header-bg-main ul li:first') :current.next()) : $('div#header-bg-main ul li:first'));	
 
	//Подключаем эффект растворения/затухания для показа картинок, css-класс show имеет больший z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
 
	//Прячем текущую картинку
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};

// images 
var imagesarr = new Array( 
"/images/joiners.jpg", 
"/images/joiners2.jpg"); 

// descriptions 
var commentsarr = new Array( 
"Столярные изделия", 
"Столярные изделия");

$(document).ready(function(){
	theRotator();
	
	$("#open_all_photo").click(function () {
		$("#all_photo").slideToggle('400', function() {
			if ($('#all_photo').is(':visible')){
				$('#open_all_photo').text('Скрыть фотографии');
			} else {
				$('#open_all_photo').text('Посмотреть все фотографии');
			}
		});
	});
	
	$.get('/inblocks/?topmenu=1', function (data) {
		$('#menu').html(data);
	});
	$.get('/inblocks/?leftcatmenu=1', function (data) {
		$('#leftcatmenu').html(data);
	});
	$.get('/inblocks/?leftnews=1', function (data) {
		$('#leftnews').html(data);
	});
	$.get('/inblocks/?botmenu=1', function (data) {
		$('#botmenu').html(data);
	});
	
	$('#ilom').click(function() {
		window.location = '/';
	});
	$('#ilic').click(function() {
		window.location = '/contacts/';
	});
	$('#logoimg').click(function() {
		window.location = '/';
	});
});

