/*$(function() {
	_Gallery.bind();
});

_Gallery = {
	container: '.b-gallery',
	collection: [],
	collectionPos: [],
	timer: null,

	bind: function() {
		this.$container = $(this.container)
		this.collection = $('img', this.$container);

		if(this.$container.length 
			&& this.collection.eq(2).length
		) {
			this.start(3);
		} else if (this.collection.eq(1).length) {
			this.$container.attr('align', 'center');
			this.collection.eq(1).hide();
			this.start(2);
		} else {
			this.$container.attr('align', 'center');
		}
	},

	start: function(number) {
		//для двух журналов
		if (number == 2) {
			var self = this;
						
			this.$container.width(290).height(180);
			
			if (this.collection.eq(0).css('display') != 'none') {
				index = 0;
				this.collection.eq(1).addClass('hideJournal');
				
				this.showLabel(_Gallery.collection.eq(index).attr('alt'));
				this.selectMenu(index);
			} else {
				index = 1;
				this.collection.eq(0).addClass('hideJournal');
				
				this.showLabel(_Gallery.collection.eq(index).attr('alt'));
				this.selectMenu(index);
			}
			$('.b-gallery').oneTime('5s', function() {
				_Gallery.collection.eq(index).fadeOut(500, function() {
						self = $(this).parent().parent()
										.width(290).height(180)
										.find('.hideJournal').fadeIn(500).removeClass('hideJournal');
					
						index = $('.b-gallery img').index(self);
						_Gallery.start(2);
				});
			});
		} 
		
		//для трех журналов
		else if (number == 3) {
		var self = this;
		this.$container.css({
			position: 'relative'
		}).height(this.collection.eq(1).height())
			.parent()
			.width(290)
			.height(250);

		this.collection.each(function(i) {
			var el = $(this);
			el.parent().click(function() {
				var el = $(this);
				self.show(el.index());
				return false;
			});

			el.data('dimensions', {w:el.width(), h:el.height()});

			if(i == 0 || i == 2) {
				var nh = el.height() / 2
				el.css({
					top: 30,
					left: 0,
					height: (el.height() / 1.37),
					zIndex: 1,
					position: 'absolute'
				});
			}
			if(i == 1) {
				el.css({
					left: (self.$container.width() / 2) - (el.width() / 2),
					zIndex: 3,
					position: 'absolute'
				});
			}
			if(i == 2) {
				el.css({
					left: self.$container.width() - (el.width() / 1.37)
				});
			}

			self.collectionPos.push(i);
			el.removeAttr('width');
		});

		$('li', this.$container.parent()).click(function() {
			var el = $(this),
				i1 = el.index() + 1,
				i2 = el.siblings('.selected').index() + 1;

			if(Math.abs(i2 - i1) > 1 || (i2 - i1) < 0) {
				if((i2 - i1) == -2) {
					self.show(self.collectionPos[0]);
				} else {
					self.show(self.collectionPos[2]);
				}
			} else {
				self.show(self.collectionPos[0]);
			}
		});

		$('label', this.$container).css({
			top: this.collection.eq(1).height() + 10,
			width: '100%',
			font: '12px/1.666em Arial',
			color: '#4D5462',
			textAlign: 'center',
			position: 'absolute'
		});

		this.showLabel(this.collection.eq(1).attr('alt'));
		this.selectMenu(1);
		this.resetTimer();
		}
	},

	show: function(index) {
		var self = this,
			count = 0;

		this.resetTimer();
		$(this.collectionPos).each(function(i) {
			if(index == this) {
				count = i;
				return false;
			}
		});

		if(count == 1) {
			window.open(this.collection.eq(index).parent().attr('href'));
			return false;
		}

		if(!count) {
			this.collectionPos = [this.collectionPos[2], this.collectionPos[0], this.collectionPos[1]];
		} else {
			this.collectionPos = [this.collectionPos[1], this.collectionPos[2], this.collectionPos[0]];
		}

		var left = this.collection.eq(this.collectionPos[0]),
			ldimensions = left.data('dimensions');
		left.css('z-index', ((!count) ? 1 : 2)).animate({
			top: 30,
			left: 0,
			height: (ldimensions.h / 1.37)
		});

		var center = this.collection.eq(this.collectionPos[1]),
			cdimensions = center.data('dimensions');
		center.css('z-index', 3).animate({
			top: 0,
			left: (self.$container.width() / 2) - (cdimensions.w / 2),
			height: cdimensions.h
		});

		this.showLabel(center.attr('alt'));
		this.selectMenu(index);

		var right = this.collection.eq(this.collectionPos[2]),
			rdimensions = right.data('dimensions');
		right.css('z-index', ((!count) ? 2 : 1)).animate({
			top: 30,
			left: self.$container.width() - (rdimensions.w / 1.37),
			height: (rdimensions.h / 1.37)
		});
	},

	resetTimer: function() {
		var self = this;

		if(this.timer) clearInterval(this.timer);
		this.timer = setInterval(function() {
			self.show(self.collectionPos[2]);
		}, 5000);
	},

	showLabel: function(text) {
		$('label', this.$container.parent()).hide().html(text).fadeIn();
	},

	selectMenu: function(index) {
		$('li', this.$container.parent()).eq(index).addClass('selected').siblings().removeClass('selected');
	}
}*/