
$(document).ready(function(){

	$('.wall:last img').load(function() {

		$('.wall').show();
		$('.wall:last').addClass('wall-active').empty();

		setInterval(function() {

			if (!$('.wall-active').prev()[0]) {
				$('.wall:last').fadeIn('slow',function() {
					$('.wall').show().removeClass('wall-active');
					$('.wall:last').addClass('wall-active');
				});
			}
			else {
				$('.wall-active').fadeOut('slow',function() {
					$(this).removeClass('wall-active');
					$(this).prev().addClass('wall-active');
				});
			}

		},10000);

	});
	
	$('.photos:last').load(function() {

		$('.photos').show();
		$('.photos:last').addClass('photo-active');

		setInterval(function() {

			if (!$('.photo-active').prev()[0]) {
				$('.photos:last').fadeIn('slow',function() {
					$('.photos').show().removeClass('photo-active');
					$('.photos:last').addClass('photo-active');
				});
			}
			else {
				$('.photo-active').fadeOut('slow',function() {
					$(this).removeClass('photo-active');
					$(this).prev().addClass('photo-active');
				});
			}

		},5000);

	});

	$('.thumbs-gallery li img').click(function() {
		var id=$(this).attr('rel');
		var prev_i=parseInt($('.gallery-active').attr('rel'));
		var new_i=parseInt($('#'+id).attr('rel'));
		if (new_i>prev_i) {
			$('#'+id).fadeIn('slow',function() {
				$('.gallery-active').hide().removeClass('gallery-active');
				$(this).addClass('gallery-active');
			});
		}
		else if (new_i<prev_i) {
			$('#'+id).show();
			$('.gallery-active').fadeOut('slow',function() {
				$(this).removeClass('gallery-active');
				$('#'+id).addClass('gallery-active');
			});
		}
	});

	if ($('#scrollable .items ul').length>1) {
		$('#scrollable-actions').show();

		$('#scrollable-actions .prev').click(function() {
			$('#scrollable .items').animate({
				top: 0
			},
			400,'swing');
			$('#scrollable-actions .next').show();
			$('#scrollable-actions .prev').hide();
		});

		$('#scrollable-actions .next').show().click(function() {
			$('#scrollable .items').animate({
				top: -$('#scrollable').height()
			},
			400,'swing');
			$('#scrollable-actions .prev').show();
			$('#scrollable-actions .next').hide();
		});
	}

	$('a.blank').each(function() {
        $(this).attr('target','_blank');
	});
	
});
