//index
Cufon.replace('#contacts');

$(function () {
	
	var length = $('#image img').length;		
	
	for(var i=0; i < length; i++) {
		$('#ico').append('<div><!-- --></div>');				
	}

	$('#ico div:first').addClass('ico_active');	

	setInterval(function () {	
		
		var activeImg = $('#image img:visible');	
			activeImg.fadeOut(2000);

		var next = activeImg.next();

		if (!next.is('img')) {
			next =  $('#image img:first');
		}											

		next.fadeIn(2000, function () {
			
			
			$('#ico div.ico_active').removeClass('ico_active');
			var current_index = $('#image img').index(this);
			$($('#ico div').get(current_index)).addClass('ico_active');
			
		});
		
	}, 5000);
	
	if ($.browser.msie) {
		$('#content #welcom #production a').hover(function () {
			$(this).addClass('hover');
		},
		function () {
			$(this).removeClass('hover');
		})
	}

	/*$('#maps').toggle(function () {
		$(this).addClass('view_big');
	}, function () {
		$(this).removeClass('view_big');
	});*/
	
	$('.zagolovok').click(function () {

		$(this).toggleClass('open');
		
		if ($(this).is('.open')) {
			$('.holder', $(this).parents('.displ')).slideDown();
		}
		else {
			$('.holder', $(this).parents('.displ')).slideUp();
		}

	});
	
	/*$('.main_ul>li').click(function () {

		$('.ul_open ul').slideUp();
		$('.ul_open').removeClass('ul_open');
		
		$(this).toggleClass('ul_open');
		
		if ($(this).is('.ul_open')) {
			$('ul', this).slideDown();
		}
		else {
			$('ul', this).slideUp();
		}
		
		return false;

	});*/
	
	$('.main_ul>li').toggle(function () {

		$('.ul_open>ul').slideUp();
		$('.ul_open').removeClass('ul_open');
		
		
		$(this).toggleClass('ul_open');
		
		if ($(this).is('.ul_open')) {
			$('ul', this).slideDown();
		}
		else {
			$('ul', this).slideUp();
		}
	}, function (){
	
		$('.ul_open ul').slideUp();
		
		return false;
	});
	
	$('.main_ul>li').click(function () {
		return false;
	})
	
	$('.banners>a').hover(function () {
		 $(this).parents('.banners').addClass('hover');
		},
		function () {
		 $(this).parents('.banners').removeClass('hover'); 
		});
	
	/* $(".gallery a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook'}); */

		$('.gallery a').lightBox({fixedNavigation:true});
		
		$('.graco_letter').lightBox({fixedNavigation:true});
	
	
});
