var moveSlider = function() {
	
}

$(document).ready(function(){	
	$('.icons li:first').click(function() {
		$('div.switcher a:eq(1)').click();
	});
	
	$('.icons li:eq(1)').click(function() {
		$('div.switcher a:eq(2)').click();
	});
	
	$('.icons li:eq(2)').click(function() {
		$('div.switcher a:eq(3)').click();
	});
	
	$('.label .item-1').click(function() {
		$('div.switcher a:eq(1)').click();
	});
	
	$('.label .item-2').click(function() {
		$('div.switcher a:eq(2)').click();
	});
	
	$('.label .item-3').click(function() {
		$('div.switcher a:eq(3)').click();
	});
	
	var elem = $('.circle-gallery');
	$('.switcher', elem).append('<ul></ul>');
	var blocks = $('ul.slide-block > li', elem);
	if (blocks.size() < 2) {
		return;
	}
	blocks.each(function(index) {
		$('<li><a href="#">' + index + '</a></li>')
			.appendTo($('.switcher ul', elem)) // add switch button
			.addClass(index == 0 ? 'active' : null) // activate if first
			.find('a').click(function() { // scroll slider on click
				// move slider
				var w = $('.frame', elem).outerWidth() + 20;
				var m = index * w * -1;
				$('ul.slide-block', elem).animate({ 'marginLeft' : m + 'px' });
				
				// activate button
				$(this).parents('ul').find('li').removeClass('active');
				$(this).parent().addClass('active');
				
				return false;
			});
	});
	
	setInterval(function(){
		var index = $('.circle-gallery .switcher ul li.active').index();
		if (index+1 >= blocks.size()) {
			$('.circle-gallery .switcher ul li:first').find('a').click();
		} else {
			$('.circle-gallery .switcher ul li').eq(index + 1).find('a').click();
		}
	}, 4000);
});
