$(document).ready(function(){

	// фотогалереи (фото, итем магазина)
	$("a.zoom").fancybox();
	$("a.zoom1").fancybox({
		'zoomSpeedIn'		:	500,
		'zoomSpeedOut'		:	500
	});

	// виды членов Клуба
	$("#membersHeader a").click(function(){
		var parTd = $(this).parent().parent();

		if (!parTd.hasClass('active')) {
			$('#membersHeader td').removeClass('active');
			parTd.addClass('active');
			var tgt = $(this).attr('href');
			var jqTgt = $(tgt);

			$('#membersContent > div').hide();
			jqTgt.fadeIn(400);
		}

		return false;
	});

	// вкладки
	$(".tabs a").live('click', function(){
		if (!$(this).hasClass('active')) {
			$(this).parent().children('a').removeClass('active');
			$(this).addClass('active');
			var tgt = $(this).attr('href');

			$('#tabsContent > div').hide();
			$(tgt).show();
		}

		return false;
	});

	// видео
	$("a[href*=.flv]").flowplayer("/components/flowplayer/flowplayer-3.1.5.swf", { 
		clip:  { 
			autoPlay: false, 
			autoBuffering: true 
		} 
	});

	// nivo slider
	$('#slider').nivoSlider({
		effect:'fade',
		slices:15,
		animSpeed:1500,
		pauseTime:7000,
		directionNav:false, //Next & Prev
		directionNavHide:true, //Only show on hover
		controlNav:false, //1,2,3...
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		beforeChange: function(){},
		afterChange: function(){}
	});

	// заголовки новостей на форуме
	NewsHeaders = new NewsHeaders();
});

function NewsHeaders() {
	this.total = null;
	this.current = 0;

	this.init = function() {
		var self = this;
		this.total = $('.newsHeaders > li').length;
		self.Switch(0);
	};

	this.Switch = function(ind) {
		var self = this;
		self.current = ind;
		var jqElem = $('.newsHeaders > li').eq(ind);

		setTimeout(function(){
			var next = self.current + 1;
			if (self.current == self.total - 1)
				next = 0;
			jqElem.fadeOut(500, function(){
				$('.newsHeaders > li').eq(next).fadeIn(200);
				self.Switch(next);
			});
		}, 3000);
	}

	this.init();
}
