var xOffset = 30;
var yOffset = -5;
var isPopIE6 = ((navigator.userAgent.indexOf("MSIE 6.") != -1) && (navigator.userAgent.indexOf("Opera") == -1));

function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
		hideCurrentPopup();
		if (isPopIE6) {
			hideAllSelectsForPop();
		}
		eventObj.cancelBubble = true;
		var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0);
		var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
		//moveObject (targetObjectId, newXCoordinate, newYCoordinate);
		if (changeObjectVisibility (targetObjectId, 'visible') ) {
		    window.currentlyVisiblePopup = targetObjectId;
		    return true;
		} else
		    return false;
    } else
		return false;
}

function hideCurrentPopup() {
	if (isPopIE6) {
		showAllSelectsForPop();
	}
    if (window.currentlyVisiblePopup) {
		changeObjectVisibility (window.currentlyVisiblePopup, 'hidden');
		window.currentlyVisiblePopup = false;
    }
}

//window.onload = initBrowserPopFix;
document.onclick = hideCurrentPopup;

function initBrowserPopFix() {
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
			&& (navigator.platform.indexOf('Mac') != -1)
			&& getStyleObject('blankDiv'))
		window.onresize = explorerMacResizeFix;
    resizeBlankDiv();
    createFakeEventObj();
}

function createFakeEventObj() {
    if (!window.event) {
	window.event = false;
    }
}

function resizeBlankDiv() {
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
    }
}

function explorerMacResizeFix () {
    location.reload(false);
}

function hideAllSelectsForPop() {
	var allSelects = document.getElementsByTagName('select');
	for (var counter=0; counter<allSelects.length; counter++) {
		allSelects[counter].style.visibility = 'hidden';
	}
}

function showAllSelectsForPop() {
	var allSelects = document.getElementsByTagName('select');
	for (var counter=0; counter<allSelects.length; counter++) {
		allSelects[counter].style.visibility = 'visible';
	}
}
