/* Copyright 2009 European Masonic Association - Ref 0001 */
var framesetPage = "index.html";
var currPage = justTheFilename(self.location.pathname);

  if (top.location == self.location && framesetPage != currPage) {
	if (currPage == "left.html" || currPage == "top.html") {
	   currPage = "EMA-Home.html";
	}
	if (currPage != "") {
	  self.location.replace("../" + framesetPage + "?" + currPage) }
	else {
	  self.location.replace(framesetPage + "?" + "EMA-Home.html")
	}
  }

function chgFrame() {
 	if (top.location == self.location && document.location.search) {
		var linkURL = justTheFilename(document.location.search);
		var contentWin = document.getElementById("mainarea").contentWindow;
		var currURL = justTheFilename(contentWin.location.pathname);

		if (currURL != linkURL) {
			contentWin.location.replace("pages/" + linkURL);
		}
	}
}

function justTheFilename(thisFile) {
	if (thisFile.indexOf("/") > -1) {
		thisFile = thisFile.substring(thisFile.lastIndexOf("/")+1);
	}

	if (thisFile.indexOf("?") == 0) {
		thisFile = thisFile.substring(1);
	}

	return thisFile;
}
