loginP = new Image(64, 27);
loginP.src = "CTVHP/button/LoginP.png";

loginU = new Image(64, 27);
loginU.src = "CTVHP/button/Login.png";

newsP = new Image(135, 30);
newsP.src = "CTVHP/button/NewsP.png";

newsU = new Image(135, 30);
newsU.src = "CTVHP/button/News.png";


gspielplanP = new Image(135, 30);
gspielplanP.src = "CTVHP/button/GesamtspielplanP.png";

gspielplanU = new Image(135, 30);
gspielplanU.src = "CTVHP/button/Gesamtspielplan.png";


teamsP = new Image(135, 30);
teamsP.src = "CTVHP/button/TeamsP.png";

teamsU = new Image(135, 30);
teamsU.src = "CTVHP/button/Teams.png";


damen1P = new Image(135, 30);
damen1P.src = "CTVHP/button/1DamenP.png";

damen1U = new Image(135, 30);
damen1U.src = "CTVHP/button/1Damen.png";

damen1teamP = new Image(95, 27);
damen1teamP.src = "CTVHP/button/MannschaftP.png";

damen1teamU = new Image(95, 27);
damen1teamU.src = "CTVHP/button/Mannschaft.png";

damen1spplanP = new Image(95, 27);
damen1spplanP.src = "CTVHP/button/SpielplanP.png";

damen1spplanU = new Image(95, 27);
damen1spplanU.src = "CTVHP/button/Spielplan.png";

damen1tabelleP = new Image(95, 27);
damen1tabelleP.src = "CTVHP/button/TabelleP.png";

damen1tabelleU = new Image(95, 27);
damen1tabelleU.src = "CTVHP/button/Tabelle.png";


damen2P = new Image(135, 30);
damen2P.src = "CTVHP/button/2DamenP.png";

damen2U = new Image(135, 30);
damen2U.src = "CTVHP/button/2Damen.png";

damen2teamP = new Image(95, 27);
damen2teamP.src = "CTVHP/button/MannschaftP.png";

damen2teamU = new Image(95, 27);
damen2teamU.src = "CTVHP/button/Mannschaft.png";

damen2spplanP = new Image(95, 27);
damen2spplanP.src = "CTVHP/button/SpielplanP.png";

damen2spplanU = new Image(95, 27);
damen2spplanU.src = "CTVHP/button/Spielplan.png";

damen2tabelleP = new Image(95, 27);
damen2tabelleP.src = "CTVHP/button/TabelleP.png";

damen2tabelleU = new Image(95, 27);
damen2tabelleU.src = "CTVHP/button/Tabelle.png";


herren1P = new Image(135, 30);
herren1P.src = "CTVHP/button/1HerrenP.png";

herren1U = new Image(135, 30);
herren1U.src = "CTVHP/button/1Herren.png";

herren1teamP = new Image(95, 27);
herren1teamP.src = "CTVHP/button/MannschaftP.png";

herren1teamU = new Image(95, 27);
herren1teamU.src = "CTVHP/button/Mannschaft.png";

herren1spplanP = new Image(95, 27);
herren1spplanP.src = "CTVHP/button/SpielplanP.png";

herren1spplanU = new Image(95, 27);
herren1spplanU.src = "CTVHP/button/Spielplan.png";

herren1tabelleP = new Image(95, 27);
herren1tabelleP.src = "CTVHP/button/TabelleP.png";

herren1tabelleU = new Image(95, 27);
herren1tabelleU.src = "CTVHP/button/Tabelle.png";


herren2P = new Image(135, 30);
herren2P.src = "CTVHP/button/2HerrenP.png";

herren2U = new Image(135, 30);
herren2U.src = "CTVHP/button/2Herren.png";

herren2teamP = new Image(95, 27);
herren2teamP.src = "CTVHP/button/MannschaftP.png";

herren2teamU = new Image(95, 27);
herren2teamU.src = "CTVHP/button/Mannschaft.png";

herren2spplanP = new Image(95, 27);
herren2spplanP.src = "CTVHP/button/SpielplanP.png";

