// JavaScript Document

var Utils = {
	Id: function(arg0)
	{
		if(typeof(arg0) != "string")
		{
			try { return arg0; }
			catch(ex) { window.status = "Elemento "	 + arg0.toString() + " não pôde ser indentificado."; }
		}
 		else
		{
			try { return document.getElementById(arg0); }
			catch(ex) { window.status = "Elemento "	 + arg0 + " não pôde ser indentificado."; }
		}
	},
	AddEvent: function(target, eventName, handlerName)
	{
		if ( target.addEventListener )
			target.addEventListener(eventName, handlerName, false);
		else if ( target.attachEvent )
			target.attachEvent("on" + eventName, handlerName);
		else
			target["on" + eventName] = handlerName;
	},
	RemoveEvent: function(target, eventName, handlerName)
	{
		if ( target.addEventListener )
			target.RemoveEventListener(eventName, handlerName, false);
		else if ( target.attachEvent )
			target.dettachEvent("on" + eventName, handlerName);
		else
			target["on" + eventName] = null;
	},
	GetKeyCode: function(e)
	{
		var keyCode;
		if (!e && window.event)
			e = window.event;

		if (e)
			keyCode = (window.Event) ? e.which : e.keyCode;
		return keyCode;
	}
};

Object.prototype.ShowTab = function()
{
	Menu.HideFirstChilds();
	try
	{
		this.parentNode.getElementsByTagName("ul")[0].style.display = "block";	
	}
	catch(ex)
	{
		alert("Não foi possível definir " + this);
		return false;
	}
}

function ShowTab2(o)
{
	Menu.HideFirstChilds();
	try
	{
		o.parentNode.getElementsByTagName("ul")[0].style.display = "block";	
	}
	catch(ex)
	{
		alert("Não foi possível definir " + o);
		return false;
	}
}

var Menu = {
	Id: null,
	FirstChilds: [],
	HideFirstChilds: function()
	{
		var i, temp;
		for(i = 0; i < Menu.FirstChilds.length; i++)
		{
			temp = Menu.FirstChilds[i].getElementsByTagName("a")[0].parentNode.getElementsByTagName("ul")[0];
			temp.style.display = "none";
		}
	},
	Init: function(myMenu)
	{
		this.Id 			= Utils.Id(myMenu);
		var temp, tempA, i, j, header;

		header = Utils.Id("box-header");
		
		for(i = 0; i < this.Id.getElementsByTagName("li").length; i++)
		{
			temp = this.Id.getElementsByTagName("li")[i];
			if(temp.className.indexOf("nav-lis") > -1)
			{
				this.FirstChilds.push(temp);
			}
		}

		for(j = 0; j < this.FirstChilds.length; j++)
		{
			tempA = this.FirstChilds[j].getElementsByTagName("a")[0];
			//Utils.AddEvent(header, "mouseout", Menu.HideFirstChilds);
			//Utils.AddEvent(Utils.Id("box-header"), "mouseover", this.HideFirstChilds);
			//Utils.AddEvent(tempA, "mouseover", this.ShowTab(tempA));
			try
			{
				Utils.AddEvent(tempA, "mouseover", tempA.ShowTab);
			}
			catch(e)
			{
				tempA.onmouseover = function() {
					ShowTab2(this);
				}
				
			}
		}
	}
};

var Clock = {
	CurrentTime: null,
	CurrentHours: null,
	CurrentMinutes: null,
	CurrentSeconds: null,
	Update: function()
	{
		this.CurrentTime 	= new Date();
		this.CurrentHours	= (this.CurrentTime.getHours() < 10)	? "0" + this.CurrentTime.getHours().toString()		: this.CurrentTime.getHours();
		this.CurrentMinutes	= (this.CurrentTime.getMinutes() < 10)	? "0" + this.CurrentTime.getMinutes().toString()	: this.CurrentTime.getMinutes();
		this.CurrentSeconds	= (this.CurrentTime.getSeconds() < 10)	? "0" + this.CurrentTime.getSeconds().toString()	: this.CurrentTime.getSeconds();

		Utils.Id("box-clock").innerHTML = this.CurrentHours + ":" + this.CurrentMinutes + ":" + this.CurrentSeconds;		
	},
	Init: function()
	{
		setInterval(Clock.Update, 1000);	
	}
};





