var ua = navigator.userAgent;
var opera = /opera [56789]|opera\/[56789]/i.test(ua);
var ie = !opera && /MSIE/.test(ua);
var ie50 = ie && /MSIE 5\.[01234]/.test(ua);
var ie6 = ie && /MSIE [6789]/.test(ua);
var ie7 = ie && /MSIE [789]/.test(ua);
 
  var ieBox = ie && (document.compatMode == null || document.compatMode != "CSS1Compat"); var moz = !opera && /gecko/i.test(ua); var nn6 = !opera && /netscape.*6\./i.test(ua);
mdw = 120; mdbl = 1; mdbr = 1; mdbt = 1; mdbb = 1; mdpl = 1; mdpr = 1; mdpt = 1; mdpb = 1;
wmDefaultShadowLeft = 0; wmDefaultShadowRight = ie && !ie50 && /win32/i.test(navigator.platform) ? 4 :0;
wmDefaultShadowTop = 0; wmDefaultShadowBottom = ie && !ie50 && /win32/i.test(navigator.platform) ? 4 : 0;
miDefaultHeight = 18; miDefaultText = "x"; miDefaultHref = "#"; wmSeparatorDefaultHeight = 6;
wmDefaultEmptyText = "Leer"; wmDefaultUseAutoPosition = nn6 ? false : true; wmImagePath = "";
wmUseHover = opera ? true : false; wmHideTime = 500; wmShowTime = 0;
var wmHandler = { idCounter : 0, idPrefix : "webfx-menu-object-", all : {}, getId : function () { return this.idPrefix + this.idCounter++; }, overMenuItem : function (oItem) {
if (this.showTimeout != null) window.clearTimeout(this.showTimeout);
if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout);
var jsItem = this.all[oItem.id]; if (wmShowTime <= 0) this._over(jsItem);
else this.showTimeout = window.setTimeout("wmHandler._over(wmHandler.all['" + jsItem.id + "'])", wmShowTime);
},
outMenuItem : function (oItem) {
 if (this.showTimeout != null) window.clearTimeout(this.showTimeout);
 if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout);
 var jsItem = this.all[oItem.id]; if (wmHideTime <= 0) this._out(jsItem);
 else this.hideTimeout = window.setTimeout("wmHandler._out(wmHandler.all['" + jsItem.id + "'])", wmHideTime);
},
 blurMenu : function (oMenuItem) { window.setTimeout("wmHandler.all[\"" + oMenuItem.id + "\"].subMenu.hide();", wmHideTime); },
 _over : function (jsItem) { if (jsItem.subMenu) { jsItem.parentMenu.hideAllSubs(); jsItem.subMenu.show(); } else jsItem.parentMenu.hideAllSubs(); },
 _out : function (jsItem) {
 var root = jsItem; var m; if (root instanceof mb) m = root.subMenu;
 else { m = jsItem.parentMenu; while (m.parentMenu != null && !(m.parentMenu instanceof wmBar)) m = m.parentMenu; }
 if (m != null) m.hide();	
},
 hideMenu : function (menu) {
  if (this.showTimeout != null) window.clearTimeout(this.showTimeout);
  if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout);
  this.hideTimeout = window.setTimeout("wmHandler.all['" + menu.id + "'].hide()", wmHideTime);
 },
 showMenu : function (menu, src, dir) {
  if (this.showTimeout != null) window.clearTimeout(this.showTimeout);
  if (this.hideTimeout != null) window.clearTimeout(this.hideTimeout);
  if (arguments.length < 3) dir = "vertical";
  menu.show(src, dir);
 } };
