var dropdown = true;
var dDown = null;
var dDownTout;

function loadDropDown()
{
	dropDownArray = document.getElementsByTagName("td");
	
	for(i = 0; i < dropDownArray.length; i++)
	{
		if(dropDownArray[i].getAttribute("drop") != null)
		{
			dropDownArray[i].ddown = document.getElementById(dropDownArray[i].getAttribute("drop"));
			
			if(dropDownArray[i].getAttribute("drop_align") != null)
				dropDownArray[i].alinhamento = dropDownArray[i].getAttribute("drop_align");
			else
				dropDownArray[i].alinhamento = "top_left";

			if(dropDownArray[i].getAttribute("drop_left") != null)
				dropDownArray[i].esquerda = parseInt(dropDownArray[i].getAttribute("drop_left"));
			else
				dropDownArray[i].esquerda = 0;

			if(dropDownArray[i].getAttribute("drop_top") != null)
				dropDownArray[i].topo = parseInt(dropDownArray[i].getAttribute("drop_top"));
			else
				dropDownArray[i].topo = 0;

	
			dropDownArray[i].onmouseover = function()
			{
				
				window.clearTimeout(dDownTout);
				if( (dDown != null) && (dDown != this.ddown) )
				{
					dDown.style.visibility = 'hidden';
				}
				if(this.ddown.style.visibility != 'visible')
				{
					switch(this.alinhamento)
					{
						case "top_left":
											this.ddown.style.left = (findPos(this).x + this.esquerda) + "px";
											this.ddown.style.top = (findPos(this).y + this.topo) + "px";
											break;
											
						case "top_right":
											this.ddown.style.left = (((findPos(this).x + this.offsetWidth) - this.ddown.offsetWidth) + this.esquerda) + "px";
											this.ddown.style.top = (findPos(this).y + this.topo) + "px";
											break;
											
						case "bottom_left":
											this.ddown.style.left = (findPos(this).x + this.esquerda) + "px";
											this.ddown.style.top = (((findPos(this).y + this.offsetHeight) - this.ddown.offsetHeight) + this.topo) + "px";
											break;
											
						case "bottom_right":
											this.ddown.style.left = (((findPos(this).x + this.offsetWidth) - this.ddown.offsetWidth) + this.esquerda) + "px";
											this.ddown.style.top = (((findPos(this).y + this.offsetHeight) - this.ddown.offsetHeight) + this.topo) + "px";
											break;
					}
					this.ddown.style.visibility = 'visible';
				}
			}
			
			dropDownArray[i].onmouseout = function()
			{
				dDown = this.ddown;
				dDownTout = window.setTimeout("dDown.style.visibility = 'hidden'; window.clearTimeout(dDownTout); dDown = null;", 500);
			}
		}
	}
}
