/* Uster JS */
/* (c) 2005 by Tim Kask (tim.kask@i-web.ch) */

function tdaction(e, type, element_id, menunr, nav_level, current_page) {
	var loc_type = (current_page?'over':type);
	document.getElementById(element_id).style.backgroundColor = navColor[nav_level][loc_type];
	if (nav_level == 1) {
		document.getElementById(element_id+'img').src = navipfeil[loc_type];
	}

	if (nav_level == 1) {
		if (type == 'over') {
			popUp('elMenu' + menunr, e);
		} else {
			popDown('elMenu' + menunr);
		}
	}
}

// Find the x,y location in pixels for a relatively positioned object
// returns an object with .x and .y properties.
function FindXY(obj){
    var x=0,y=0;
    while (obj!=null){
        x+=obj.offsetLeft-obj.scrollLeft;
        y+=obj.offsetTop-obj.scrollTop;
        obj=obj.offsetParent;
    }
    return {x:x,y:y};
}

// Find the x,y location in pixels for a relatively positioned object
// returns an object with .x, .y, .w (width) and .h (height) properties.
function FindXYWH(obj){
    var objXY = FindXY(obj);
    return objXY?{ x:objXY.x, y:objXY.y, w:obj.offsetWidth, h:obj.offsetHeight }:{ x:0, y:0, w:0, h:0 };
}

function getTop(e) {
	var pos_y = (HM_IE) ? (e.clientY + HM_IEcanvas.scrollTop - 1)  : e.pageY;
	var out_y = pos_y;

	// go thru all the navi1 elements, check if the x is within, if so, return that position
	var el = 0;
	while (document.getElementsByTagName("td")[el]) {
		if (document.getElementsByTagName("td")[el].id.substr(0,4) == 'nav1') {
			dim = FindXYWH(document.getElementsByTagName("td")[el]);
			if ((pos_y >= dim.y) && (pos_y <= dim.y + dim.w)) {
				out_y = dim.y;
				el = 100;
			}
		}
		el++;
	}

	return(out_y);
}

