	$(function() {
		$('.services-ctrl').click(function() {
			var svcs = $('.services');
			if (svcs.is(':visible')) {
				$('#marker_img').attr('src', 'img/marker01.gif'); 
				svcs.slideUp(300);
				$(this).removeClass('opened');
			} else {
				$('#marker_img').attr('src', 'img/marker01_active.gif'); 
				svcs.slideDown(1000, 'easeOutBounce');
				$(this).addClass('opened');
			}
		});
		$('.services-ctrl div').hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
	});

	$(function(){
		$('#acc02').accordion({
			autoHeight: false,
			active: 0
		});
		$('#acc02').append('<em class="tl"></em><em class="tr"></em><em class="bl"></em><em class="br"></em>');
		
		var api1 = $('#main-projects').scrollable({
			vertical: true,
			easing: 'linear',
			speed: 400,
			size: 1
		});		
		
		var api2 = $('#main-clients01').scrollable({
			vertical: true,
			//hoverClass: 'hover',
			easing: 'linear',
			speed: 400,
			size: 8,
			api: true,
			onMouseOver: function(item){
				$('#main-clients01 li').removeClass('active');
			
				$(item).addClass('active');
			
				var srcImg = $('img', item);
			
				var logotypeId = parseInt(srcImg.attr('class'), 10);				
				var alt = srcImg.attr('alt');
				var title = srcImg.attr('title');
				
				var bigImg = $('#main-clients01 div.big img');
				
				bigImg.stop().animate({opacity: 0}, 200, 'linear', function(){
					bigImg.attr('src', '/cms/i/' + logotypeId + '.jpg');
					bigImg.attr('alt', alt);
					bigImg.attr('title', title);
					bigImg.animate({opacity: 1}, 200);
				});
			}
		});
		var firstImg = api2.getItems().eq(0).children('img');
		if(firstImg != null){
			var logotypeId = parseInt(firstImg.attr('class'), 10);
			var alt = firstImg.attr('alt');
			var title = firstImg.attr('title');
			
			var bigImg = $('#main-clients01 div.big img');				
			bigImg.attr('src', '/cms/i/' + logotypeId + '.jpg');
			bigImg.attr('alt', alt);
			bigImg.attr('title', title);
		}
	});
var tab_pos= Array(0,0,0,0,0);
var tab_obj = Array(null, null, null, null, null);
var tab_state = Array(0, 0, 0, 0, 0); // 0 - закрыт, 1 - открывается, 2 - открыт. 3 - закрывается.
function show_tab(i, o)
{
	if (tab_state[i] == 3) return;
	
	if (o != null) tab_obj[i] = o;
	var obj = tab_obj[i];

	/*for (j=1;j<=5;j++)
		if (tab_obj[j] != null && j != i) hide_tab(j, tab_obj[j]);*/

	if (tab_pos[i] < 100)
	{
		tab_state[i] = 1;
		tab_pos[i] += 20;
		obj.style.backgroundPosition = '0 ' + (tab_pos[i]) + '%';
		setTimeout("show_tab("+i+", null)", 100);
	}
	else tab_state[i] = 2;
}

function hide_tab(i, o)
{
	// если не до конца открылась. то не закрываем
	if (tab_state[i] == 1) return;

	if (o != null) tab_obj[i] = o;
	var obj = tab_obj[i];
	
	if (tab_pos[i] > 0)
	{
		tab_state[i] = 3;
		tab_pos[i] -= 20;
		obj.style.backgroundPosition = '0 ' + (tab_pos[i]) + '%';
		setTimeout("hide_tab("+i+", null)", 100);
	}
	else tab_state[i] = 0;
}
$(document).ready(function() {
	$('#topnav li div').prepend('<span ></span>');
	$('#topnav li div').each(function() {
		var linkText = $(this).find('a').html();
		$(this).find('span').show().html(linkText);
	}); 
	$('#topnav li div').hover(function() {
		$(this).find('span').stop().animate({ 
			marginTop: '-45'
		}, 250);
	} , function() { //On hover out...
		$(this).find('span').stop().animate({
			marginTop: '0'
		}, 250);
	});
});

	function select_slide(i)
	{
		for (j=1; j<=6; j++)
		{
			//$('#ct'+j).fadeOut(1);
			$('#t'+j).removeClass('current');
		}
			
		//$('#ct'+i).fadeIn(1000);
		$('#t'+i).addClass('ct');
		$("#flowpanes").scrollable({api: true, size: 1}).seekTo(i-1);
	}
	
	$(document).ready(function() {
		// select #flowplanes and make it scrollable. use circular and navigator plugins
		$("#flowpanes").scrollable({size: 1}).circular().mousewheel(400).navigator({

			// select #flowtabs to be used as navigator
			navi: "#flowtabs",

			// select A tags inside the navigator to work as items (not direct children)
			naviItem: 'a',

			// assign "current" class name for the active A tag inside navigator
			activeClass: 'current'

		});

	});




	hs.graphicsDir = '/js/gal/graphics/';
	hs.align = 'center';
	hs.transitions = ['expand', 'crossfade'];
	hs.wrapperClassName = 'dark borderless floating-caption';
	hs.fadeInOut = true;
	hs.dimmingOpacity = .35;

	// Add the controlbar
	if (hs.addSlideshow) hs.addSlideshow({
		//slideshowGroup: 'group1',
		interval: 5000,
		repeat: false,
		useControls: true,
		fixedControls: 'fit',
		overlayOptions: {
			opacity: .6,
			position: 'bottom center',
			hideOnMouseOut: true
		}
	});


