// Interface.js
function celloIFInit() {
	// change the contents of the main frame if there is a search term (queryString) contained in
	// the URL with an opening doc specified.
	var startPage = docQueryString();
	var source;
	if (startPage) {
		source = startPage;
	} else if (window.startDoc) {
		source = window.startDoc;	
	}
	if (source) {
		// need to do it this way to stop Mozilla from getting consued with onload handlers
		setTimeout(function() { loadContent(source); }, 1);		
	}
}
function loadContent(source) {
	document.getElementById("mainFrame").src = source;	
}
function docQueryString() {
	var qs;
	if ((qs = window.top.location.search) && qs.indexOf("?doc=") == 0 && qs.length > 5) {
		// get rid of the ?doc= at the start of the string
		return qs.substring(5);
	}
	return undefined;
}
// once loading of the document is complete, initialise the cello interface:
window.onload = function() {
	celloIFInit();
};