herren2spplanU = new Image(95, 27);
herren2spplanU.src = "CTVHP/button/Spielplan.png";

herren2tabelleP = new Image(95, 27);
herren2tabelleP.src = "CTVHP/button/TabelleP.png";

herren2tabelleU = new Image(95, 27);
herren2tabelleU.src = "CTVHP/button/Tabelle.png";


wAjP = new Image(135, 30);
wAjP.src = "CTVHP/button/wA-JugendP.png";

wAjU = new Image(135, 30);
wAjU.src = "CTVHP/button/wA-Jugend.png";

wAjteamP = new Image(95, 27);
wAjteamP.src = "CTVHP/button/MannschaftP.png";

wAjteamU = new Image(95, 27);
wAjteamU.src = "CTVHP/button/Mannschaft.png";

wAjspplanP = new Image(95, 27);
wAjspplanP.src = "CTVHP/button/SpielplanP.png";

wAjspplanU = new Image(95, 27);
wAjspplanU.src = "CTVHP/button/Spielplan.png";

wAjtabelleP = new Image(95, 27);
wAjtabelleP.src = "CTVHP/button/TabelleP.png";

wAjtabelleU = new Image(95, 27);
wAjtabelleU.src = "CTVHP/button/Tabelle.png";


wBjP = new Image(135, 30);
wBjP.src = "CTVHP/button/wB-JugendP.png";

wBjU = new Image(135, 30);
wBjU.src = "CTVHP/button/wB-Jugend.png";

wBjteamP = new Image(95, 27);
wBjteamP.src = "CTVHP/button/MannschaftP.png";

wBjteamU = new Image(95, 27);
wBjteamU.src = "CTVHP/button/Mannschaft.png";

wBjspplanP = new Image(95, 27);
wBjspplanP.src = "CTVHP/button/SpielplanP.png";

wBjspplanU = new Image(95, 27);
wBjspplanU.src = "CTVHP/button/Spielplan.png";

wBjtabelleP = new Image(95, 27);
wBjtabelleP.src = "CTVHP/button/TabelleP.png";

wBjtabelleU = new Image(95, 27);
wBjtabelleU.src = "CTVHP/button/Tabelle.png";


wCjP = new Image(135, 30);
wCjP.src = "CTVHP/button/wC-JugendP.png";

wCjU = new Image(135, 30);
wCjU.src = "CTVHP/button/wC-Jugend.png";

wCjteamP = new Image(95, 27);
wCjteamP.src = "CTVHP/button/MannschaftP.png";

wCjteamU = new Image(95, 27);
wCjteamU.src = "CTVHP/button/Mannschaft.png";

wCjspplanP = new Image(95, 27);
wCjspplanP.src = "CTVHP/button/SpielplanP.png";

wCjspplanU = new Image(95, 27);
wCjspplanU.src = "CTVHP/button/Spielplan.png";

wCjtabelleP = new Image(95, 27);
wCjtabelleP.src = "CTVHP/button/TabelleP.png";

wCjtabelleU = new Image(95, 27);
wCjtabelleU.src = "CTVHP/button/Tabelle.png";


wDjP = new Image(135, 30);
wDjP.src = "CTVHP/button/wD-JugendP.png";

wDjU = new Image(135, 30);
wDjU.src = "CTVHP/button/wD-Jugend.png";

wDjteamP = new Image(95, 27);
wDjteamP.src = "CTVHP/button/MannschaftP.png";

wDjteamU = new Image(95, 27);
wDjteamU.src = "CTVHP/button/Mannschaft.png";

wDjspplanP = new Image(95, 27);
wDjspplanP.src = "CTVHP/button/SpielplanP.png";

wDjspplanU = new Image(95, 27);
wDjspplanU.src = "CTVHP/button/Spielplan.png";

wDjtabelleP = new Image(95, 27);
wDjtabelleP.src = "CTVHP/button/TabelleP.png";

wDjtabelleU = new Image(95, 27);
wDjtabelleU.src = "CTVHP/button/Tabelle.png";


