//* 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/image.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 getFlashMovie(movieName){
	var isIE = navigator.appName.indexOf("Microsoft") != -1;
	return (isIE) ? window[movieName] : document[movieName];
}

function initUI(){
	var pEl = document.getElementById("navigation");
	var j = 1;
	
	// Do not display any navigation yet!!
	for(var i=0; i<pEl.childNodes.length; i++){
		
		if(pEl.childNodes[i].className=='item main'&&pEl.childNodes[i+1].className=='submenu'){
			pEl.childNodes[i+1].style.display = "none";
			pEl.childNodes[i+1].id = 'submenu'+j;
			pEl.childNodes[i].number = j;
			pEl.childNodes[i].onclick = function(){
					Effect.toggle('submenu'+this.number,'slide');
			}
			j++;
		}
	}
	
	// Process main navigation
	/*var j = 1;
	
	for(i = 0;i<elements.length;i++){
		if(elements[i].className == "item main"){
			
			elements[i].number = j;
			elements[i].onclick = function(){
					Effect.toggle('submenu'+this.number,'slide');
			}
			
			j++;
			if(j==5){
				break;
			}
		}
	}*/
	
	// Process mouseovers
	elements=pEl.getElementsByTagName("DIV")
	for(i = 0;i<elements.length;i++){
		if(/item/i.test(elements[i].className)){
			elements[i].onmouseover = function(){
				this.className += ' over';
			}
			elements[i].onmouseout = function(){
				this.className = this.className.replace(' over','');
			}
		}
	}
}

addDOMLoadEvent(initUI);