var SelectedLink = null;
var SelectedIMG  = null;

function SelectLink(obj, colorSet, colorSetBack)
{
  if (obj && obj.style) {
    if (SelectedLink) {
      SelectedLink.style.color = "";
    }
    
    obj.style.color = "#" + colorSet;
    SelectedLink = obj;
  }
}

function SelectMOO(objName, url, setIt)
{
  if (objName && url && window.document.getElementById && window.document.getElementById(objName)) {
    if (setIt && SelectedIMG && SelectedIMG != objName) {
      window.document.getElementById(SelectedIMG).src = url.replace("_over", "");
    }
    
    if (objName != SelectedIMG) {
      window.document.getElementById(objName).src = url;
    }
    
    if (setIt) {
      SelectedIMG = objName;
    }
  }
}

// Setzt den Cursor-Focus auf das übergebene Element.
// @param elementID ID des Elements.
function FokusSetzen(elementID)
{
  if (elementID) {
    if (window && window.focus) {
	    if (window.document.getElementById && window.document.getElementById(elementID)) {
	      window.focus();
		    window.document.getElementById(elementID).focus();
		    
		    if (window.document.getElementById(elementID).select) {
          window.document.getElementById(elementID).select();
        }
	    }
    }
  }
}

// Öffnet ein Pop-Up Fenster.
// @param url Die URL die geöffnet werden soll.
// @param params Die Parameter für das Pop-Up Fenster.
// @param height Die Höhe des Pop-Up Fenster.
// @param width Die Breite des Pop-Up Fenster.
function PappasOeffnen(url, params, height, width)
{
  if (url) {
    var sHeight = "492";
    var sWidth = "787";
    
    if (height) {
      sHeight = "" + height;
    }
    
    if (width) {
      sWidth = "" + width;
    }
    
    var top = screen.height / 2 - sHeight / 2;
    var left = screen.width / 2 - sWidth / 2;
    
    if (!params) {
      params = "resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0";
    }
    
    params += ",height=" + sHeight + ",width=" + sWidth + ",top=" + top + ",left=" + left + "";
    
    if (window.pappas && !window.pappas.closed) {
      window.pappas.open(url, "_self", params);
      window.pappas.focus();
    }
    else {
      window.pappas = window.open(url, "_blank", params);
    }
  }
}

// Öffnet ein Pop-Up Fenster.
// @param url Die URL die geöffnet werden soll.
// @param params Die Parameter für das Pop-Up Fenster.
// @param height Die Höhe des Pop-Up Fenster.
// @param width Die Breite des Pop-Up Fenster.
function McPappasOeffnen(url, params, height, width)
{
  if (url) {
    var sHeight = "460";
    var sWidth = "720";
    
    if (height) {
      sHeight = "" + height;
    }
    
    if (width) {
      sWidth = "" + width;
    }
    
    var top = screen.height / 2 - sHeight / 2;
    var left = screen.width / 2 - sWidth / 2;
    
    if (!params) {
      params = "resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0";
    }
    
    params += ",height=" + sHeight + ",width=" + sWidth + ",top=" + top + ",left=" + left + "";
    
    if (window.mcpappas && !window.mcpappas.closed) {
      window.mcpappas.open(url, "_self", params);
      window.mcpappas.focus();
    }
    else {
      window.mcpappas = window.open(url, "_blank", params);
    }
  }
}

// Öffnet ein Pop-Up Fenster.
// @param url Die URL die geöffnet werden soll.
// @param params Die Parameter für das Pop-Up Fenster.
// @param height Die Höhe des Pop-Up Fenster.
// @param width Die Breite des Pop-Up Fenster.
function SchauplatzOeffnen(url, params, height, width)
{
  if (url) {
    var sHeight = "395";
    var sWidth = "720";
    
    if (height) {
      sHeight = "" + height;
    }
    
    if (width) {
      sWidth = "" + width;
    }
    
    var top = screen.height / 2 - sHeight / 2;
    var left = screen.width / 2 - sWidth / 2;
    
    if (!params) {
      params = "resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0";
    }
    
    params += ",height=" + sHeight + ",width=" + sWidth + ",top=" + top + ",left=" + left + "";
    
    if (window.schauplatz && !window.schauplatz.closed) {
      window.schauplatz.open(url, "_self", params);
      window.schauplatz.focus();
    }
    else {
      window.schauplatz = window.open(url, "_blank", params);
    }
  }
}

