// *************************************************
//            Copyright by Tango GRAZioso
//                8020 Graz Austria
//            info(AT)tangograzioso(DOT)at
// *************************************************
//            Design by Gunter Jammernegg
// *************************************************
// allgemeine JavaScript-Bibliothek, englische Version

// Filter zum Ausschluß älterer Browser, Screenreader oder Mobile Browser:
//   document.getElementById ... schließt Netscape 4.x aus
//   document.getElementById("navigation").offsetWidth == 220 ... Screen-Stylesheet wurde verarbeitet
//   screen.height >= 768 ... Mindestgröße des Bildschirms für Popup-Ausgabe
//   document.getElementById("footer").offsetWidth == 612 ... Hack zum Ausschluß von IE 5.0: footer ist auf 611px gesetzt

function SetDimension()
{ // Größe des Containers "scroll" festlegen
  if (document.getElementById && (document.getElementById("navigation").offsetWidth == 220) && (screen.height >= 768)) // ältere Browser und Screenreader ausschließen
  {
    var x,y; // innere Fenstergröße ermitteln
    if (self.innerHeight) // alle Browser außer IE
    {
      x = self.innerWidth;
      y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight) // IE 6 bei HMTL Strict
    {
      x = document.documentElement.clientWidth;
      y = document.documentElement.clientHeight;
      document.getElementsByTagName("html")[0].style.overflow = "hidden"; // notwendig für IE 6 bei HTML Strict
    }
    else if (document.body) // andere IE
    {
      x = document.body.clientWidth;
      y = document.body.clientHeight;
    }
    if (x >= 862) { document.getElementById("scroll").style.width = "642px"; } // Breite von "scroll"
    else { document.getElementById("scroll").style.width = (x - 220) + "px"; }
    document.getElementById("scroll").style.height = (y - 92) + "px"; // Höhe von "scroll"
    document.getElementById("navigation").style.height = (y - 92 - 14) + "px"; // Höhe von "navigation" gleich wie "scroll" - padding
    document.getElementById("scroll").style.overflow = "auto";
    document.getElementsByTagName("body")[0].style.overflow = "hidden";
  }
}
if (document.getElementById) { window.onresize = SetDimension; } // Fenstergrößenänderung überwachen

function Mail(Name,Adress,Domain,Text)
{ // Umsetzen von Mailadressen zur Vermeidung von Adressenklau
  if (!Text) { Text = Name+'@'+Adress+'.'+Domain; } // nur drei Parameter übergeben
  document.write('<a href=\"mailto:'+Name+'@'+Adress+'.'+Domain+'\" title=\"Mail\" class=\"aMail\">'+Text+'<\/a>');
}

function MailParam(Name,Adress,Domain,Parameter,Text)
{ // Umsetzen von Mailadressen zur Vermeidung von Adressenklau, mit Parameterübergabe
  if (!Text) { Text = Name+'@'+Adress+'.'+Domain; } // nur vier Parameter übergeben
  document.write('<a href=\"mailto:'+Name+'@'+Adress+'.'+Domain+Parameter+'\" title=\"Mail\" class=\"aMail\">'+Text+'<\/a>');
}

function FormTop(File,Name)
{ // Spamschutz: Formulare nur mit JavaScript benutzbar
  document.write('<form action="'+File+'" method="post" name="'+Name+'">');
}

function FormBottom(Name1,Type1,Value1,Name2,Type2,Value2)
{ // Spamschutz: Formulare nur mit JavaScript benutzbar
  document.write('<p><input name="'+Name1+'" type="'+Type1+'" value="'+Value1+'" class="button" alt="'+Value1+'"> <input name="'+Name2+'" type="'+Type2+'" value="'+Value2+'" class="button" alt="'+Value2+'"></p>');
  document.write('</form>');
}

// Popup für Stadtplan einblenden (maximale Breite wegen Hintergrundbild 612 px)
// Stadtplan muß in 2 Versionen mit gleichen Maßen vorliegen:
//    <map>_lores.jpg (Übersicht)
//    <map>_hires.jpg (Detail)
function ShowMap(title, map, mapwidth, mapheight, flag)
{
  if (flag) { map = map.replace(/hires/,"lores"); }
  if (map.substr(map.length-9,5) == "lores") { var nextmap = map.replace(/lores/,"hires"); }
  else { var nextmap = map.replace(/hires/,"lores"); }
  var path = map.substring(0,map.indexOf("pix"));
  if (document.getElementById && (document.getElementById("navigation").offsetWidth == 220) && (screen.height >= 768)) // ältere Browser und Screenreader ausschließen
  {
    var HTMLText = "<div style=\"width:" + mapwidth + "px\" id=\"popuphead\">" + title + "<\/div>" +
                   "<div id=\"popupclose\"><a href=\"javascript:HidePopup()\"><img src=\"" + path + "pix\/pixel.gif\" title=\"Close\" alt=\"\" width=\"" + mapwidth + "\" height=\"22\"><\/a><\/div>" +
                   "<div style=\"width:" + mapwidth + "px; height:" + mapheight + "px;\"><a href=\"" + nextmap + "\" onClick=\"return ShowMap(\'" + title + "\',this.href," + mapwidth + "," + mapheight + ")\"><img src=\"" + map + "\" width=\"" + mapwidth + "\" height=\"" + mapheight + "\" title=\"Zoom\" alt=\"\"><\/a><\/div>";
    document.getElementById("popup").innerHTML = HTMLText;
    document.getElementById("popup").style.display = "block";
  }
  else // neue Seite für ältere Browser und Screenreader
  {
    document.close();
    document.open();
    document.write("<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\"><html><head><title>Tango GRAZioso - Map<\/title>" +
                   "<link rel=\"stylesheet\" type=\"text\/css\" media=\"all\" href=\"" + path + "style_all.css\"><\/head>" +
                   "<body><h2><a href=\"javascript:history.back();\" title=\"Back\">back<\/a><\/h2>" +
                   "<img src=\"" + nextmap + "\" width=\"" + mapwidth + "\" height=\"" + mapheight + "\" alt=\"\"><\/body><\/html>");
    document.close();
  }
  return false;
}