function wm() {this._menuItems=[];this._subMenus=[];this.id=wmHandler.getId();this.top=0;this.left=0;this.shown=false;this.parentMenu=null;wmHandler.all[this.id]=this;}
wm.prototype.width = mdw; wm.prototype.emptyText = wmDefaultEmptyText;
wm.prototype.useAutoPosition = wmDefaultUseAutoPosition; wm.prototype.borderLeft = mdbl;
wm.prototype.borderRight = mdbr; wm.prototype.borderTop = mdbt;
wm.prototype.borderBottom = mdbb; wm.prototype.paddingLeft = mdpl;
wm.prototype.paddingRight = mdpr; wm.prototype.paddingTop = mdpt;
wm.prototype.paddingBottom = mdpb; wm.prototype.shadowLeft	= wmDefaultShadowLeft;
wm.prototype.shadowRight = wmDefaultShadowRight; wm.prototype.shadowTop = wmDefaultShadowTop;
wm.prototype.shadowBottom = wmDefaultShadowBottom;
wm.prototype.add = function (menuItem) {
 this._menuItems[this._menuItems.length] = menuItem;
 if (menuItem.subMenu) { this._subMenus[this._subMenus.length] = menuItem.subMenu; menuItem.subMenu.parentMenu = this; } menuItem.parentMenu = this;
};
wm.prototype.show = function (relObj, sDir) {
 if (this.useAutoPosition) this.position(relObj, sDir);
 var divElement = document.getElementById(this.id);
 divElement.style.left = opera ? this.left : this.left + "px";
 divElement.style.top = opera ? this.top : this.top + "px";
 divElement.style.visibility = "visible";
 this.shown = true; if (this.parentMenu) this.parentMenu.show();
};
wm.prototype.hide = function () { this.hideAllSubs(); var divElement = document.getElementById(this.id); divElement.style.visibility = "hidden";	this.shown = false; };
wm.prototype.hideAllSubs = function () { for (var i = 0; i < this._subMenus.length; i++) { if (this._subMenus[i].shown) this._subMenus[i].hide(); } };
wm.prototype.toString = function () {
 var top = this.top + this.borderTop + this.paddingTop;
 var str = "<div id='" + this.id + "' class='webfx-menu' style='" +  "width:" + (!ieBox  ?
		this.width - this.borderLeft - this.paddingLeft - this.borderRight - this.paddingRight  : 
		this.width) + "px;" + (this.useAutoPosition ? "left:" + this.left + "px;" + "top:" + this.top + "px;" :
		"") + (ie50 ? "filter: none;" : "") +	"'>";
 if (this._menuItems.length == 0) { str += "<span class='webfx-menu-empty'>" + this.emptyText + "</span>"; } else {	
  for (var i = 0; i < this._menuItems.length; i++) {
   var mi = this._menuItems[i];
   str += mi;
   if (!this.useAutoPosition) {
    if (mi.subMenu && !mi.subMenu.useAutoPosition) mi.subMenu.top = top - mi.subMenu.borderTop - mi.subMenu.paddingTop;
    top += mi.height;
   } } }
 str += "</div>";
 for (var i = 0; i < this._subMenus.length; i++) { this._subMenus[i].left = this.left + this.width - this._subMenus[i].borderLeft; str += this._subMenus[i]; }
 return str;
};
function mi(sText, sHref, sToolTip, oSubMenu) {
 this.text = sText || miDefaultText; this.href = (sHref == null || sHref == "") ? miDefaultHref : sHref;
 this.subMenu = oSubMenu; if (oSubMenu) oSubMenu.parentMenuItem = this;
 this.toolTip = sToolTip; this.id = wmHandler.getId(); wmHandler.all[this.id] = this;
};
mi.prototype.height = miDefaultHeight;
mi.prototype.toString = function () {
 return	"<a" + " id='" + this.id + "'" + " href='" + this.href + "'" +
			(this.toolTip ? " title='" + this.toolTip + "'" : "") +
			" onmouseover='wmHandler.overMenuItem(this)'" +
			(wmUseHover ? " onmouseout='wmHandler.outMenuItem(this)'" : "") +
			(this.subMenu ? " unselectable='on' tabindex='-1'" : "") +
			">" +
			(this.subMenu ? "<img class='arrow' src='" + wmImagePath + "arrow.gif'>" : "") +
			this.text + "</a>";
};
function wmSeparator() { this.id = wmHandler.getId(); wmHandler.all[this.id] = this; };
wmSeparator.prototype.height = wmSeparatorDefaultHeight;
wmSeparator.prototype.toString = function () {
 return	"<div" + " id='" + this.id + "'" + (wmUseHover ? " onmouseover='wmHandler.overMenuItem(this)'" + " onmouseout='wmHandler.outMenuItem(this)'" : "") + "></div>"
};
function wmBar() { this._parentConstructor = wm; this._parentConstructor(); }
wmBar.prototype = new wm;
wmBar.prototype.toString = function () {
 var str = "<div align=right id='" + this.id + "' class='webfx-menu-bar'>";
 for (var i = 0; i < this._menuItems.length; i++) str += this._menuItems[i] + "<br>";
 str += "</div>";
 for (var i = 0; i < this._subMenus.length; i++) str += this._subMenus[i];
 return str;
};
function mb(sText, sHref, sToolTip, oSubMenu) { this._parentConstructor = mi; this._parentConstructor(sText, sHref, sToolTip, oSubMenu);}
mb.prototype = new mi;
mb.prototype.toString = function () {
 return	"<a" + " id='" + this.id + "'" + " href='" + this.href + "'" + (this.toolTip ? " title='" + this.toolTip + "'" : "") + (wmUseHover ? (" onmouseover='wmHandler.overMenuItem(this)'" +	" onmouseout='wmHandler.outMenuItem(this)'") :
				(" onfocus='wmHandler.overMenuItem(this)'" + (this.subMenu ? " onblur='wmHandler.blurMenu(this)'" : ""))) + ">" + 
(this.subMenu ? "<img class='arrow' border='0' align='absmiddle' src='" + wmImagePath + this.text + "'>" : "<img class='arrow' border='0' align='absmiddle' src='" + wmImagePath + this.text + "'>") + "</a>";
};
function getInnerLeft(el) { if (el == null) return 0; if (ieBox && el == document.body || !ieBox && el == document.documentElement) return 0; return getLeft(el) + getBorderLeft(el); }
function getLeft(el) { if (el == null) return 0; return el.offsetLeft + getInnerLeft(el.offsetParent); }
function getInnerTop(el) { if (el == null) return 0; if (ieBox && el == document.body || !ieBox && el == document.documentElement) return 0; return getTop(el) + getBorderTop(el); }
function getTop(el) { if (el == null) return 0;	return el.offsetTop + getInnerTop(el.offsetParent); }
function getBorderLeft(el) { return ie ? el.clientLeft : parseInt(window.getComputedStyle(el, null).getPropertyValue("border-left-width")); }
function getBorderTop(el) { return ie ? el.clientTop : parseInt(window.getComputedStyle(el, null).getPropertyValue("border-top-width")); }
function opera_getLeft(el) { if (el == null) return 0; return el.offsetLeft + opera_getLeft(el.offsetParent); }
function opera_getTop(el) { if (el == null) return 0; return el.offsetTop + opera_getTop(el.offsetParent); }
function getOuterRect(el) { return { left: (opera ? opera_getLeft(el) : getLeft(el)), top: (opera ? opera_getTop(el) : getTop(el)), width: el.offsetWidth, height: el.offsetHeight }; }
function getDocumentRect(el) { return { left: 0, top: 0, width: (ie ? (ieBox ? document.body.clientWidth : document.documentElement.clientWidth) : window.innerWidth), height: (ie ? (ieBox ? document.body.clientHeight : document.documentElement.clientHeight) : window.innerHeight) }; }
function getScrollPos(el) { return { left: (ie ? (ieBox ? document.body.scrollLeft : document.documentElement.scrollLeft) : window.pageXOffset), top: (ie ? (ieBox ? document.body.scrollTop : document.documentElement.scrollTop) : window.pageYOffset) }; }
wm.prototype.position = function (relEl, sDir) {
 var dir = sDir; var piRect;
 if (!relEl) {
  var pi = this.parentMenuItem; if (!this.parentMenuItem) return; relEl = document.getElementById(pi.id);
  if (dir == null) dir = pi instanceof mb ? "horizontal" : "horizontal";  piRect = getOuterRect(relEl);
}
else if (relEl.left != null && relEl.top != null && relEl.width != null && relEl.height != null) {
 piRect = relEl; } else piRect = getOuterRect(relEl);
var menuEl = document.getElementById(this.id); var menuRect = getOuterRect(menuEl); var docRect = getDocumentRect();
var scrollPos = getScrollPos(); var pMenu = this.parentMenu;
if (dir == "vertical") {
 if (piRect.left + menuRect.width - scrollPos.left <= docRect.width) this.left = piRect.left;
  else if (docRect.width >= menuRect.width) this.left = docRect.width + scrollPos.left - menuRect.width;
  else this.left = scrollPos.left;
 if (piRect.top + piRect.height + menuRect.height <= docRect.height + scrollPos.top) this.top = piRect.top + piRect.height;
  else if (piRect.top - menuRect.height >= scrollPos.top) this.top = piRect.top - menuRect.height;
  else if (docRect.height >= menuRect.height) this.top = docRect.height + scrollPos.top - menuRect.height;
  else this.top = scrollPos.top;
 } else {
  if (piRect.top + menuRect.height - this.borderTop - this.paddingTop <= docRect.height + scrollPos.top) this.top = piRect.top - this.borderTop - this.paddingTop;
   else if (piRect.top + piRect.height - menuRect.height + this.borderTop + this.paddingTop >= 0) this.top = piRect.top + piRect.height - menuRect.height + this.borderBottom + this.paddingBottom + this.shadowBottom;
   else if (docRect.height >= menuRect.height) this.top = docRect.height + scrollPos.top - menuRect.height;
   else this.top = scrollPos.top;
 var pMenuPaddingLeft = pMenu ? pMenu.paddingLeft : 0;
 var pMenuBorderLeft = pMenu ? pMenu.borderLeft : 0;
 var pMenuPaddingRight = pMenu ? pMenu.paddingRight : 0;
 var pMenuBorderRight = pMenu ? pMenu.borderRight : 0;
 if (piRect.left + piRect.width + menuRect.width + pMenuPaddingRight + pMenuBorderRight - this.borderLeft + this.shadowRight <= docRect.width + scrollPos.left)
 this.left = piRect.left + piRect.width + pMenuPaddingRight + pMenuBorderRight - this.borderLeft;
 else if (piRect.left - menuRect.width - pMenuPaddingLeft - pMenuBorderLeft + this.borderRight + this.shadowRight >= 0)
 this.left = piRect.left - menuRect.width - pMenuPaddingLeft - pMenuBorderLeft + this.borderRight + this.shadowRight;
 else if (docRect.width >= menuRect.width) this.left = docRect.width  + scrollPos.left - menuRect.width;
 else this.left = scrollPos.left;
}};

