var TimerID=setTimeout('hideCurrentPopup()',0);

function openMyWin(URL,Name,features) {
  x=window.open(URL,Name,features);
}

function TimerS() {
    TimerID=setTimeout('hideCurrentPopup()', 1000);
}

function TimerC() {
    clearTimeout(TimerID);
}

function setPopup(targetObjectId, Xkoor, Ykoor) {
    var newXCoordinate = Xkoor + ((document.body.scrollLeft)?document.body.scrollLeft:0);
    var newYCoordinate = Ykoor + ((document.body.scrollTop)?document.body.scrollTop:0);
//    if (document.body.clientWidth > 775) newXCoordinate += (document.body.clientWidth - 775) / 2;
    moveObject(targetObjectId, newXCoordinate, newYCoordinate);
}

function showPopup (targetObjectId, eventObj) {
    if(eventObj) {
	hideCurrentPopup(); // hide any currently-visible popups
	eventObj.cancelBubble = true; // stop event from bubbling up any farther
	if (changeObjectVisibility(targetObjectId, 'visible')) { // and make it visible
	    window.currentlyVisiblePopup = targetObjectId; // store its Id on a globally-accessible object
	    clearTimeout(TimerID);
	    return true;
	} else {
	    return false; // we couldn't show the popup, boo hoo!
	}
    } else {
	return false; // there was no event object, so we won't be able to position anything, so give up
    }
}

function hideCurrentPopup() {
    if (window.currentlyVisiblePopup) {
	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
	window.currentlyVisiblePopup = false;
    }
    clearTimeout(TimerID);
}

window.onload = initializeHacks; // initialize hacks whenever the page loads
window.onresize = ujraszamol;

function ujraszamol() {
    location.reload(true);
}

function initializeHacks() {
    // resizes a blank div, so you can click anywhere in the window for Mac MSIE 5
    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
	&& (navigator.platform.indexOf('Mac') != -1)
	&& getStyleObject('blankDiv')) {
	window.onresize = explorerMacResizeFix;
    }
    resizeBlankDiv();
    createFakeEventObj(); // this next function creates a placeholder object for older browsers
}

function createFakeEventObj() {
    if (!window.event) { // to avoid errors when we need to pass the event object to functions
	window.event = false;
    }
}

function resizeBlankDiv() {
    // resize blank placeholder div so IE 5 on mac will get all clicks in window
    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 getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if (document.getElementById && document.getElementById(objectId)) { // W3C DOM
	return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {                // MSIE 4 DOM
	return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {          // NN 4 DOM.. note: this won't find nested layers
	return document.layers[objectId];
    } else return false;
}

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.visibility = newVisibility;
	return true;
    } else return false;
} 

function moveObject(objectId, newXCoordinate, newYCoordinate) {
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
	styleObject.left = newXCoordinate;
	styleObject.top = newYCoordinate;
	return true;
    } else return false;
}
