$(document).ready(function() {
	// Startup code goes here.

	// Setup slideshow of larger app images (inside the iPhone)
	$('#app1').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});
	$('#app2').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});
	$('#app3').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});
	$('#app4').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});
	$('#app5').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});
	$('#app6').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});		
	$('#app7').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});	
	$('#app8').slideshow({
		timeout: 5000,
		fadetime: 500,
		type: 'sequence',
	});			

	// Setup the dock.
	jQuery('#appDock').jqDock();

	// Link the dock thumbnail images to actions.
	$(function(){
		var slider = $('.pageSlider').bxSlider({
		auto: true,
		mode: 'fade',
		pager: false,
		pause: 10000,
		controls: false
	  });

	  // assign a click event to the external thumbnails
	  $('.thumbs a').click(function(){
	   var thumbIndex = $('.thumbs a').index(this);
		// call the "goToSlide" public function
		slider.goToSlide(thumbIndex);
	  
		// remove all active classes
		$('.thumbs a').removeClass('pager-active');
		// assisgn "pager-active" to clicked thumb
		$(this).addClass('pager-active');
		// very important! you must kill the links default behavior
		return false;
	  });

	  // assign "pager-active" class to the first thumb
	  $('.thumbs a:first').addClass('pager-active');
	});

	// Check if #appname was used, to start them on a specific dock-item,
	// named "dock_appname". Need delay so that all the JS bits are working.
	if(document.location.hash) {
		window.setTimeout(function() {
			var anc = document.location.hash.substring(1);
			var target = $("#dock_" + anc);
			if(target) {
				target.click();
			}
		}, 200);		
	}

}); // end onReady code