// Öffnet ein Pop-Up Fenster.
// @param url Die URL die geöffnet werden soll.
// @param params Die Parameter für das Pop-Up Fenster.
// @param height Die Höhe des Pop-Up Fenster.
// @param width Die Breite des Pop-Up Fenster.
function MammasOeffnen(url, params, height, width)
{
  if (url) {
    var sHeight = "435";
    var sWidth = "787";
    
    if (height) {
      sHeight = "" + height;
    }
    
    if (width) {
      sWidth = "" + width;
    }
    
    var top = screen.height / 2 - sHeight / 2;
    var left = screen.width / 2 - sWidth / 2;
    
    if (!params) {
      params = "resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0";
    }
    
    params += ",height=" + sHeight + ",width=" + sWidth + ",top=" + top + ",left=" + left + "";
    
    if (window.mammas && !window.mammas.closed) {
      window.mammas.open(url, "_self", params);
      window.mammas.focus();
    }
    else {
      window.mammas = window.open(url, "_blank", params);
    }
  }
}

// Öffnet ein Pop-Up Fenster.
// @param url Die URL die geöffnet werden soll.
// @param params Die Parameter für das Pop-Up Fenster.
// @param height Die Höhe des Pop-Up Fenster.
// @param width Die Breite des Pop-Up Fenster.
function FlyerOeffnen(url, params, height, width)
{
  if (url) {
    var sHeight = "778";
    var sWidth = "561";
    
    if (height) {
      sHeight = "" + height;
    }
    
    if (width) {
      sWidth = "" + width;
    }
    
    var top = screen.height / 2 - sHeight / 2;
    var left = screen.width / 2 - sWidth / 2;
    
    if (!params) {
      params = "resizable=1,toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0";
    }
    
    params += ",height=" + sHeight + ",width=" + sWidth + ",top=" + top + ",left=" + left + "";
    
    if (window.flyer && !window.flyer.closed) {
      window.flyer.open(url, "_self", params);
      window.flyer.focus();
    }
    else {
      window.flyer = window.open(url, "_blank", params);
    }
  }
}

function SeiteOeffnen(url, win, objName, lokal, lokalZusatz, seite)
{
  if (url && seite && seite > 0 && seite < 5 && win.document.getElementById && win.document.getElementById(objName) && win.document.getElementById(objName).value && parseInt(win.document.getElementById(objName).value) > 0) {
    url = url + "?locId=" + win.document.getElementById(objName).value.split('_')[0] + "&locName=" + win.document.getElementById(objName).value.split('_')[1] + "&lokal=" + lokal + "&lokalZus=" + lokalZusatz;
    
    switch (seite) {
      case 1:
        PappasOeffnen(url);
        break;
      case 2:
        McPappasOeffnen(url);
        break;
      case 3:
        SchauplatzOeffnen(url);
        break;
      case 4:
        MammasOeffnen(url);
        break;
    }
    
    win.document.getElementById(objName).selectedIndex = 0;
  }
}

// Schliesst ein Pop-Up Fenster.
function PappasSchliessen()
{
  if (window.pappas && !window.pappas.closed) {
    window.pappas.close();
  }
}

// Schliesst ein Pop-Up Fenster.
function McPappasSchliessen()
{
  if (window.mcpappas && !window.mcpappas.closed) {
    window.mcpappas.close();
  }
}

// Schliesst ein Pop-Up Fenster.
function SchauplatzSchliessen()
{
  if (window.schauplatz && !window.schauplatz.closed) {
    window.schauplatz.close();
  }
}

// Schliesst ein Pop-Up Fenster.
function MammasSchliessen()
{
  if (window.mammas && !window.mammas.closed) {
    window.mammas.close();
  }
}

// Schliesst ein Pop-Up Fenster.
function FlyerSchliessen()
{
  if (window.flyer && !window.flyer.closed) {
    window.flyer.close();
  }
}

function AlleSchliessen()
{
  PappasSchliessen();
  McPappasSchliessen();
  SchauplatzSchliessen();
  MammasSchliessen();
  FlyerSchliessen();
}

// Selektiert alle Check-Boxen.
// @param elementID1 ID des Elements1.
// @param elementID2 ID des Elements2.
// @param elementID3 ID des Elements3.
function AlleAuswaehlen(elementID1, elementID2, elementID3)
{
  if (elementID1 && elementID2 && elementID3) {
	  if (window.document.getElementById && window.document.getElementById(elementID1)) {
	    var iCount = parseInt(window.document.getElementById(elementID1).value);
	    for (var i = 1; i <= iCount; i++) {
	      window.document.getElementById(elementID2 + i).checked = window.document.getElementById(elementID3).checked;
	    }
	  }
  }
}
