var vertical=false;
var dst=0;var butonsel = null;
var abuton = 1;
var men = null;
var x = 0,y = 0;
var agt = navigator.userAgent.toLowerCase();
var ie = (agt.indexOf("msie") != -1);
var ns = !ie; // daca nu e ie, atunci e ns6
var par = null;

if (ie) document.onmousedown = clk;
if (ns) document.addEventListener("mousedown", clk, true);

function getx(obj)
{
		var xx = 0, yy=0;
		xx   = obj.offsetLeft;
		yy   = obj.offsetTop;
		par = obj.offsetParent;
		while (par.tagName.toUpperCase() != "BODY")
		{
			xx  += par.offsetLeft;
			yy  += par.offsetTop;
			par = par.offsetParent;
		}
		if (vertical) {
			xx+=obj.offsetWidth;
		}
		return xx;
}

function gety(obj)
{
		var yy = 0,xx=0;
		xx   = obj.offsetLeft;
		yy   = obj.offsetTop;
		par = obj.offsetParent;
		while (par.tagName.toUpperCase() != "BODY")
		{
			xx  += par.offsetLeft;
			yy  += par.offsetTop;
			par = par.offsetParent;
		}
		if (vertical==false) {
			yy+=obj.offsetHeight;
		}
		return yy;
}

function resetall()
{
   if (men!=null)
   {
	men.style.visibility = "hidden";
	men.buton.style.backgroundColor = "";
	if (ns)
	{
		men.buton.style.borderColor= "#C7C7BA";
	}
	else
	{
		men.buton.style.borderColor= "";
	}
	}
	men = null;
}

function clk(event)
{
 if (ie)className = window.event.srcElement.className;
 if (ns)className = event.target.className;
 if (className != "dropdown" && className != "subitem")
 resetall();
}

function mclick(buton, meniu) {
resetall();
  //buton.style.borderColor = "black white white black"
  buton.blur();
  if (!buton.menu)
    buton.menu = document.getElementById(meniu);
  men = buton.menu;
  men.buton = buton;
if (ie)
{
	 x = getx(buton);
	 y = gety(buton) + dst;
}
else
{
	x = buton.offsetLeft ;
	y = buton.offsetTop + buton.offsetHeight + dst;
}
	men.style.visibility = "visible";
	men.style.top = y+"px";
	men.style.left = x+"px";
  return false;
}
