function addEvent(obj, evType, fn) {
	if (obj.addEventListener) {
		obj.addEventListener(evType, fn, false);
		return true;
	} else if (obj.attachEvent) {
		var r = obj.attachEvent("on" + evType, fn);
		return r;
	} else {
		return false;
	}
}

function viewPanorama(fileName) {
	var width = 640;
	var height = 480;

	var xpos = Math.round((window.screen.width / 2) - (width / 2));
	var ypos = Math.round((window.screen.height / 2) - (height / 2));

	if ( xpos < 0 ) { xpos = 0; }
	if ( ypos < 0 ) { ypos = 0; }

	var win_dimensions = "height=" + height + ",width=" + width;
	
	var viewerURL = 'http://www.elizabeth-hotel.hu/wp-content/panorama/panoramaviewer.html';
	
	flashWindow = window.open(viewerURL + "?fileName=" + fileName, "flashWindow", win_dimensions + ",resizable=1,scrollbars=no");
	
	if (flashWindow.moveTo)
		flashWindow.moveTo(xpos, ypos);
	
	if (window.focus)
		flashWindow.focus();
}

function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}

function writeExternalLinks()
{
	if (!document.getElementsByTagName)
		return;
	var anchors = document.getElementsByTagName("a");
	for (var i = 0; i < anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target = "_blank";
		}
	}
}

function mainMenuList() {
	if (document.all&&document.getElementById) {
		navRoot = document.getElementById("mainmenu");
		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			if (node.nodeName=="LI") {
				node.onmouseover=function() {
					this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace(" over", "");
				}
			}
		}
	}
}

function initPage() {
	writeExternalLinks();
	mainMenuList();
}

addEvent(window, "load", initPage);

