$(window).hashchange(function() {
	var project = location.hash.replace("#/", "");
//	console.log(project);
	if (project)
		loadhtml(project, "#top", projectCallback);
	else {
		loadhtml("splash", "#top", splashCallback);
	}
});
$(document).ready(init);

function init() {
	$(window).hashchange();
	$("#twitter").tweet({
		username: "florsignol",
		join_text: null,
		count: 3,
		loading_text: "Loading recent tweets...",
		template: function(info) {
			return info["text"] + info["time"];
		}
	});
}

function splashCallback() {
	$("#top").carousel({ loop: true, autoSlide: true, autoSlideInterval: 5000, animSpeed: 500, nextBtn: "", prevBtn: "" });
}

function projectCallback() {
	$("#top").carousel({ loop: true, animSpeed: 500 });
}

// loadhtml functions gets an html fragment from the src name and iserts into the target
function loadhtml(src, target, callback) {
//	$(target).contents().fadeOut(1000, funtion() {});
	$.get("work/" + src + ".html", function(data) {
		$(target).html(data);
		if (callback) callback();
	});
	scrollTo(0, 0);
}
