// JavaScript Document
function init() {
	var aNodeList = $('menu').getElementsByTagName('a');
	var nodes = $A(aNodeList);

	nodes.each(function(node){
		node.onclick = function(e) {
				aclick(node);
				return false;
			};
	});
	
	var pos = window.location.href.lastIndexOf('?');
	if (pos > 0) {
		loadContent(window.location.href.replace("?", "/") + ".html");
	}
}

function aclick(anch) {
	loadContent(anch.href);
}

function loadContent(uri) {
	new Ajax.Request(uri, 
		{
			method: 'get', 
			onComplete: function(req) {
					var content = req.responseText;
					var start = content.indexOf("<body>") + 6;
					var end = content.lastIndexOf("</body>") - 1;
					$('content').innerHTML = content.substring(start, end);
				}
		});
}
