var curLang;
$(document).ready(function() {
	//Init flag functions, so it's not in the HTML code
	$("#flag_NL").click(function(){setLang('NL')});
	$("#flag_EN").click(function(){setLang('EN')});
	$("#flag_DE").click(function(){setLang('DE')});

	//Set initial language
	curLang = $.cookie('lang');
	if(!curLang){
   		curLang = 'DE';
	}
	setLang(curLang);
	setPhotos();
 });
 
function setLang(lang){
	curLang = lang;
	$.cookie('lang',curLang);
	$("#colLeft").fadeOut('fast',function(){$(this).html($("#colLeft_"+curLang).html())}).fadeIn('slow');
	$("#colMiddle").fadeOut('fast',function(){$(this).html($("#colMiddle_"+curLang).html())}).fadeIn('slow');
	//$("#colRight").html($("#colRight_"+curLang).html());
	//$("#footer").html( $("#footer_"+curLang).html());
	
	//Reset flags and mark current
	$("#lang >img").css("border","0px");
	$("#flag_"+curLang).css("border","1px solid white");
	
	//Let's not forget Google :-)
	pageTracker._trackPageview('/'+curLang);
	
	//return ... well, something
	return false;
}

function setPhotos(){
	var t;
	var i;
	var nImg = 9;
	for(i=1;i<nImg;i++){
		t = (i%3)+1;
		$('#photos'+t).append("<a href='images/photos/"+i+".jpg' rel='lightbox-top'><img src='images/photos/"+i+"t.jpg' width='80' height='60'/></a>");
	}
	for(i=1;i<4;i++){
		$('#photos'+i).cycle({ 
				fx: 'fade',
				speed: 1000,
				timeout: 5000,
				pause: 1
			});
		$("#photos1 a,#photos2 a, #photos3 a").slimbox();
	}

}
