$.preloadImages = function() {
	for(var i = 0; i < arguments.length; i++) {
		$('<img />').attr('src', arguments[i]);   
	} 
}

$(document).ready(function() {
	$.preloadImages(
		'img/screen1.jpg',
		'img/screen2.jpg',
		'img/screen3.jpg',
		'img/screen4.jpg',
		'img/screen5.jpg'
	);	
	$('#screenshots li a.zoom')
		.mouseenter(function() {
			$this = $(this);
			if (!$this.hasClass('active'))
				$this.animate({'top': '-10px'}, 100);
		})
		.mouseleave(function() {
			$this = $(this);
			if (!$this.hasClass('active'))
				$this.stop().animate({'top': '0px'}, 100);
		})
		.click(function(event) {
			$this = $(this);
			if (!$this.hasClass('active')) {
				$('#screenshots ul li a.active')
					.removeClass("active")
					.animate({'top': '0px'}, 100);
			
				$this.addClass("active");

				$('#iphonescreen').fadeOut(300, function() {
					$(this)
						.css('background-image', 'url(' + $this.attr('href') + ')')
						.fadeIn(300);
				});
			}
	
			event.preventDefault();
		})
		.eq(0).animate({'top': '-10px'}, 100, 'linear', function() {
			$(this).addClass('active');
		});
			
	$('#iphonescreen').fadeIn(300);
	
	
});
