function findPos(objid) {
	obj = document.getElementById(objid);
	if (!obj) {
		frm = document.forms['form'];
		if (frm) obj = frm.elements[objid];
	}
	if (!obj) return false;
	
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curtop, curleft];
}

function findHeight(elid) {
	ct = document.getElementById(elid);
	var h = '0';
	var o;
	var wrong = false;
	if(ct) {
		if((o = document.defaultView) && o.getComputedStyle) {
			h = o.getComputedStyle(ct, null).height;
			if (parseInt(h) != h) wrong = true;
		}
		if(typeof ct.offsetHeight == 'number' || wrong) {
			h = ct.offsetHeight;
		}
	}
	return h;
}

function findWidth(elid) {
	ct = document.getElementById(elid);
	var w = '0';
	var o;
	var wrong = false;
	if(ct) {
		if((o = document.defaultView) && o.getComputedStyle) {
			w = o.getComputedStyle(ct, null).width;
			if (parseInt(w) != w) wrong = true;
		}
		if(typeof ct.offsetWidth == 'number' || wrong) {
			w = ct.offsetWidth;
		}
	}
	return w;
}

function findScrollTop() {
	return filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function showtip(id_act, id_ct) {
	var act_pos = findPos(id_act);
	if (!act_pos) return false;
	var ct_height = findHeight(id_ct);
	ct = document.getElementById(id_ct);
	ct.style.top = (act_pos[0]-parseInt(ct_height))+'px';
	ct.style.left = (act_pos[1]-5)+'px';
	ct.style.visibility = 'visible';
}

function hidetip(id_ct) {
	if (!document.getElementById(id_ct)) return;
	ct = document.getElementById(id_ct);
	ct.style.visibility = 'hidden';
}
