var alertParent = function(e){
	document.location.replace(document.location + "#website" + e.target.getAttribute("href").toString().substr(7));
}
function loaded(){
	var disablehashcheck;

	if(document.getElementById("cart") != null) {
		var cartscript = document.createElement("script");
		cartscript.setAttribute("type", "text/javascript");
		cartscript.setAttribute("src", "/website/scripts/shoppingCartClient.js");
		document.getElementsByTagName("head")[0].appendChild(cartscript);
		cartscript.onload = function(){globalCart = new shoppingCartClient.cart(); globalCart.displayCartSidePanel();}
	}
	for (var x = 0; x < document.getElementsByTagName("a").length; x++) {
		var t = document.getElementsByTagName("a")[x];
		if (t.href.indexOf("javascript:") === -1){
			t.onclick = function(e){alertParent(e)};
		}
	}
	if(window.top.location.hash === ""){
		disablehashcheck = true;
		window.top.location.hash = "website" + getLocation();
		disablehashcheck = false;
	} else if (window.top.location.hash !== "website" + getLocation()) {
		disablehashcheck = true;
		window.top.location.replace(window.top.location.protocol+"//"+window.top.location.host+window.top.location.pathname + "#website" + getLocation());
		disablehashcheck = false;
	}
	window.top.onhashchange = function(){
		if (!disablehashcheck) {
			//window.location = "/widgets/websiteViewer"+window.top.location.hash.substr(1);
		}
	}
}

function getLocation(){
	return window.location.toString().substr(window.location.toString().indexOf("website")+7);
}

