
	(function()
	{
	
		// Initializes the iPhone app screenshot gallery
		function gallery()
		{
			$("#gallery").jcarousel(
			{
				scroll: 1,
				buttonNextHTML: null,
				buttonPrevHTML: null,
				
				initCallback: function( carousel )
				{
					var timer = null,
						timer_index = 0;
					
					var scroll = function( a )
					{
						var i = parseInt($(a).text());
						carousel.scroll( i );
						$("#gallery .jcarousel-control a").each( function( __i )
						{
							if( ( 1 + __i ) == i )
								$(this).addClass("active")
							else
								$(this).removeClass("active");
						});
					};
					
					// Setups click events for the A elements
					$("#gallery .jcarousel-control a").bind( "click", function()
					{
						clearInterval( timer );
						scroll( this );
					});
					
					// Starts the 5second interval
					timer = setInterval( function()
					{
						timer_index = ((timer_index + 1) % 5);
						scroll( $("#gallery .jcarousel-control a:eq("+ timer_index +")").first() );
					}, 5000 );
				}
			});
		};
		
		$( function()
		{
			gallery();
		});
		
	})();
	
	jQuery(document).ready(function() {
		$(".blank").attr('target', '_blank');
	});
