function getBody() {
  if(document.body)
    return true;
  if(document.documentElement)
    return false;
  return null;
}
function getAvailWidth() {
  if(typeof window.innerWidth != 'undefined')
    var width = window.innerWidth - 286;
  else {
    if(getBody())
      var width = document.body.clientWidth - 270;
    else
      var width = document.documentElement.clientWidth - 286;
  }
  return width;
}
function getAvailHeight() {
  if(typeof window.innerWidth != 'undefined')
    var height = window.innerHeight - 114;
  else {
    if(getBody())
      var height = document.body.clientHeight - 114;
    else
      var height = document.documentElement.clientHeight - 114;
  }
  return height;
}
// Variablendeklaration
var yshift = new Array(148,122,135,68,27,10,2,-2,-10,-23,-37,-39,-21,-15,-5,5,15,13,7,0,-13,-19,-27);
weit = getAvailWidth();
hoch = getAvailHeight();
var hoehe = 300;
var breite = 12;
var startx = weit + 286;
var starty = 0;
var startwert = breite;
var i = 0;

var expMinutes = 30;
var exp = new Date();
// Zeitangaben werden in Millisekunden umgerechnet!
exp.setTime(exp.getTime() + (expMinutes*60*1000));

var fenster1;
var fenster2;
var fenster3;
var fenster4;
var win;
var lauftext = "   +   +   +   +   +   W i l l k o m m e n   a u f   d e m   V e r k e h r s ü b u n g s p l a t z   K a a r s t";
// Funktionsdeklaration
function nach_vorne() {
  self.focus();
  window.setTimeout("nach_vorne()",15000);
}
// Zeitangabe, wie lange das Cookie gespeichert werden soll.
// Nach Überschreitung der Zeitspanne, wird beim nächsten Öffnen
// des Browsers mit dieser Seite oder beim Zurückkehren auf diese Seite
// (onLoad) das Popup Fenster nicht mehr geöffnet [checkCount()]!
function GetCookie(name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if(document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if(i == 0)
      break;
  }
  return null;
}
function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + "=" + escape (value) +
  ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  ((path == null) ? "" : ("; path=" + path)) +
  ((domain == null) ? "" : ("; domain=" + domain)) +
  ((secure == true) ? "; secure" : "");
}
function DeleteCookie(name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);
  var cval = GetCookie(name);
  document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function amt() {
  var count = GetCookie('count')
  if(count == null) {
    SetCookie('count','1');
    return 1;
  }
  else {
    var newcount = parseInt(count) + 1;
    DeleteCookie('count');
    SetCookie('count',newcount,exp);
    return count;
  }
}
function getCookieVal(offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if(endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
function gummifenster() {
  win = window.open("Weihnachten/Weihnachtsgutschein.htm","neu","width=" + breite + ",height=" + hoehe + ",status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no,screenX=" + startx + ",left=" + startx + ",screenY=" + starty + ",top=" + starty + " ");
}
function checkCount() {
  var count = GetCookie('count');
  if (count == null) {
    count=1;
    SetCookie('count', count, exp);
    gummifenster();
  }
  else {
    count++;
    SetCookie('count', count, exp);
  }
}
function zeigeFenster(url,name,para) {
  para += "top=209,";
  para += "left=163,";
  para += "scrollbar=no,";
  para += "resizable=no,";
  para += "menubar=no,";
  para += "location=no,";
  para += "directories=no";
  fenster1 = window.open(url,name,para);
  setTimeout('fenster1.close()',20000);
}
function zeigeFensterPos(url,name,para) {
  para += "scrollbar=no,";
  para += "resizable=no,";
  para += "menubar=no,";
  para += "location=no,";
  para += "directories=no";
  fenster2 = window.open(url,name,para);
  setTimeout('fenster2.close()',20000);
}
function zeigeFensterPosDauer(url,name,para,time) {
  para += "scrollbar=no,";
  para += "resizable=no,";
  para += "menubar=no,";
  para += "location=no,";
  para += "directories=no";
  fenster3 = window.open(url,name,para);
  setTimeout('fenster3.close()',(time*1000));
}
function oeffneFensterPos(url,name,para) {
  para += "scrollbar=no,";
  para += "resizable=no,";
  para += "menubar=no,";
  para += "location=no,";
  para += "directories=no";
  fenster4 = window.open(url,name,para);
}
function schliesseFenster(wann) {
  window.setTimeout("self.close()",wann*1000);
}
function groesser() {
  if(i < 55) {
    self.resizeTo((startwert+i*10),hoehe);
    self.moveBy(-10,0);
    setTimeout("groesser()",1);
  }
  else if(i > 54 && i < 78) {
    self.moveBy(-20,yshift[i-55]);
    setTimeout("groesser()",60);
  }
  else {
    setTimeout("self.close()",200);
  }
  i++;
}
function bewegung() {
  parentWin = window.opener;
  groesser();
}
function row_walk_on() {
  window.status = lauftext;
  lauftext = lauftext.substring(1,lauftext.length) + lauftext.substring(0,1);
  setTimeout("row_walk_on()",133);
}
function doFlash()
{ setInterval("guestbook1.filters.glow.enabled=!guestbook1.filters.glow.enabled",700);
  setInterval("guestbook2.filters.glow.enabled=!guestbook2.filters.glow.enabled",700);
}
function tauscheBild(bild,bildname) {
  if(document.images)
    window.document.images[bild].src="images/"+bildname+".gif";
}
function wechsle_Seite(url,dauer) {
 setTimeout("window.open('"+url+"','_self')",dauer*1000)
}
function gif_vorladen() {
  var bilder =  new Array();
  if(document.images) {
    for(var i = 0; i < gif_vorladen.arguments.length; i++) {
      bilder[i] = new Image();
      bilder[i].src = "images/"+gif_vorladen.arguments[i]+".gif";
    }
  }
}
function jpg_vorladen() {
  var bilder =  new Array();
  if(document.images) {
    for(var i = 0; i < jpg_vorladen.arguments.length; i++) {
      bilder[i] = new Image();
      bilder[i].src = "images/"+jpg_vorladen.arguments[i]+".jpg";
    }
  }
}
function zeigeFensterZufall() {
  zufall = parseInt(Math.random()*6);
  zufall++;
  if(zufall == 3 || zufall == 5)
    window.document.write('<img src="images/ISO.gif" width="203" height="88" border="0"><br>Wir sind zertifiziert nach ISO 9001');
  else
    window.document.write('&nbsp;');
}
function oeffnePopupLink(url) {
  opener.location.href = url;
  self.close();
}
function checkHorizontalScroll(img,s_width,s_height,b_width,b_height,alt) {
  if(screen.width < 1280)
    window.document.write('<div style="width:734px;border:0;overflow:auto;overflow-y:hidden"><img src="images/'+ img +'1.jpg" width="'+ s_width +'" height="'+ s_height +'" alt="'+ alt +'"></div>');
  else
    window.document.write('<div style="width:1006px;border:0;overflow:auto;overflow-y:hidden"><img src="images/'+ img +'2.jpg" width="'+ b_width +'" height="'+ b_height +'" alt="'+ alt +'"></div>');
}
function resizeMe(guestbook) {
  if(screen.height < 1024) {
    if(navigator.appName == "Microsoft Internet Explorer")
      document.getElementById(guestbook).style.height = document.body.clientHeight - 134;
    else if(navigator.appName == "Opera") {
      document.getElementById(guestbook).style.height = document.body.clientHeight - 132;
      document.getElementById(guestbook).style.width = 748;
    }
    else if(navigator.appName == "Netscape") {
      if(navigator.userAgent.search("Firefox") != -1)
        document.getElementById(guestbook).style.height = document.body.clientHeight - 132;
      else {
        if(navigator.userAgent.search("Netscape") != -1);//Netscape ist voll der Loserbrowser!
        else {
          if(navigator.userAgent.search("Gecko") != -1)
            document.getElementById(guestbook).style.height = document.body.clientHeight - 132;
        }
      }
    }
  } else {
    if(navigator.appName == "Microsoft Internet Explorer")
      document.getElementById(guestbook).style.height = document.body.clientHeight - 134;
    else if(navigator.appName == "Opera") {
      document.getElementById(guestbook).style.height = document.body.clientHeight - 132;
      document.getElementById(guestbook).style.width = 1004;
    }
    else if(navigator.appName == "Netscape") {
      if(navigator.userAgent.search("Firefox") != -1)
        document.getElementById(guestbook).style.height = document.body.clientHeight - 132;
      else {
        if(navigator.userAgent.search("Netscape") != -1);
        else {
          if(navigator.userAgent.search("Gecko") != -1)
            document.getElementById(guestbook).style.height = document.body.clientHeight - 132;
        }
      }
    }
  }
}
function scrollSmall() {
  if(screen.height < 1024)//Auflösung 1024x768 und kleiner
    window.document.write('<div style="height:'+(document.body.clientHeight - 114)+';border:0;overflow:auto;">');
  else
    window.document.write('<div>');
//alert(document.body.clientWidth);
}