//* loading js files *//
document.write('<script type="text/javascript" src="includes/js/life.js"></script>');
document.write('<script type="text/javascript" src="includes/js/scriptaculous/lib/prototype.js"></script>');
document.write('<script type="text/javascript" src="includes/js/scriptaculous/src/scriptaculous.js"></script>');
document.write('<script type="text/javascript" src="includes/js/lightbox.js"></script>');

function addDOMLoadEvent(func) {
	if (!window.__load_events) {
		var init = function () {
			// quit if this function has already been called
			if (arguments.callee.done) return;
			// flag this function so we don't do the same thing twice
			arguments.callee.done = true;
			// kill the timer
			if (window.__load_timer) {
				clearInterval(window.__load_timer);
				window.__load_timer = null;
			}
			
			// execute each function in the stack in the order they were added
			for (var i=0;i < window.__load_events.length;i++) {
				window.__load_events[i]();
			}
			window.__load_events = null;
		};
   
		// for Mozilla/Opera9
		if (document.addEventListener) {
			document.addEventListener("DOMContentLoaded", init, false);
		}

		// for Internet Explorer
		/*@cc_on @*/
		/*@if (@_win32)
		document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");
		var script = document.getElementById("__ie_onload");
		script.onreadystatechange = function() {
			if (this.readyState == "complete") {
				init(); // call the onload handler
			}
		};
		/*@end @*/

		// for Safari
		if (/WebKit/i.test(navigator.userAgent)) { // sniff
			window.__load_timer = setInterval(function() {
				if (/loaded|complete/.test(document.readyState)) {
					init(); // call the onload handler
				}
			}, 10);
		}

		// for other browsers
		window.onload = init;
		
		// create event function stack
		window.__load_events = [];
	}
	
	// add function to event stack
	window.__load_events.push(func);
}

function initUI(){
	navRoot = document.getElementById("navigationP");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.className+="navItem";
			node.onmouseover=function() {
				this.className+=" over";
			}
			node.onmouseout=function() {
				this.className=this.className.replace(" over","");
			}
			
			// Enhance non-ie5/6 with png
			elm = node.getElementsByTagName('A');
			for (j=0; j<elm.length; j++) {
				if(!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
				{
					elm[j].className += " no-ie";
				}
			}
			
			// Enhance non-ie5/6 with png
			elm = node.getElementsByTagName('ul');
			for (j=0; j<elm.length; j++) {
				if(!/MSIE (5\.5|6\.)/.test(navigator.userAgent))
				{
					elm[j].className += " no-ie";
				}
			}
		}
	}
	document.getElementById("header").className += " js";
	document.getElementById("content-container").className += " js";
	
	if(document.getElementById("MapBuilder")){
		if (!GBrowserIsCompatible()) 
		{
			document.getElementById("MapBuilderMap").innerHTML = "Unfortunately your browser doesn't support Google Maps.<br /> To check browser compatibility visit the following <a href=\"http://local.google.com/support/bin/answer.py?answer=16532&topic=1499\">link</a>.";
			return;
		}
		map = new GMap2(document.getElementById("MapBuilderMap"));
		var MB = new MapBuilder(map);
		// Render map
		MB.renderMap();
	}
}

addDOMLoadEvent(initUI);
