$(document).ready(function(){
	$("a.zoom").fancybox();
	$("a.zoom1").fancybox({
		'zoomSpeedIn'		:	500,
		'zoomSpeedOut'		:	500
	});

	// фотогалереи (фото, итем магазина)
	$("#arTabs a").live('click', function(){
		var parLi = $(this).parent();
		if (!parLi.hasClass('active')) {
			$('#arTabs').children('li').removeClass('active');
			parLi.addClass('active');
			var tgt = $(this).attr('href');
			$('#content .arTab_content').hide();
			$(tgt).show();
		}

		return false;
	});

	// обычные вкладки
	$("#arTabs_Home a").live('click', function(){
		var parLi = $(this).parent();
		if (!parLi.hasClass('active')) {
			$('#arTabs_Home').children('li').removeClass('active');
			parLi.addClass('active');
			var tgt = $(this).attr('href');
			$('#content .wrapper_Home_Gallery').slideUp(300, function(){
					setTimeout(function(){
						$(tgt).slideDown(300);
					}, 300);
			});
		}

		return false;
	});

	// переключение между видами новостей
	$("#newsFilter a").live('click', function(){
		if (!$(this).hasClass('active')) {
			$('#newsFilter').children('a').removeClass('active');
			$(this).addClass('active');
			var tgt = $(this).attr('href');
			tgt = tgt.substring(1);

			if (tgt == 'all') {
				$('ul.news li').slideDown(200);
			} else {
				$('ul.news li[class!='+tgt+']').slideUp(200);
				$('ul.news li[class='+tgt+']').slideDown(200);
			}
		}

		return false;
	});

	// видео
	$("a[href*=.flv]").flowplayer("/components/flowplayer/flowplayer-3.1.5.swf", {
		clip: {
		// these two configuration variables does the trick
			autoPlay: false, 
			autoBuffering: true // <- do not place a comma here  
		}
	});

	// заголовки новостей на форуме
	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();
}
