
// initialize global variables
var api = 0;
var thisID = 0;
var globalSpeed = 40;	
// rock on when DOM is ready	



function init() {
// initialize scrollable
	$("#mainWrapper").scrollable({
		speed: 10000,
		size: 1,
		clickable: false,
		loop: false,
		});
	
	//initialize jQueryTools API
	api = $(".scrollable").data("scrollable");

	//Start on MainPage
	gotoSpecialPage(1, 10, 0);

	$('.project').click(function () {
		var id = '.'+this.id;
		//$('.overlay').hide();
		getContent(id);
	});
	
	$('.contactoverlay').click(function() {
		$(this).hide("fast");
	});
	
	$('.contactLink').click(function () {
		getContact();
		}
	);
	
	$('.top').click(function () {
		kickContact();
		gotoSpecialPage(1, 10, 0);
		$('.projectDetail').fadeOut("slow");
		}
	);
	
	$('.project').hover(
		function () {
			//alert($(this)+':first-child');
			$('.overlay', this).fadeOut("fast");
		},
		function () {
			$('.overlay', this).fadeIn("fast");
		}
	);
	
	$("area[rel]").overlay();
	
}

function gotoSpecialPage(page, speed, id) {
	api.onBeforeSeek(function() {
		
		/*$(id).show();*/
		if (id != 0) { 
				/*alert(id);*/
				$(".active").removeClass("active").hide();
				$(id).addClass("active").show();
					
		} 
	}).seekTo(page, 400);
}
	
// function MM_preloadImages() { //v3.0
//   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
//     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
//     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
// }

function kickContent() {
	$('.projectDetail').fadeOut("slow");
//	$('.overlay').show();
}

function getContact() {
	$('.contactoverlay').show("fast");
}

function kickContact() {
	$('.contactoverlay').hide("fast");
}

function getContent(id) {
		$(".active").removeClass("active").hide();
		$(id).addClass("active").show();
		$('.projectDetail').fadeIn("slow");
}
