var Gallery = {
	ShowFrame : function(id) {
		$('div.gallery-frames').each(function() {
			$(this).fadeOut('fast');
		});

		$('#' + id).fadeIn('slow');
	},

	InitMinsSlider : function() {
		$.easing.custom = function (x, t, b, c, d) {
			var s = 1.70158;
			if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
			return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
		}

		$('div.pictures-mins-content').scrollable({easing: 'custom', speed: 700, circular: false});

		$(".items li img").click(function() {
			if ($(this).hasClass("active")) {return;}
			var url = $(this).attr("normal");
			var big_url = $(this).attr("big");
			var wrap = $("#image_wrap").fadeTo("medium", 0.5);
			var img = new Image();
			img.onload = function() {
				wrap.fadeTo("fast", 1);
				wrap.find("img").attr("src", url);
			};
			img.src = url;
			wrap.find('a').attr('href', big_url);
			$("a[rel^='prettyPhoto']").prettyPhoto(
				{
					animationSpeed:'slow',
					show_title: false, 
					theme:'light_rounded',
					default_width: 700,
					default_height: 700,
					allow_resize: false,
					opacity: 0.5
				}
			);
			$(".items li img").removeClass("active");
			$(this).addClass("active");
		}).filter(":first").click();
	},

	InitNaviArrows : function() {
		$('#navi_left').click(function() {
			var picId = $(".items li img.active").attr('id').toString().split('_');
			picId = parseInt(picId[0]) - 1;

			if (picId > 0)
			{
				$('#' + picId.toString() + '_pic').click();
//				$('div.prev').click();
			}
		});

		$('#navi_right').click(function() {
			var picId = $(".items li img.active").attr('id').toString().split('_');
			picId = parseInt(picId[0]) + 1;

			var maxPicId = $(".items li img").filter(':last').attr('id').toString().split('_');
			maxPicId = parseInt(maxPicId);
			
			if (picId <= maxPicId)
			{
				$('#' + picId.toString() + '_pic').click();
//				$('div.next').click();
			}
		});
	}
}
