$(document).ready(function(){
	highlightCurrentPageLink();
	$('a.lightbox').lightBox(); // Select all links with lightbox class
});

function popUpLageplan(halle)
{
  if(halle=="allenlueften"){window.open("hallenplaene/allenlueften.html", "Allenlueften_Lageplan", "width=700, height=500");}
  else if(halle=="eisengasse"){window.open("hallenplaene/eisengasse.html", "Eisengasse_Lageplan", "width=700, height=500");}
  else if(halle=="dennigkofen"){window.open("hallenplaene/dennigkofen.html", "Dennigkofen_Lageplan", "width=700, height=500");}
  else if(halle=="lorraine"){window.open("hallenplaene/lorraine.html", "Lorraine_Lageplan", "width=700, height=500");}
  else if(halle=="fuellerich"){window.open("hallenplaene/fuellerich.html", "Fuellerich_Lageplan", "width=700, height=500");}
  else if(halle=="aebnit"){window.open("hallenplaene/aebnit.html", "Aebnit_Lageplan", "width=700, height=500");}
}

// Aktuelle Seite via CSS Klasse auf aktiv setzen und Submenu anzeigen
function highlightCurrentPageLink() 
{
  if(document.location.href.charAt(document.location.href.length-1) != "/")
  {
    // Alle links durchlaufen
    anzHrefs = document.getElementsByTagName('a').length;
    for (var i = 0; i <= anzHrefs - 1; i++) 
    {
      var currentVon = document.location.href.lastIndexOf('?');
      if(currentVon != -1 && document.location.href.lastIndexOf('&') == -1)
      {
        currentVon = currentVon+1;
        var currentBis = document.location.href.length;
      }
      else
      {
        currentVon = currentVon+1;
        var currentBis = document.location.href.lastIndexOf('&');
      }    
      
      var currentId = document.location.href.substring(currentVon, currentBis)
      var bolLink = false;
      
      // link auf aktuelle Seite gefunden
      if(document.getElementsByTagName('a')[i].href == document.location.href){bolLink = true;}
      
      var regEx = new RegExp('(' + document.getElementsByTagName('a')[i].href + ')\\b');
      // Newsseite: news.php ohne Id enthalten in Link
      if(document.location.href.substring(0, document.getElementsByTagName('a')[i].href.length).match(regEx)){bolLink = true;}

      var regEx = new RegExp('(' + currentId + '&)|(' + currentId + ')\\b');
      // enthält Link am anfang und GENAUE id (Teams)
      if(currentId != "" && document.getElementsByTagName('a')[i].href.match(regEx)){bolLink = true;}
      
      if(bolLink)
      {
        // der link gehört zu einem Submenu
        if (document.getElementsByTagName('a')[i].className == "aSubMenu")
        {
          // submenulink auf Active setzen
          var currentClassName = document.getElementsByTagName("a")[i].className;
          var newClassName = currentClassName.replace("aSubMenu","aSubMenuActive");
          document.getElementsByTagName("a")[i].className = newClassName;
          
          // subMenuDiv anzeigen
          var currentSubMenu = document.getElementsByTagName('a')[i].parentNode.id;
          currentClassName = document.getElementById(currentSubMenu).className;
          newClassName = currentClassName.replace("divSubMenu","divSubMenuActive");
          document.getElementById(currentSubMenu).className = newClassName;

          // aktuelles Hauptmenu auf Aktiv setzen
          document.getElementById(currentSubMenu.replace(/divSub/g, "a")).className = document.getElementById(currentSubMenu.replace(/divSub/g, "a")).className + "Active";
        }
      }
    }
  }
}

// DHTML-Scripts by Ch. Wysseier, netstyle.ch, CROSS BROWSER
// Supported:
// All Browsers using the W3C Standard:
// - Internet Explorer 4.0 - 6.0
// - Mozilla 1.0
// - Netscape 6.0 - 7.0
// - Opera 6.0
// Special versions for:
// - Netscape 4.x
// Get this script under http://www.netstyle.ch/chris/
//***********************************************************************
browserCheck();
var w3c,ns4, gecko;
function browserCheck() {
  var strBrowser = navigator.userAgent.toLowerCase();
  w3c = false;
  ns4 = false;
  gecko = false;
  if (document.getElementById) {
    w3c = true;
    if (strBrowser.indexOf('gecko') != -1) gecko = true;
  }
  else {
    if (document.layers) ns4 = true;
  }
}

// Hides a layer
// argument: strLayer represents the ID of the Layer
function hideLayer(strLayer) {
  if (w3c) document.getElementById(strLayer).style.visibility = "hidden";
  if (ns4) document.layers[strLayer].visibility = "hide";
}

// Shows a layer
// argument: strLayer represents the ID of the Layer
function showLayer(strLayer) {
  if (w3c) document.getElementById(strLayer).style.visibility = "visible";
  if (ns4) document.layers[strLayer].visibility = "show";
}
// argument: strLayer represents the ID of the Layer
// returns: true if the layer is visible
function getLayersVisibility(strLayer) {
  if (w3c) return document.getElementById(strLayer).style.visibility == "visible";
  if (ns4) return document.layers[strLayer].visibility == "show";
}

