window.addEvent('domready', function() {
	if (location.hash != '#' && location.hash != '') {
		toPage(location.hash.replace('#', ''));
	}
});

function historyListener(newLocation, historyData) {
	if (newLocation == '') {
		newLocation = 'home';
	}
	toPage(newLocation);
}

function toPage(id) {
	$$('.page').setStyle('display', 'none');
	$(id).setStyle('display', 'block');
}

window.dhtmlHistory.create({
	toJSON: function(o) {
		return Json.toString(o); 
	} , fromJSON: function(s) {
		return Json.evaluate(s); 
	} 
}); 

window.addEvent('load', function () {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(historyListener);
});


