$(document).ready(function() {
	
	//init
	$("#navigation .back").css('opacity', 0.3); 
	$("#navigation").css('display', 'block'); 
	$("#anwb a.lb").lightBox();
	$("#cca a.lb").lightBox();
	$("#itchlive a.lb").lightBox();
	$("#dianaheemskerk a.lb").lightBox();
	$("#hallelujah a.lb").lightBox();
	$("#stroomrotterdam a.lb").lightBox();
	$("#deltahotel a.lb").lightBox();
	$("#cruisehotel a.lb").lightBox();
	$("#jobplanet a.lb").lightBox();
	$("#orisgroep a.lb").lightBox();
	$("#divaznetwerk a.lb").lightBox();
	$("#honderdprocenteigenwijs a.lb").lightBox();
	$("#lockdown a.lb").lightBox();
	openInNewWindow("body");

	//readmore
	$("#intro a.open").click(function(){
		$("#intro .readmore").slideDown("slow");
		$(this).fadeOut();
		$("#intro span.dots").fadeOut();
		return false;
	});
	

	$(window).bind('resize', function() {
		//alert($("#topPanel").css('margin-left'));
	});	
	
	//populate list
	itemList = new Array();
	itemList[0]= '#intro';
	counter = 1;
	$("#container li").each(function(){
		 if ($(this).attr("class") == "item"){ 
			itemList[counter]= '#' + $(this).attr("id");
			counter++;
		 }
	});
	
	currentItem = 0;
	
	//navigation  forward
	$(".forward").click(function(){
		if (currentItem < itemList.length-1) {
			currentItem = currentItem + 1;
		}
		
		if (currentItem == itemList.length-1) {
			$("#navigation .forward").css({'opacity': 0.3,'cursor':'default' });				
		}
		
		$.scrollTo( itemList[currentItem], 800, {easing:'easeOutExpo',offset:-280} );
			
		$("#navigation .back").css({'opacity': 1,'cursor':'pointer' });		
	});
	
	//navigation  back
	$(".back").click(function(){
		if (currentItem != 0) {
			currentItem = currentItem - 1;
		}
		
		if (currentItem == 0) {
			$("#navigation .back").css({'opacity': 0.3,'cursor':'default' });		
		}
	
		$.scrollTo( itemList[currentItem], 800, {easing:'easeOutExpo',offset:-280} );
		
		
		$("#navigation .forward").css({'opacity': 1,'cursor':'pointer' });				
	});
	
	//spam fighter!
	$(function(){
		var spt = $('span.mailme');
		var at = / at /;
		var dot = / dot /g;
		var addr = $(spt).text().replace(at,"@").replace(dot,".");
		$(spt).after('<a href="mailto:'+addr+'" title="Send an email">'+ addr +'</a>')
		.hover(function(){window.status="Send a letter!";}, function(){window.status="";});
		$(spt).remove();
	});
	
	//target blanko!
	function openInNewWindow(target) {
	
		$(target + " a[rel='blank']").each(function() {
	
			$(this).attr({
	
				//target: "_blank",
	
				href: "javascript:window.open('" + $(this).attr("href") + "');void(0);", 
	
				title: "Link opens in new window/tab"
	
			});
	
		});

}

});