//=================================================
// Browser detection
if (document.all)
	var browser = 'IE';		// Internet Explorer
else if (document.layers)
	var browser = 'NN';		// Netscape <=4
else if (document.getElementById)
	var browser = 'GECKO';	// Gecko-based browsers


//=================================================
// CSS hiding of javascript onload action borrowed from John Serris - http://phonophunk.com/
var d = document;
var dE = d.documentElement;
dE.className = "preLoad";		// Hide DOM manipulation by JS until completed


//=================================================
// Pause for milliseconds
function pause(mSec) {
	date = new Date();
	var curDate = null;
	
	do { var curDate = new Date(); }
	while(curDate - date < mSec);
}

//=================================================
// Global
var global = new Object();		// Global object
global = {};
global.pageLoading = function() {
/*		rootNode = document.getElementsByTagName("body")[0];
		var parentNode = document.createElement("div");
		parentNode.id = "loading";
		var childNode = document.createElement("h2");
		var textNode = document.createTextNode("Downloading...");
		childNode.appendChild(textNode);
		parentNode.appendChild(childNode);
		rootNode.appendChild(parentNode);*/
		
//		rootNode = document.getElementById("loading");
//		rootNode.innerHTML = "<h2>Downloading</h2>";
//		alert("first");
}

// Return an element where the method varies by browser
global.getID = function(id) {
	if (browser=='IE')
		return document.all[id];
	else if (browser=='NN')
		return window.document[id];
	else if (browser=='GECKO')
		return document.getElementById(id);
}

global.pageLoaded = function() {
	parentNode = document.getElementsByTagName("body")[0];
	childNode = global.getID("loading");
	parentNode.removeChild(childNode);
}

global.init = function() {
	if (d.getElementById) {
		// preLoad stuff here:
		themes.onload();
		global.pageLoading();
		local.init();
//		pause(3000);
		// postLoad stuff here:
		global.pageLoaded();
		dE.className = "postLoad";
	}
}

global.end = function() {
//		fixIELeaks();
		themes.onunload();
}

window.onload = global.init;
window.onunload = global.end;