function Dora_getServerPath() {
	var lh = location.href;
	var serverPath = "";

	if (lh.indexOf("file://") != -1)
		serverPath = Dora.UP_RELATIVE_PATH;
	else
		serverPath = "http://" + location.host + "/";

	return serverPath
}

function Dora_getRedirectFramePath() {
	return Dora_getServerPath() + Dora.redirectFrameDir + "/" + Dora.redirectFrame;
}

function Dora_isRequiredFrame(dirName) {
	for (var i in Dora.requiredFrameDirs) {
		if (Dora.requiredFrameDirs[i] == dirName) {
			return true;
		}
	}

	return false;
}

function Dora_inDirs(dirName) {
	if ((dirName == null) || (dirName == "")) return false;

	for (var i in Dora.Dirs) {
		if (Dora.Dirs[i] == dirName) {
			return true;
		}
	}

	return false;
}

function Dora_isCgiLocation() {
	return (location.href.indexOf(this.getServerPath() + "bin/") > -1);
}

function Dora_isIndexFile(fileName) {
	return (fileName == "") || (fileName.indexOf("index.html") > -1) || (fileName.indexOf("index.php") > -1);
}

function Dora_getNavigationFileName(file) {
	var buffFile = file.substring(0, file.indexOf('.'));
	var buffExt  = file.substring(file.indexOf('.'), file.length);

	return buffFile + Dora.NAVI_SUFFIX + buffExt;
}

function Dora_isHomeDir(dir) {
	return Dora.HOME_DIR == dir;
}

function Dora_topFrameExixts() {
	return ((top.frames.length != 0) &&
			(top.header != null) &&
			(top.menu != null) &&
			(top.contents != null));
}

function Dora_systemFrameExixts() {
	return (Dora.topFrameExixts() &&
			(top.contents.navi != null) &&
			(top.contents.desc != null));
}

function Dora_getQuery(dir, file) {
	function getDelimitChar(com) {
		if (com == "") {
			return "?";
		} else {
			return "&";
		}
	}

	var command = "";

	if ((dir != null) && (dir != "")) {
		command += getDelimitChar(command) + Dora.KEY_DIR + "=" + dir;
	}

	if ((file != null) && (file != "")) {
		command += getDelimitChar(command) + Dora.KEY_FILE + "=" + file;
	}

	return command;
}

function Dora() {
}
new Dora();

Dora.isHomeDir = Dora_isHomeDir;
Dora.isRequiredFrame = Dora_isRequiredFrame;
Dora.topFrameExixts = Dora_topFrameExixts;
Dora.systemFrameExixts = Dora_systemFrameExixts;
Dora.getQuery = Dora_getQuery;
Dora.getServerPath = Dora_getServerPath;
Dora.getNavigationFileName = Dora_getNavigationFileName;
Dora.getRedirectFramePath = Dora_getRedirectFramePath;
Dora.isCgiLocation = Dora_isCgiLocation
Dora.isIndexFile = Dora_isIndexFile
Dora.inDirs = Dora_inDirs;

Dora.requiredFrameDirs = new Array("character", "item", "link", "place", "data");
Dora.Dirs = new Array("bbs", "character", "data", "mitamama", "family_tree", "link", "nazo", "nobi_house", "place", "quiz", "about", "search", "spec", "item");
Dora.redirectFrame = "redirect-frame.html";
Dora.redirectFrameDir = "redirect";
Dora.HOME_DIR = "dsdb.jp";
Dora.KEY_FILE = "file";
Dora.KEY_DIR = "dir";
Dora.UP_RELATIVE_PATH = "../";
Dora.NAVI_SUFFIX = "-navi";