torLP = new Image(135, 30);
torLP.src = "CTVHP/button/TorlisteP.png";

torLU = new Image(135, 30);
torLU.src = "CTVHP/button/Torliste.png";


hallenP = new Image(135, 30);
hallenP.src = "CTVHP/button/HallenverzeichnisP.png";

hallenU = new Image(135, 30);
hallenU.src = "CTVHP/button/Hallenverzeichnis.png";


historieP = new Image(135, 30);
historieP.src = "CTVHP/button/HistorieP.png";

historieU = new Image(135, 30);
historieU.src = "CTVHP/button/Historie.png";


bilderP = new Image(135, 30);
bilderP.src = "CTVHP/button/BilderP.png";

bilderU = new Image(135, 30);
bilderU.src = "CTVHP/button/Bilder.png";


forumP = new Image(135, 30);
forumP.src = "CTVHP/button/ForumP.png";

forumU = new Image(135, 30);
forumU.src = "CTVHP/button/Forum.png";


gaestebuchP = new Image(135, 30);
gaestebuchP.src = "CTVHP/button/GaestebuchP.png";

gaestebuchU = new Image(135, 30);
gaestebuchU.src = "CTVHP/button/Gaestebuch.png";


vorstandP = new Image(135, 30);
vorstandP.src = "CTVHP/button/VorstandP.png";

vorstandU = new Image(135, 30);
vorstandU.src = "CTVHP/button/Vorstand.png";


linksP = new Image(135, 30);
linksP.src = "CTVHP/button/LinksP.png";

linksU = new Image(135, 30);
linksU.src = "CTVHP/button/Links.png";


impressumP = new Image(135, 30);
impressumP.src = "CTVHP/button/ImpressumP.png";

impressumU = new Image(135, 30);
impressumU.src = "CTVHP/button/Impressum.png";


function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();

var activeButton = null;
var timeout = null;

// Capture mouse clicks on the page so any active button can be
// deactivated.

if (browser.isIE)
  document.onmousedown = pageMousedown;
else
  document.addEventListener("mousedown", pageMousedown, true);

var i = 0;
var o = 0;


function move_table_spielplan() {

  
}

function mouseIn(container,neuesBild) {
  container.src = neuesBild.src;
  if (getContainerWith(container, "DIV", "menu")) {
    window.clearTimeout(timeout);
   // i++;
    
  }
}

function mouseOut(container,neuesBild) {
  container.src = neuesBild.src;
 // o++;document.getElementById("footer").innerHTML = i + " <-in Test out-> " + o;
  //timeout = window.setTimeout("if(resetButton()){activeButton = null;}", 500);
}


function getContainerWith(node, tagName, className) {

  // Starting with the given node, find the nearest containing element
  // with the specified tag name and style class.

  while (node != null) {
    if (node.tagName != null && node.tagName == tagName &&
        hasClassName(node, className))
      return node;
    node = node.parentNode;
  }

  return node;
}

function hasClassName(el, name) {

  var i, list;

  // Return true if the given element currently has the given class
  // name.

  list = el.className.split(" ");
  for (i = 0; i < list.length; i++)
    if (list[i] == name)
      return true;

  return false;
}

function removeClassName(el, name) {

  var i, curList, newList;

  if (el.className == null)
    return;

  // Remove the given class name from the element's className property.

  newList = new Array();
  curList = el.className.split(" ");
  for (i = 0; i < curList.length; i++)
    if (curList[i] != name)
      newList.push(curList[i]);
  el.className = newList.join(" ");
}

function getPageOffsetLeft(el) {

  var x;

  // Return the x coordinate of an element relative to the page.

  x = el.offsetLeft;
  if (el.offsetParent != null)
    x += getPageOffsetLeft(el.offsetParent);

  return x;
}

function getPageOffsetTop(el) {

  var y;

  // Return the x coordinate of an element relative to the page.

  y = el.offsetTop;
  if (el.offsetParent != null)
    y += getPageOffsetTop(el.offsetParent);

  return y;
}