wmImagePath = "/images/buttons/"; wmUseHover = true;

var n = new wm;
n.left = 135; n.top = 155;
n.add(new mi("Allgemeines", "/nachwuchs/index.php"));
n.add(new mi("Trainer/Betreuer", "/nachwuchs/betreuer.php"));
n.add(new wmSeparator());
n.add(new mi("Rookies", "/start.php?league=158&team=65"));
n.add(new mi("Unter 9 (U9)" , "/start.php?league=242&team=66"));
n.add(new mi("Unter 11 (U11)", "/start.php?league=238&team=355"));
n.add(new mi("Unter 13 (U13)", "/start.php?league=239&team=347"));
n.add(new mi("Unter 15 (U15)", "/start.php?league=240&team=339"));
n.add(new mi("Unter 17 (U17)", "/start.php?league=241&team=208"));

var ve = new wm;
ve.left = 135; ve.top = 175;
ve.add(new mi("Geschichte", "/archiv/geschichte.php"));
ve.add(new mi("Sponsoren", "/news/sponsoren.php"));
//ve.add(new mi("Saisonkarten", "/news/news.php?id=677"));
ve.add(new mi("Vereinsführung", "/news/verein.php"));
ve.add(new mi("Leitbild", "/news/leitbild.php"));
ve.add(new mi("Kontakte", "/news/verein.php"));
ve.add(new mi("Eisarena Mödling", "/news/preise.php", null));
ve.add(new wmSeparator());
ve.add(new mi("Archiv", "/archiv/index.php"));

