var ie5=((document.all) && !(window.opera));
var ns4 = document.layers;
var op5 = (navigator.userAgent.indexOf("Opera 5")!=-1) 
		||(navigator.userAgent.indexOf("Opera/5")!=-1);

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
	}
	return [curleft,curtop];
}

var showing_id = -1;
function show(o,id){
	
	if((showing_id>-1) && (showing_id!=id)) { hide(showing_id);}
	document.getElementById('menu'+id).style.display='block';
	p = findPos(o);
	if(o.offsetTop) document.getElementById('menu'+id).style.top=p[1]+"px";
	document.getElementById('menu'+id).style.left=(getElementWidth(o))+"px";
	//alert(getElementWidth(o));
	showing_id = id;
}
function hide(){
	if(showing_id !=-1) {
		document.getElementById('menu'+showing_id).style.display='none';
		showing_id = -1;
	}
}

function getElementWidth(Elem) {
	if (ns4) {
		var elem = getObjNN4(document, Elem);
		return elem.clip.width;
	} else {
		if(document.getElementById) {
			var elem = document.getElementById(Elem);
		} else if (document.all){
			var elem = document.all[Elem];
		}
		if (op5) {
			xPos = elem.style.pixelWidth;
		} else {
			if(Elem.clientWidth) xPos = Elem.clientWidth; 
			//xPos = elem.offsetWidth;
		}
		return xPos;
	}
}

