// Created: 21.10.05 13:09:42 by Stefan Ascher <stievie[at]utanet[dot]at>

/* Ein Fenster fuer ein Bild, ein paar Pixel breiter fuer den Rand */
function imageWin(url, width, height) {
  wnd = openWin(url, width + 20, height + 20);
//  wnd.document.write("<html><head><title>Foto</title>");
//  wnd.document.write("<link rel=\"stylesheet\" href=\"style.ie.css\" type=\"text/css\">");
//  wnd.document.write("</head><body>");
//  wnd.document.write("<img src=\"" + url + "\">");
//  wnd.document.write("</body></html>\n");
}

/* Oeffnet ein neues Fenster */
function openWin(url, width, height) {
  return window.open(url, "NewWnd", "height=" + height + ",width=" + width);
}

function checkInput()
{
  if (document.KontaktForm.name.value == "") {
    alert("Bitte geben Sie Ihren Namen an.");
    document.KontaktForm.name.focus();
    return false;
  }
  if (document.KontaktForm.email.value == "") {
    if (confirm("Bitte geben Sie Ihre Email Adresse an.\nWenn Sie keine eigene Email Adresse haben, drücken Sie 'Abbrechen' oder 'Cancel'.")) {
      document.KontaktForm.email.focus();
      return false;
    } else {
      document.KontaktForm.email.value = "noreply@nowhere.nn";
      if (document.KontaktForm.message.value != "")
        return true;
    }
  }
  if (document.KontaktForm.message.value == "") {
    document.KontaktForm.message.focus();
    return confirm("Sie haben wirklich keine Nachricht zu versenden?\nDrücken Sie OK, um das Mail abzuschicken.");
  }
  return true;
}

function backLink () {
  // Es gibt einen Zurueck Link auf manchen Seiten
  document.write("<div class=\"toback\">");
  document.write("<a title=\"Zur&uuml;ck\" href=\"javascript:history.back()\">");
  document.write("<img src=\"images/back.png\" alt=\"Zur&uuml;ck zur vorherigen Site\" title=\"Zur&uuml;ck\" class=\"smartimg nohov\">&nbsp;&nbsp;Zur&uuml;ck");
  document.write("</a></div>\n");
}

function makeThumb(pic, width, height) {
  document.write("<a class=\"nohov\" title=\"Verg&ouml;&szlig;ern\" href=\"javascript:imageWin('images/" + pic + ".jpg'," + width + "," + height + ")\">\n");
  document.write("<img class=\"padpic\" src=\"images/thumb_" + pic + ".jpg\" alt=\"Thumbnail\">\n");
  document.write("</a>\n");
/*
  document.write("<a class=\"nohov ext\" href=\"javascript:imageWin('images/" + pic + ".jpg'," + width + "," + height + ")\">\n");
  document.write("<img class=\"padpic\" src=\"thumb.php?file=images/" + pic + ".jpg\" alt=\"Thumbnail\">\n");
  document.write("</a>\n");
*/
}

// Eine vernuenftive Version des IE, also ich habe ja einige Zweifel, dass es die
// mal geben wird.
var reasonable_IE_version = 8;
// I thought IE 7 will understand position:fixed and max-width, but apparently not ;-(.

var detect = navigator.userAgent.toLowerCase();
var OS, browser, version, total, thestring;

function checkIt(string)
{
  place = detect.indexOf(string) + 1;
  thestring = string;
  return place;
}

/* Brauser und OS ermitteln */
function checkBrowser() {
  if (checkIt('konqueror')) {
    browser = "Konqueror";
    OS = "Linux";
  } else if (checkIt('safari'))
    browser = "Safari";
  else if (checkIt('omniweb'))
    browser = "OmniWeb";
  else if (checkIt('opera'))
    browser = "Opera";
  else if (checkIt('webtv'))
    browser = "WebTV";
  else if (checkIt('icab'))
    browser = "iCab";
  else if (checkIt('msie'))
    browser = "IE";
  else if (!checkIt('compatible')) {
    browser = "Netscape";
    version = detect.charAt(8);
  } else
    browser = "Unknown";

  if (!version)
    version = detect.charAt(place + thestring.length);

  if (!OS) {
    if (checkIt('linux'))
      OS = "Linux";
    else if (checkIt('x11'))
      OS = "Unix";
    else if (checkIt('mac'))
      OS = "Mac";
    else if (checkIt('win'))
      OS = "Windows";
    else
      OS = "Unknown";
  }
  
  return browser;
}

/* Der IE hat so seine Probleme mit CSS */
if (checkBrowser() == "IE" && version < reasonable_IE_version) {
  /* Vielleicht wird fixed positioniert die Ver 7 mal koennen... */
  document.write("<link rel=\"stylesheet\" href=\"style.ie.css\" type=\"text/css\">");
} else {
  document.write("<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\">");
}



