// JavaScript Document

var currentIndex = 0;
var images = new Array(
					   'images/incept_01.jpg',
					   'images/incept_02.jpg',
					   'images/incept_03.jpg',
					   'images/incept_04.jpg',
					   'images/incept_05.jpg',
					   'images/incept_06.jpg',
					   'images/incept_07.jpg',
					   'images/incept_08.jpg',
					   'images/incept_09.jpg'
					   );

window.scrollTo(0, 1);

$(document).ready( function() {
	
	if ($(window).height() > 1100)
	{
		$("#container").css("marginTop", ($(window).height() > 1100) / 2);
	}
	
	/*$('#gallery').swipe({
		 threshold: {
				x: 200,
				y: 500
			},
		 swipeLeft: function() { 
			currentIndex++;
			loadImage(currentIndex); 
		 },
		 swipeRight: function() { 
			currentIndex--;
			loadImage(currentIndex); 
		 }
	})*/
	
	$("a.arrow-left").click( function(event) {
		event.preventDefault();	
		
		currentIndex--;
		loadImage(currentIndex);
	});
	
	$("a.arrow-right").click( function(event) {
		event.preventDefault();	
		
		currentIndex++;
		loadImage(currentIndex);
	});
	
	$("a.arrow-left-iphone").click( function(event) {
		event.preventDefault();	
		
		currentIndex--;
		loadImage(currentIndex);
	});
	
	$("a.arrow-right-iphone").click( function(event) {
		event.preventDefault();	
		
		currentIndex++;
		loadImage(currentIndex);
	});
	
});

function loadImage(pIndex)
{
	
	if ( pIndex >= 0 && pIndex < images.length)
	{
		var img = new Image();
		img.src = images[pIndex];
		$("#gallery").html(img);
		
		if (pIndex > 0 )
		{
			$("a.arrow-left img").show();	
			$("a.arrow-right img").show();
			$("a.arrow-left-iphone img").show();	
			$("a.arrow-right-iphone img").show();
		} else {
			$("a.arrow-left img").hide();
			$("a.arrow-left-iphone img").hide();
		}
		
	} else if (pIndex == images.length) {
		$("a.arrow-right img").hide();
		$("a.arrow-right-iphone img").hide();
		//$("a.arrow-left img").hide();
		$("#gallery").html('<div id="gallery-swf"></div>');
		
		var flashvars = {};
		var params = { bgcolor: "#000000" };
		swfobject.embedSWF("manual.swf", "gallery-swf", "850", "1100", "10.0.0", "expressInstall.swf", flashvars, params);
	} 

}
