function AppRootURL(sTopDirs) {
  // sTopDirs = "examples|test|includes"

	var reTopDirs = new RegExp(sTopDirs,"i");
	var aLvls = window.location.pathname.split("/");
	aLvls.pop(); //remove file name
	for ( var x = aLvls.length - 1 ; x >= 0 ; x-- ) {
		if ( reTopDirs.test(aLvls[x]) ) {
			aLvls.pop();
		}
	}
  return "http://" + window.location.host + aLvls.join("/");
} // AppRootURL()

