/*
	Loaded by content frame
*/

function getLMHomePage() {
	// Get URI current dir
	var homeDir = getDirFromLocation(window.location)
	
	if (homeDir) {
		var strDoc = 'documentation'
		var i = homeDir.lastIndexOf(strDoc)
		if (i >= 0) 
			homeDir = homeDir.substr(0, i + strDoc.length)
		else {
			var strLM = 'LazyMirror'
			i = homeDir.lastIndexOf(strLM)
			if (i >= 0)
				homeDir = homeDir.substring(0, i + strLM.length)
		}
		return homeDir + '/index.html'
	}
	return false
}

function doLoad() {
	if (parent.name != "index") {
		var homePage = getLMHomePage()
		if (homePage) 
			window.location = homePage + "?url=" + escape(getContentURL(homePage, window.location))
	} else {
		// Running in frame, add title to main frame
		parent.document.title = document.title
	}
}

