var pathCollection = new Array();
//root is the viewer folder
/*
pathCollection["css/content.css"] = "";
pathCollection["css/content.css"] = belenusHomeRootPath+"css/content.css";
*/

function pathFinder(w, mode, path) { 
	//@w is the window object
	//@mode ["write" | "return" | "jsInclude" | "cssInclude" | "jsCustomInclude" | "cssCustomInclude" | "jsIncludeReturnAsString" | "returnCustomHREF" ]
	//@path ..
	var undef;
	if(path == undef || path == "") {
		alert("The path parameter is not usable!\n\npath: <"+path+">");
	}
	try {
	if(path.indexOf("http://") == 0) return path;
	} catch(e) { return path;}
	var tmpPath = path;
	try {
		tmpPath = (pathCollection[path] == undef || pathCollection[path] == "") ? path : pathCollection[path];
	} catch(e) {}
	
	
	if(tmpPath == path) {
		path = tmpPath = belenusHomeRootPath + path;
	} else { 
		path = belenusHomeRootPath + path;
		tmpPath = belenusHomeRootPath + tmpPath;
	}
	
	if(mode == "write") w.document.write(tmpPath);
	else if(mode == "return") return tmpPath;
	else if(mode == "jsCustomInclude" || mode == "cssCustomInclude") {
		if(mode == "jsCustomInclude") {
			w.document.write('<sc'+'ript type="text/javascript" src="'+path+'"></sc'+'ript>');
			if(path != tmpPath) w.document.write('<sc'+'ript type="text/javascript" src="'+tmpPath+'"></sc'+'ript>'); // debar that the same file is included twice
		}
		if(mode == "cssCustomInclude") {
			w.document.write('<link type="text/css" rel="stylesheet" href="'+path+'">');
			if(path != tmpPath) w.document.write('<link type="text/css" rel="stylesheet" href="'+tmpPath+'">'); // debar that the same file is included twice
		}
	}
	else if(mode == "jsInclude" || mode == "cssInclude") {
		if(mode == "jsInclude") w.document.write('<sc'+'ript type="text/javascript" src="'+tmpPath+'"></sc'+'ript>');
		if(mode == "cssInclude") w.document.write('<link type="text/css" rel="stylesheet" href="'+tmpPath+'">');
	} else if(mode == "jsIncludeReturnAsString") {
		var returningStr = '<sc'+'ript type="text/javascript" src="'+path+'"></sc'+'ript>';
		if(path != tmpPath) returningStr+='<sc'+'ript type="text/javascript" src="'+tmpPath+'"></sc'+'ript>'; // debar that the same file is included twice	
		return returningStr;
	} else if(mode == "returnCustomHREF") {
		if(path != tmpPath) return tmpPath;
		else return null;
	}
	else alert("Unknow pathFinder mode!\nmode: <"+mode+">");
}

function getPath(path) {
	return pathFinder(null,"return",path);
}

function includeJS(w,path) {
	pathFinder(w,"jsCustomInclude",path);
}

function includeCSS(w,path) {
	pathFinder(w,"cssCustomInclude",path);
}

function jsIncludeReturnAsString(path) {
	return pathFinder(null,"jsIncludeReturnAsString",path);
}

function customHREF(path) {
	return pathFinder(null,"returnCustomHREF",path);
}