var st = new wm;
st.width = 160;
st.add(new mi("Punkteliste", "http://www.eishockey.at/e.php?t=859&x=spielerstats&d=OL0607_SPIELERSTAT"));
st.add(new mi("Torschützenliste", "http://www.eishockey.at/e.php?t=859&x=spielerstats&d=OL0607_SPIELERSTAT&o=ZLS_PL_G"));
st.add(new mi("Vorlagenliste", "http://www.eishockey.at/e.php?t=859&x=spielerstats&d=OL0607_SPIELERSTAT&o=ZLS_PL_A"));
st.add(new mi("Strafenliste", "http://www.eishockey.at/e.php?t=859&x=spielerstats&d=OL0607_SPIELERSTAT&o=ZLS_PL_BB"));
st.add(new mi("Powerplay", "http://www.eishockey.at/e.php?t=859&x=powerplay&d=OL0607_VEREINSTAT"));
st.add(new mi("Penaltykilling", "http://www.eishockey.at/e.php?t=859&x=penaltykilling&d=OL0607_VEREINSTAT"));
st.add(new mi("Fairplay", "http://www.eishockey.at/e.php?t=859&x=fairplay&d=OL0607_VEREINSTAT"));
st.add(new mi("Shorthanded", "http://www.eishockey.at/e.php?t=859&x=shorthanded&d=OL0607_VEREINSTAT"));

