// *************************************************
//            Copyright by Tango GRAZioso
//                8020 Graz Austria
//            Design by Gunter Jammernegg
// *************************************************
// allgemeine JavaScript-Bibliothek, englische Version

// Filter zum Ausschluß älterer Browser, Screenreader oder Mobile Browser:
//   document.getElementById("footer").offsetWidth == 612 ... Indikator: Screen-Stylesheet wurde verarbeitet
//   Hack zum Ausschluß von IE 6.0: footer ist auf 611px gesetzt
//   document.getElementById("scroll").offsetHeight >= 504 ... Mindesthöhe des Fensters für Popup-Ausgabe

var Popup = false; // Anfangswert für Popupfenster

function ReplaceMail()
{ // Ersetzen von Mailadressen zur Vermeidung von Adressenklau
  var HTMLText = document.getElementById("content").innerHTML;
  while (HTMLText.indexOf("_AT_") != -1) { HTMLText = HTMLText.replace(/_AT_/,"@"); }
  while (HTMLText.indexOf("_DOT_") != -1) { HTMLText = HTMLText.replace(/_DOT_/,"."); }
  document.getElementById("content").innerHTML = HTMLText;
}

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("footer").offsetWidth == 612) && (document.getElementById("scroll").offsetHeight >= 504)) // Popupausgabe nur ab bestimmter Fensterhöhe
  {
    var HTMLText = "<div id=\"popuplight\"><a href=\"javascript:HidePopup()\">&nbsp;<\/a><\/div>" +
                   "<div id=\"popupwindow\">" +
                   "<div style=\"width:" + mapwidth + "px\" id=\"popuphead\"><a href=\"javascript:HidePopup()\" title=\"Close\">" + title + "<\/a><\/div>" +
                   "<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";
    Popup = true;
  }
  else // neue Seite für ältere Browser, Handhelds 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\" href=\"" + path + "style_basic.css\"><\/head>" +
                   "<body><h3><a href=\"javascript:history.back();\" title=\"Back\" class=\"aLeft\">back<\/a><\/h3>" +
                   "<p><a href=\"javascript:history.back();\" class=\"aAnchor\"><img src=\"" + map + "\" width=\"" + mapwidth + "\" height=\"" + mapheight + "\" title=\"Back\" alt=\"\"><\/a><\/p>" +
                   "<p><a href=\"javascript:history.back();\" class=\"aAnchor\"><img src=\"" + nextmap + "\" width=\"" + mapwidth + "\" height=\"" + mapheight + "\" title=\"Back\" alt=\"\"><\/a><\/p><\/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("footer").offsetWidth == 612) && (document.getElementById("scroll").offsetHeight >= 504)) // Popupausgabe nur ab bestimmter Fensterhöhe
  {
    var HTMLText = "<div id=\"popuplight\"><a href=\"javascript:HidePopup()\">&nbsp;<\/a><\/div>" +
                   "<div id=\"popupwindow\">" +
                   "<div style=\"width:" + imgwidth + "px\" id=\"popuphead\"><a href=\"javascript:HidePopup()\" title=\"Close\">" + title + "<\/a><\/div>" +
                   "<img src=\"" + image + "\" width=\"" + imgwidth + "\" height=\"" + imgheight + "\" alt=\"\">" +
                   "<\/div>";
    document.getElementById("popup").innerHTML = HTMLText;
    document.getElementById("popup").style.display = "block";
    Popup = true;
  }
  else // neue Seite für ältere Browser, Handhelds 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\" href=\"" + path + "style_basic.css\"><\/head>" +
                   "<body><h3><a href=\"javascript:history.back();\" title=\"Back\" class=\"aLeft\">back<\/a><\/h3>" +
                   "<p><a href=\"javascript:history.back();\" class=\"aAnchor\"><img src=\"" + image + "\" width=\"" + imgwidth + "\" height=\"" + imgheight + "\" title=\"Back\" alt=\"\"><\/a><\/p><\/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("footer").offsetWidth == 612) && (document.getElementById("scroll").offsetHeight >= 504)) // Popupausgabe nur ab bestimmter Fensterhöhe
  {
    var path = url.substring(0,url.indexOf("page"));
    url = url.replace(/info/,"popup");
    var HTMLText = "<div id=\"popuplight\"><a href=\"javascript:HidePopup()\">&nbsp;<\/a><\/div>" +
                   "<div id=\"popupwindow\">" +
                   "<div style=\"width:" + urlwidth + "px\" id=\"popuphead\"><a href=\"javascript:HidePopup()\" title=\"Close\">" + title + "<\/a><\/div>" +
                   "<iframe src=\"" + url + "\" width=\"" + urlwidth + "\" height=\"" + urlheight + "\" name=\"Popup\" frameborder=\"0\"><\/iframe>" +
                   "<\/div>";
    document.getElementById("popup").innerHTML = HTMLText;
    document.getElementById("popup").style.display = "block";
    Popup = true;
  }
  else { var fenster=window.open(url,"_self"); } // neue Seite für ältere Browser, Handhelds und Screenreader
  return false;
}

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

