// JavaScript Document

var Menu = {
	active: {
		button: null,
		sub: null,
		menu: null
	},
	subtimer: null,

	menutimer: null,
	
	subListHover: function(subID){
	},

	subListOut: function(subID){
		//var sub = document.getElementById(subID);
		//sub.style.left = "-200px";
	},
	
	light: function(parentID, subID){
		
		var menuBtn = document.getElementById(parentID);
		menuBtn.style.backgroundIColor = "";
		if(this.active.button){
			if(this.active.button != parentID){
				this.hideSub();
			}
		}

		clearInterval(this.menutimer);
		this.active.button = parentID;
		this.active.sub = subID;
		if(this.active.menu){
			this.showSub();
		}

	},

	dark: function(parentID, subID){
		var menuBtn = document.getElementById(parentID);
		menuBtn.style.backgroundColor = "";
		this.menutimer = setTimeout("Menu.timer()", 200);
	},

	subListHover: function(subID){
	},

	subListOut: function(subID){
		//var sub = document.getElementById(subID);
		//sub.style.left = "-200px";
	},


	click: function(noSub){
		var sub = document.getElementById(this.active.sub);
		if(this.active.menu){
			this.hideSub();
			this.active.menu = null;
		}else{
			this.showSub();
			this.active.menu = true;
		}
		
		if(noSub == 0){
			this.active.menu = null;
			this.active.button = null;
			this.hideSub();
		}
		

	},
	sublight: function(){
		clearInterval(this.menutimer);
	},

	subdark: function(){
		this.menutimer = setTimeout("Menu.timer()", 200);
	},
	
	showSub: function(){

		var menuBtn = document.getElementById(this.active.button);
		var sub = document.getElementById(this.active.sub);
		var leftPos = 0;

		while (menuBtn != null){                                           
			leftPos += menuBtn.offsetLeft;      
			menuBtn = menuBtn.offsetParent;
		}

		sub.style.left = leftPos+"px";
	},

	hideSub: function(){
		var menuBtn = document.getElementById(this.active.button);
		var sub = document.getElementById(this.active.sub);
		sub.style.left = "-200px";
	},

	timer: function(){
		this.active.menu = null;
		this.active.button = null;
		this.hideSub();
	},

	dblclick: function(url){
		window.location.href = url;
	}

};

