
function showMenu(el)
{
	var arr = el.getElementsByTagName('div');
	if (arr.length==0) return;
 	el.style.background='white';
	if(arr[0].childNodes.length>0)
	aj2_showAtElement(arr[0],el,'TR');
}
function hideMenu(el)
{
	var arr = el.getElementsByTagName('div');
	el.style.background='transparent';
	aj2_hide(arr[0]);
}
function aj2_getAbsolutePos(m,el) {
                var SL = 0, ST = 0;
                var is_div = /^div$/i.test(el.tagName);
                if (is_div && el.scrollLeft)
                        SL = el.scrollLeft;
                if (is_div && el.scrollTop)
                        ST = el.scrollTop;
                var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
                if (el.offsetParent) {
                        var tmp = aj2_getAbsolutePos(m,el.offsetParent);
                        r.x += tmp.x;
                        r.y += tmp.y;
                }
                return r;
        };
        function aj2_showAt(m,x, y) {
		if (typeof(m)=="undefined" || m.style==null) return;
                var s = m.style;
		//alert("pos at "+x+"/"+y);
                //s.left = x + "px";
                //s.top = y + "px";
		s.display='block';
		s.top="-22px";
		s.width="0px";
		s.height="0px";
		s.position="relative";

        }
        function aj2_hide(m) {
		if (typeof(m)=="undefined" || m.style==null) return;
                var s = m.style;
                s.display='none';
        }
        function aj2_fixPosition(m,box) {
                if (box.x < 0)
                        box.x = 0;
                if (box.y < 0)
                        box.y = 0;
                var cp = document.createElement("div");
                var s = cp.style;
                s.position = "absolute";
                s.right = s.bottom = s.width = s.height = "0px";
                document.body.appendChild(cp);
                var br = aj2_getAbsolutePos(m,cp);
                document.body.removeChild(cp);
		br.y += box.height;
                var tmp = box.x + box.width - br.x;
                if (tmp > 0) box.x -= tmp;
                tmp = box.y + box.height - br.y;
                //if (tmp > 0) box.y -= tmp;
        };
	/**
	 * Positioniert ELemente 
	 *
	 * @param m Zu positionierendes Element
	 *
	 * @param el Element an dem positioniert wird 
	 *
	 * @param opts Art der Positionierung 
	 *
	 */
var test = 0;
       function aj2_showAtElement (m,el, opts) {
		if ((typeof(m)=="undefined" || m.style==null)) return;
                var p = aj2_getAbsolutePos(m,el);
                if (!opts || typeof opts != "string") {
                        //aj2_showAt(m,p.x, p.y + el.offsetHeight);
                        return true;
                }
                m.style.display = "block";
                continuation = function() {
                        var w = m.offsetWidth;
                        var h = m.offsetHeight;
                        var valign = opts.substr(0, 1);
                        var halign = "l";
                        if (opts.length > 1) {
                                halign = opts.substr(1, 1);
                        }
                        // vertical alignment
                        switch (valign) {
                            case "T": p.y += - h +5; break;
                            case "B": p.y += el.offsetHeight; break;
                            case "C": p.y += (el.offsetHeight - h) / 2; break;
                            case "t": p.y += el.offsetHeight - h; break;
                            case "b": break; // already there
			    case "M": p.y=p.y+el.offsetHeight-(el.offsetHeight-5+m.offsetHeight);break;

                        }
test++;
                        // horizontal alignment
                        switch (halign) {
                            case "L": p.x -= w; break;
                            case "R": p.x += el.offsetWidth-5; break;
                            case "C": p.x += (el.offsetWidth - w) / 2; break;
                            case "l": p.x += el.offsetWidth - w; break;
                            case "r": break; // already there
                        }
                        p.width = w;
                        //p.height = h + 40;
                        //aj2_fixPosition(m,p);
			//alert(w+"/"+h+" "+el.offsetHeight+" m:"+m.offsetHeight+" "+el.offsetWidth+" m:"+m.offsetWidth);
                        aj2_showAt(m,p.x, p.y);
                };
		if(/chrome/i.test(navigator.userAgent.toLowerCase()))
			continuation();
		else if (/Konqueror|Safari|KHTML/i.test(navigator.userAgent))
                        setTimeout("continuation()", 10);
                else 
  			continuation();
        }
