var viewerIndex = 0;
var viewerTotal = 0;

$(document).ready(function(){
	$('.icons li a').click(function(e){
		var lb = $('#' + this.rel);
		lb.css('top', $(window).scrollTop() + 20);
		lb.css('left', ($('body').width() - 797) / 2);
		lb.show();
		$('#curtain').show();
		$('#curtain').css('height', $('body').height());
		e.preventDefault();
	});
	$('.lb .close').click(function(e){
		$('#curtain').hide();
		$(this).parents('div').eq(0).hide();
	});
	$('.content p input.text').eq(0).focus(function(){
		this.select();
	});
	viewerTotal = $('.viewer div').length - 1;
	$('.arrow.prev').eq(0).click(function(){
		$('.viewer div').eq(viewerIndex).hide();
		if (viewerIndex == 0) {
			viewerIndex = viewerTotal;
		} else {
			viewerIndex--;
		}
		$('.viewer div').eq(viewerIndex).show();
	});
	$('.arrow.next').eq(0).click(function(){
		$('.viewer div').eq(viewerIndex).hide();
		if (viewerIndex == viewerTotal) {
			viewerIndex = 0;
		} else {
			viewerIndex++;
		}
		$('.viewer div').eq(viewerIndex).show();
	});
});