if(window.parent.location.pathname != '/public/') {
	window.parent.location.href = '/public/#/' + window.parent.location.pathname.substr(8);
}

var currentcategory;
var currentarticle;
var currenthash = window.parent.location.hash;

function set_url(category, article, title) {
	if(title) {
		window.document.title = title;
	}
	if(category && article) {
		currentcategory = category;
		currentarticle = article;
		new_url = "/" + category + "/" + article + "/";
		if(new_url != window.parent.location.hash) {
						window.parent.location.hash = new_url;
		}
	}
	currenthash = window.parent.location.hash;
}

// History for ie
function change_navigation(category, article) {
	if(category != currentcategory && article != currentarticle) {
		currentcategory = category;
		currentarticle = article;
		new_url = "/" + category + "/" + article + "/";
		if(new_url == '///') {
			window.parent.location.hash = '';
		} else {
			window.parent.location.hash = new_url;
		}
		// Change page in flash
		document.getElementById('flash').setflashpage(category, article);
	}
}

// History for firefox
function check_navigation() {
	if(currenthash != window.parent.location.hash) {
		currenthash = window.parent.location.hash;

		var url = window.parent.location.hash;
		url = url.replace('#', '');
		if(url.substr(0,1) == '/') url = url.substr(1);
		url = url.split('/', 2);
		
		var category = url[0];
		var article = url[1];
		
		current_category = category;
		current_article = article;

		// Change page in flash
		if(document['flash']) {
			document['flash'].setflashpage(category, article);
		} else if(document.getElementById('flash')) {
			document.getElementById('flash').setflashpage(category, article);
		} else {
			load_flash();
		}
	}
}

	var navigationcheck = setInterval(check_navigation, 100);

