function getRealLeft(el) {
    xPos = el.offsetLeft;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        xPos += tempEl.offsetLeft;
        tempEl = tempEl.offsetParent;
    }
    return xPos;
}

function getRealTop(el) {
    yPos = el.offsetTop;
    tempEl = el.offsetParent;
    while (tempEl != null) {
        yPos += tempEl.offsetTop;
        tempEl = tempEl.offsetParent;
    }
    return yPos;
}

function flipSwitch(textId){
	
	thisText = document.getElementById(textId+'Extra');
	thisButton = document.getElementById(textId+'Button');
	flipMode = thisText.style.display;
	
	if (flipMode == "none"){
		thisText.style.display = 'inline';
		thisText.style.visibility = 'visible';
		thisButton.src = 'images/collapse.gif';
	}
	else {
		thisText.style.display = 'none';
		thisText.style.visibility = 'hidden';
		thisButton.src = 'images/expand.gif';
	}
	
}

function displayText(textId,mode){

	thisText = document.getElementById(textId+'Extra');
	thisAnchor = document.getElementById(textId);
	docWidth = document.body.clientWidth;
	docHeight = document.body.clientHeight;
	thisTop = getRealTop(thisAnchor);
	thisLeft = getRealLeft(thisAnchor);
	
	if (docHeight < (parseInt(thisTop) + parseInt(thisText.style.height))){
		thisTop = parseInt(thisTop) - (parseInt(thisText.style.height) + 50);
	}
	else {
		thisTop = parseInt(thisTop) + 30;
	}

	if (docWidth < (parseInt(thisLeft) + parseInt(thisText.style.width))){
		thisLeft = parseInt(thisLeft) - (parseInt(thisText.style.width) - 20);
	}
	
	thisText.style.position = 'absolute';

	if (mode == "S"){
		thisText.style.display = 'inline';
		thisText.style.visibility = 'visible';
		thisText.style.top = thisTop;
		thisText.style.left = thisLeft;
	}
	else {
		thisText.style.display = 'none';
		thisText.style.visibility = 'hidden';
	}

}

function highlight(tblName,row,cols,status) {
	if (status == 1 || status == '1'){
		color = "#C4E5F6";
	}
	else {
		color = "#FFF";
	}
	for (i=1;i<=cols;i++) {
		document.getElementById(tblName+row+"."+i).style.backgroundColor = color;
	}
}