// init scroll gallery
function initGallery() {
	$('.gallery').galleryScroll({
		circleSlide: true
	});
}

// tabs function
function initTabs() {
	$('div.home-gallery').each(function(){
		var _gallery = $(this);
		var _thumbsHolder = _gallery.find('div.gallery');
		var _thumbs = _thumbsHolder.find('ul a');
		var _tabs = _gallery.find('div.tab-holder > div');
		var _currentIndex = 0;
		for (divIndex=0;divIndex<=12;divIndex++)
            {
              if ((_tabs.hide().eq(divIndex)).attr("id") == "current_ep") _currentIndex = divIndex;
            }
		_tabs.hide().eq(_currentIndex).show();
		_thumbs.each(function(_ind){
			// switch tabs by hover
			$(this).hover(function(){
				_tabs.hide().eq(_ind).show();
			});
			// set active
			/*
			$(this).click(function(){
				_currentIndex = _ind;
				_tabs.hide().eq(_currentIndex).show();
				return false;
			});
			*/
			
		});

		// restore tab on mouse out
		
		_thumbsHolder.hover(function(){
		},function(){
			_tabs.hide().eq(_currentIndex).show();
		});
		
	});
}

// init page
$(function() {
	initGallery();
	initTabs();
});