function buttonClick(event, menuId) {

  window.clearTimeout(timeout);
  var button;

  if (browser.isIE)
    button = window.event.srcElement;//
  else
    button = event.currentTarget;

//  if (button.onmouseout == null)
  //      button.onmouseout = buttonOrMenuMouseout;//----------------------------------------
    
  if ((activeButton == null) || (activeButton != null && activeButton != button)) {

    
    
    // Get the target button element.
    /*
    if (browser.isIE)
      button = window.event.srcElement;
    else
      button = event.currentTarget;*/
    
    // Associate the named menu to this button if not already done.
    // Additionally, initialize menu display.
    
    if (button.menu == null) {
      button.menu = document.getElementById(menuId);
  //    if (button.menu.onmouseout == null)
    //    button.menu.onmouseout = buttonOrMenuMouseout;//----------------------------------------
      if (button.menu.isInitialized == null)
        menuInit(button.menu);
    }

    // [MODIFIED] Added for activate/deactivate on mouseover.
  
    // Set mouseout event handler for the button, if not already done.
    if (browser.isIE) {
    
      if (button.onmouseout == null) {
      
        button.onmouseout = buttonOrMenuMouseout;
      }
    } else {
      button.addEventListener("mouseout", buttonOrMenuMouseout, true);
    }
    
    // Exit if this button is the currently active one.
  
    if (button == activeButton)
      return false;
  
    // [END MODIFIED]

    
    // Reset the currently active button, if any.
    
    if (activeButton != null) {
      //resetButton(activeButton);
    }
    // Activate this button, unless it was the currently active one.
    
    if (button != activeButton) {
      depressButton(button);
      activeButton = button;
    }
    else {
      activeButton = null;
    }
  }
  return;
}


function depressButton(button) {

  var x = 0;
  var y = 0;
  
  // Set mouseout event handler for the button, if not already done.

  if (button.onmouseout == null)
    button.onmouseout = buttonOrMenuMouseout;
  if (button.menu.onmouseout == null)
    button.menu.onmouseout = buttonOrMenuMouseout;
    
  // Position the associated drop down menu next to the button and
  // show it.

  x = getPageOffsetLeft(button) ;
  y = getPageOffsetTop(button) + button.offsetHeight;

//  if (!browser.isNS) {
    x += button.offsetParent.clientLeft + 135;//135
    y +=  0 - 37;
  //}
  
  if (navigator.userAgent.indexOf("Firefox/2") >= 0) {
  
    x = 160;
    y = 407;
  }
 
  button.menu.style.left = x + "px";//x
  button.menu.style.top  = y + "px";//y
  button.menu.style.visibility = "visible"; 
}


function resetButton(button) {

  if (!button) {
    button = activeButton;
  } 
  
  // Hide the button's menu, first closing any sub menus.

  if ((button != null) && (button.menu != null)) {
    closeSubMenu(button.menu);
    button.menu.style.visibility = "hidden";
    return true;
  }
  return false;
}

function pageMousedown(event) {

  window.clearTimeout(timeout);
  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element that was clicked on.

  if (browser.isIE)
    el = window.event.srcElement;//
  else
    el = (event.target.tagName ? event.target : event.target.parentNode);

  // If the active button was clicked on, exit.

  if (el == activeButton)
    return;

  // If the element is not part of a menu, reset and clear the active
  // button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    resetButton(activeButton);
    activeButton = null;
  }
}

function menuInit(menu) {
  menu.isInitialized = true;
}

function closeSubMenu(menu) {

  if (menu == null || menu.activeItem == null)
    return;
  
  
  // Recursively close any sub menus.

  if (menu.activeItem.subMenu != null) {
    closeSubMenu(menu.activeItem.subMenu);
    menu.activeItem.subMenu.style.visibility = "hidden";
    menu.activeItem.subMenu = null;
  }

  menu.activeItem = null;
}

function menuMouseover(event) {

  window.clearTimeout(timeout);
  var menu;

  // Find the target menu element.

  if (browser.isIE)
    menu = getContainerWith(window.event.srcElement, "DIV", "menu");//
  else
    menu = event.currentTarget;

  // Close any active sub menu.

  if (menu.activeItem != null)
    closeSubMenu(menu);
}