// Popup für Bilder einblenden (maximale Breite wegen Hintergrundbild 612 px)
function ShowPix(title, image, imgwidth, imgheight)
{
  var path = image.substring(0,image.indexOf("pix"));
  if (document.getElementById && (document.getElementById("navigation").offsetWidth == 220) && (screen.height >= 768)) // ältere Browser und Screenreader ausschließen
  {
    var HTMLText = "<div style=\"width:" + imgwidth + "px\" id=\"popuphead\">" + title + "<\/div>" +
                   "<div id=\"popupclose\"><a href=\"javascript:HidePopup()\"><img src=\"" + path + "pix\/pixel.gif\" title=\"Close\" alt=\"\" width=\"" + imgwidth + "\" height=\"22\"><\/a><\/div>" +
                   "<div><img src=\"" + image + "\" width=\"" + imgwidth + "\" height=\"" + imgheight + "\" alt=\"\"><\/div>";
    document.getElementById("popup").innerHTML = HTMLText;
    document.getElementById("popup").style.display = "block";
  }
  else // neue Seite für ältere Browser und Screenreader
  {
    document.close();
    document.open();
    document.write("<!DOCTYPE HTML PUBLIC \"-\/\/W3C\/\/DTD HTML 4.01\/\/EN\" \"http:\/\/www.w3.org\/TR\/html4\/strict.dtd\"><html><head><title>Tango GRAZioso - Image<\/title>" +
                   "<link rel=\"stylesheet\" type=\"text\/css\" media=\"all\" href=\"" + path + "style_all.css\"><\/head>" +
                   "<body><h2><a href=\"javascript:history.back();\" title=\"Back\">back<\/a><\/h2>" +
                   "<img src=\"" + image + "\" width=\"" + imgwidth + "\" height=\"" + imgheight + "\" alt=\"\"><\/body><\/html>");
    document.close();
  }
  return false;
}

// Popup für Textinhalt (iframe) einblenden (maximale Breite wegen Hintergrundbild 612 px)
function ShowPopup(title, url, urlwidth, urlheight)
{
  if (document.getElementById && (document.getElementById("footer").offsetWidth == 612) && (screen.height >= 768)) // ältere Browser und Screenreader ausschließen
  {
    var path = url.substring(0,url.indexOf("page"));
    url = url.replace(/info/,"popup");
    var HTMLText = "<div style=\"width:" + urlwidth + "px\" id=\"popuphead\">" + title + "<\/div>" +
                   "<div id=\"popupclose\"><a href=\"javascript:HidePopup()\"><img src=\"" + path + "pix\/pixel.gif\" title=\"Close\" alt=\"\" width=\"" + urlwidth + "\" height=\"22\"><\/a><\/div>" +
                   "<iframe src=\"" + url + "\" width=\"" + urlwidth + "\" height=\"" + urlheight + "\" name=\"Popup\" frameborder=\"0\"><\/iframe>";
    document.getElementById("popup").innerHTML = HTMLText;
    document.getElementById("popup").style.display = "block";
  }
  else { var fenster=window.open(url,"_self"); } // neue Seite für ältere Browser und Screenreader
  return false;
}

// Popup ausblenden
function HidePopup()
{
  document.getElementById("popup").innerHTML = "";
  document.getElementById("popup").style.display = "none";
}

// Bildergallerie in neuem Fenster darstellen
function Gallery(url)
{
  if (document.getElementById && (document.getElementById("navigation").offsetWidth == 220) && (screen.height >= 768)) // ältere Browser und Screenreader ausschließen
  {
    url = url.replace(/album/,"gallery");
    var fenster = window.open(url, "Gallery", "width=800,height=700,left=80,top=0,directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no");
    fenster.focus();
  }
  else { var fenster = window.open(url,"_self"); } // neue Seite für ältere Browser und Screenreader
  return false;
}