var st2 = new wm;
st2.width = 160;
st2.add(new mi("Punkteliste", "/spieler/stats.php?f=EHLO-punkteliste"));
st2.add(new mi("Torschützenliste", "/spieler/stats.php?f=EHLO-torschuetzen"));
st2.add(new mi("Vorlagenliste", "/spieler/stats.php?f=EHLO-assists"));
st2.add(new mi("Strafenliste", "/spieler/stats.php?f=EHLO-boesebuben"));
st2.add(new mi("Powerplay", "/spieler/stats.php?f=EHLO-powerplay"));
st2.add(new mi("Penaltykilling", "/spieler/stats.php?f=EHLO-penaltykilling"));
st2.add(new mi("Fairplay", "/spieler/stats.php?f=EHLO-fairplay"));

var ka = new wm;
ka.left = 135; ka.top = 133; ka.width = 160;
ka.add(new mi("Mannschaft/Statistik", "/spieler/statistik.php?team=1&league=228"));
ka.add(new wmSeparator());
ka.add(new mi("Vorbereitungsspiele", "/berichte/gamesv3.php?league=237"));
//ka.add(new mi("Playoffs Wiener Liga", "/berichte/gamesv3.php?league=223"));
ka.add(new mi("Tabelle Wiener Liga", "/tabelle/index.php?liga=228"));
ka.add(new mi("Spielplan/Ergebnisse", "/berichte/gamesv3.php?league=228"));
ka.add(new mi("Austragungsmodus", "/tabelle/modus.php"));
ka.add(new wmSeparator());
ka.add(new mi("Archiv", "/archiv/index.php"));

var ka2 = new wm;
ka2.width = 160;
ka2.add(new mi("Mannschaft/Statistik", "/spieler/statistik.php?team=55&league=97"));
ka2.add(new wmSeparator());
ka2.add(new mi("Tabelle Eishockeyliga Ost", "/tabelle/index.php?liga=164"));
ka2.add(new mi("Obere Playoffs", "/berichte/gamesv3.php?league=180"));
ka2.add(new mi("Untere Playoffs", "/berichte/gamesv3.php?league=181"));
ka2.add(new mi("Statistik (NÖEHLV)", "", "", st2));
ka2.add(new mi("Spielplan/Ergebnisse", "/berichte/gamesv3.php?league=164"));
ka2.add(new mi("Austragungsmodus", "/tabelle/modus2.php"));
ka2.add(new wmSeparator());
ka2.add(new mi("Archiv", "/archiv/index.php"));

var ka3 = new wm;
ka3.width = 160;
ka3.add(new mi("Mannschaft/Statistik", "/spieler/statistik.php?team=55&league=244"));
ka3.add(new wmSeparator());
ka3.add(new mi("Tabelle Hobbyliga", "/tabelle/index.php?liga=244"));
ka3.add(new mi("Spielplan/Ergebnisse", "/berichte/gamesv3.php?league=244"));
ka3.add(new wmSeparator());
ka3.add(new mi("Archiv", "/archiv/index.php"));

var uecmenu = new wmBar;
uecmenu.add(new mb("uec1.gif", "/start.php?league=228&team=1", null, ka));
//uecmenu.add(new mb("uec2.gif", "/start.php?league=97&team=55", null, ka2));
uecmenu.add(new mb("hobby.gif", "/start.php?league=244&team=55", null, ka3));
uecmenu.add(new mb("nachwuchs.gif", "/nachwuchs/index.php", null, n));
uecmenu.add(new mb("verein.gif", "/news/verein.php", null, ve));
uecmenu.add(new mb("news.gif", "/news/news_category.php", null));
uecmenu.add(new mb("interaktiv.gif", "/news/forum.php", null, null));
uecmenu.add(new mb("trainingsplan.gif", "/nachwuchs/trainingsplan.php", null));
uecmenu.add(new mb("fotogalerie.gif", "/cpg/", null));
uecmenu.add(new mb("webcam.gif", "javascript:void window.open(\"/images/buttons/webcam.php\", \"w\", \"width=670,height=400,resizable=no\");", "Webcam der Eisarena Mödling"));