var horizontal = 0;
var idm = new Array();

function largura(o){
	return o.offsetWidth;	
}

function altura(o){
	return o.offsetHeight;
}

function findPosYy(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	var iTop = 0;
    while(obj.tagName != "BODY") {
       	iTop += obj.offsetTop;
    	obj = obj.offsetParent;
 	}
	//if(_jslib_isIE){
	//	return obj.offsetTop;
	//}else{
		return obj.offsetTop
		//return iTop;
	//}
}

function findPosXx(obj) {
	obj = (!jsGetObject(obj)) ? obj : jsGetObject(obj);
	
		/*var curleft = 0;
		if (obj.offsetParent) {
			while (obj.offsetParent) {
				curleft += obj.offsetLeft;
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
		curleft += obj.x;
		
	return curleft;*/
	return obj.offsetLeft;
	
}

function posmenuTop(o,om){
	if(!horizontal){
		return  (findPosYy(o) + altura(o));
	}else{
		return  (findPosYy(o));
	}
}
function posmenuLeft(o,om){	

	if(horizontal){
		//alert("aca "+findPosXx(o) + largura(o) );
		return  (findPosXx(o) + largura(o));
	}else{
		//alert("alla "+findPosXx(o) );
		return  (findPosXx(o));
	}
}

function pos(om,o,h){
	if(h){
		horizontal = h;
	}else{
		horizontal = 0;
	}
	jsGetObject(om).style.display = 'block';
	jsGetObject(om).style.top = posmenuTop(o)+'px';		
	jsGetObject(om).style.left = (posmenuLeft(o))+'px';
}


function fechar(o){
		var n = o.getAttribute('indice');
		var m = o.getAttribute('idsubmenu');
		var funcao = 'delay("'+m+'");';
		idm[n]=window.setTimeout(funcao,1000);
}

function fecharsub(m,n){
		var funcao = 'delay("'+m+'");';
		idm[n]=window.setTimeout(funcao,500);
}

function delay(o){
	//if(o!=null){
		jsGetObject(o).style.display = 'none';
	//}
}

function manter(n){
	window.clearTimeout(idm[n]);	
}