scServices.currentPage = scOnLoads[scOnLoads.length] = {
	fActive : true,
	fCurrentHash : "",
	fBaseUrl : (scUrlToLoad ? scUrlToLoad : scServices.scLoad.getUrlFromRoot(scCoLib.hrefBase())),

	set : function(pUrl) {
		const vPge = pUrl.substring(pUrl.lastIndexOf("/") + 1);
		const vNewHash = vPge.substring(0, vPge.lastIndexOf("."));
		if (this.fActive){
			this.fCurrentHash = vNewHash;
			window.location.replace(scCoLib.hrefBase() + "#" + vNewHash);
		} else if(window.location.hash.length > 0){
			const vHash = decodeURIComponent(window.location.hash).substring(1);
			if (vHash!=vNewHash) history.replaceState(null, null, ' ');
		}
	},
	enable : function() {
		this.fActive = true;
	},
	disable : function() {
		this.fActive = false;
	},
	hashChange : function() {
		if(window.location.hash.length > 0){
			const vHash = decodeURIComponent(window.location.hash).substring(1);
			if (vHash == this.fCurrentHash) return;
			const vPageUrl = this.fBaseUrl.substring(0, this.fBaseUrl.lastIndexOf("/") + 1) + vHash + this.fBaseUrl.substring(this.fBaseUrl.lastIndexOf("."));
			try {
				const vReq = new XMLHttpRequest();
				vReq.onreadystatechange = function () {
					if (vReq.readyState != 4) return;
					if (vReq.status != 0 && vReq.status != 200 && vReq.status != 304) {
						return;
					}
					sc$("mainFrame").src = vPageUrl;
				}
				vReq.open("GET",vPageUrl,false);
				vReq.send();
			} catch(e){}
		}
	},
	onLoad : function() {
		try {
			if(window.location.hash.length > 0){
				const vHash = decodeURIComponent(window.location.hash).substring(1);
				const vPageUrl = this.fBaseUrl.substring(0, this.fBaseUrl.lastIndexOf("/") + 1) + vHash + this.fBaseUrl.substring(this.fBaseUrl.lastIndexOf("."));
				try {
					const vReq = new XMLHttpRequest();
					vReq.onreadystatechange = function () {
						if (vReq.readyState != 4) return;
						if (vReq.status != 0 && vReq.status != 200 && vReq.status != 304) {
							return;
						}
						scUrlToLoad = vPageUrl;
					}
					vReq.open("GET",scServices.scLoad.resolveDestUri("/" + vPageUrl),false);
					vReq.send();
				} catch(e){}
			}
		} catch (e) {
			console.log("scServices.currentPage.onLoad : " + e);
		}
	},
	loadSortKey : "1currentPage"
}
window.addEventListener("hashchange", function(pEvt) {
	scServices.currentPage.hashChange();
});