function menuItemMouseover(event, menuId) {
  
  window.clearTimeout(timeout);
  var item, menu, x, y;

  // Find the target item element and its parent menu element.

  if (browser.isIE)
    item = window.event.srcElement;//getContainerWith(window.event.srcElement, "INPUT", "menu");//
  else
    item = event.currentTarget;
    
  menu = getContainerWith(item, "DIV", "menu");

  // Close any active sub menu and mark this one as active.

  
  if (menu.activeItem != null) {

    closeSubMenu(menu);
  }
  menu.activeItem = item;

  // Initialize the sub menu, if not already done.

  if (item.subMenu == null) {
    item.subMenu = document.getElementById(menuId);
    if (item.subMenu.isInitialized == null)
      menuInit(item.subMenu);
  }

  // [MODIFIED] Added for activate/deactivate on mouseover.

  // Set mouseout event handler for the sub menu, if not already done.

  if (item.subMenu.onmouseout == null)
    item.subMenu.onmouseout = buttonOrMenuMouseout;//------------------------------------------------

  // [END MODIFIED]

  // Get position for submenu based on the menu item.

  x = getPageOffsetLeft(item) + item.offsetWidth;
  y = getPageOffsetTop(item);

  // Adjust position to fit in view.
///*
  var maxX, maxY;

  if (browser.isIE) {
    maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) +
      (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
    maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) +
      (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
  }
  if (browser.isOP) {
    maxX = document.documentElement.scrollLeft + window.innerWidth;
    maxY = document.documentElement.scrollTop  + window.innerHeight;
  }
  if (browser.isNS) {
    maxX = window.scrollX + window.innerWidth;
    maxY = window.scrollY + window.innerHeight;
  }
  maxX -= item.subMenu.offsetWidth;
  maxY -= item.subMenu.offsetHeight;

  if (x > maxX)
    x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth
      + (menu.offsetWidth - item.offsetWidth));
  y = Math.max(0, Math.min(y, maxY));
//*/
  // Position and show the sub menu.

  item.subMenu.style.left       = x + "px";
  item.subMenu.style.top        = y + "px";
  item.subMenu.style.visibility = "visible";

  // For IE; size, position and display the menu's IFRAME as well.

  if (item.subMenu.iframeEl != null)
  {
    item.subMenu.iframeEl.style.left    = item.subMenu.style.left;
    item.subMenu.iframeEl.style.top     = item.subMenu.style.top;
    item.subMenu.iframeEl.style.width   = item.subMenu.offsetWidth + "px";
    item.subMenu.iframeEl.style.height  = item.subMenu.offsetHeight + "px";
    item.subMenu.iframeEl.style.display = "";
  }

  // Stop the event from bubbling.

  if (browser.isIE)
    window.event.cancelBubble = true;
  else
    event.stopPropagation();
    
}
/*
function buttonOrMenuMouseout(event) {//

  var el;
  var ev;
  ev = event;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element the mouse is moving to.

  if (browser.isIE) {
    el = window.event.toElement;//
  } else { 
    
    if (ev.relatedTarget != null) {
    
      el = (ev.relatedTarget.tagName ? ev.relatedTarget : ev.relatedTarget.parentNode);
    }
  }
  // If the element is not part of a menu, reset the active button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    timeout = window.setTimeout("if(resetButton()){activeButton = null;}", 800);//activeButton
  }
}

*/


function buttonOrMenuMouseout(event) {//

  var el;

  // If there is no active button, exit.

  if (activeButton == null)
    return;

  // Find the element the mouse is moving to.

  if (browser.isIE) {
    el = window.event.toElement;//
  } else { 
    
    if (event != null && event.relatedTarget != null) {
    
      el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);
    }
  }
  // If the element is not part of a menu, reset the active button.

  if (getContainerWith(el, "DIV", "menu") == null) {
    timeout = window.setTimeout("if(resetButton()){activeButton = null;}", 800);//activeButton
  }
}


