//
// ds_util.js AddOn for menue relative positioning
//
function stringToNumber(s){
	return parseInt(('0' + s), 10);
}
function getEl(){
	if (ie4) {
		if (arguments.length && arguments[0])
			return document.all[arguments[0]];
		else
			return event.srcElement.parentElement;
	} else if (oper || ns5) {
		if (arguments.length && arguments[0]) {
			return document.getElementById(arguments[0]);
		}
	}
}

function getAbsPos(el) {
	var mPos, sPos, i;
	if (arguments.length > 1) {
		mPos = arguments[1].split(",");
	} else {
		mPos = new Array(0,0,0,0);
		if (oper) {
			mPos[2] = el.style.pixelWidth;
			mPos[3] = el.style.pixelHeight;
		} else if (ie4) {
			mPos[2] = el.offsetWidth;
			mPos[3] = el.offsetHeight;
		} else {
		 	if (el.style.width) mPos[2] = stringToNumber(el.style.width);
		   else mPos[2] = stringToNumber(el.offsetWidth);
		 	if (el.style.height) mPos[3] = stringToNumber(el.style.height);
		   else mPos[3] = stringToNumber(el.offsetHeight);
		}
	}
	sPos = (parseInt(mPos[0]) + el.offsetLeft) + "," + (parseInt(mPos[1]) + el.offsetTop) + "," + mPos[2] + "," + mPos[3];
	if (el.offsetParent) {return getAbsPos(el.offsetParent, sPos);}
	return sPos;
}

function getPos(el, p){
	var mPos = getAbsPos(el).split(",");
	var rc;
	if (p=='l') rc = mPos[0];
	else if (p=='t') rc = mPos[1];
	else if (p=='r') rc = parseInt(mPos[0]) + parseInt(mPos[2]);
	else if (p=='b') rc = parseInt(mPos[1]) + parseInt(mPos[3]);
	return parseInt(rc);
}

function xl(){
	return getPos(getEl(arguments[0]), "l");
}
function yb(){
	return getPos(getEl(arguments[0]), "b");
}
function xr(){
	return getPos(getEl(arguments[0]), "r");
}
function yt(){
	return getPos(getEl(arguments[0]), "t");
}
