window.dhtmlHistory.create({ toJSON: function(o) { return JSON.stringify(o); }, fromJSON: function(s) { return JSON.parse(s); } });

var historyListener = function(historyLocation, historyData) {
	//alert('listener ' + historyLocation +', ' + historyData);
	//fix history data on web root
	if(historyData == null)
		historyData = 'home';

	jQuery.handleLinkClick(historyData, false);
};

window.onload = function() {
	dhtmlHistory.initialize();
	dhtmlHistory.addListener(historyListener);

	//browser entered url
	var url = "" + window.location;
	var sitename = '';
	var location = '';

	//bookmark handling - it should work somehow in rsh, but not sure how, so lets hack it a bit
	//non-hashed links handling

	//check for anything after site name
	if(url.substr(0, 7) == 'http://')
	{
		url = url.substr(7);
	}

	sitename = url.substr(0, url.indexOf('/'));
	location = url.substr(url.indexOf('/') + 1);

	if(location.length)
	{
		//check for # in location
		var hash = location.indexOf('#');

		//no hash
		if(hash == -1)
		{
			window.location = 'http://' + sitename + '/#' + location;
			//alert('http://' + sitename + '/#' + location);
		}
		//hash is not first
		else if(hash > 0)
		{
			var link = location.substr(location.indexOf('#') + 1);

			if(link)
				window.location = 'http://' + sitename + '/#' + link;
		}
		//hash is first
		else
		{
			var link = location.substr(1);

			if(link)
				jQuery.handleLinkClick(link, true);
		}
	}


	//insert contact address
	document.getElementById("kontakt_e").innerHTML = 'go';
	document.getElementById("kontakt_e").innerHTML += '@';
	document.getElementById("kontakt_e").innerHTML += 'massageatelier.de';
};