// 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);
var hoehe = 362;
var breite = 16;
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 - 286;
    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;
}
weit = getAvailWidth();
hoch = getAvailHeight();
var startx = getAvailWidth() + 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;
// Funktionsdeklarationen
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.html","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 oeffnePopupLink(url) {
  opener.location.href = url;
  self.close();
}
function zeigeFenster(url,name,para) {
  para += "status=no,";
  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 += "status=no,";
  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 += "status=no,";
  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 += "status=no,";
  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 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 scriptBrowser() {
  if(navigator.appName == "Microsoft Internet Explorer") {//IE6
    var scrollAttribut = document.createAttribute("scroll");
    scrollAttribut.nodeValue = "no";
    var zuweisen = document.getElementsByTagName("body")[0];
    zuweisen.setAttributeNode(scrollAttribut);
    //alert("IE6");
  }
  else if(navigator.appName == "Opera") {//Opera
    document.getElementsByTagName("body")[0].setAttribute("style","position:fixed;overflow:hidden;");
    //alert("Opera");
  }
  else if(navigator.appName == "Netscape") {
    if(navigator.userAgent.search("Firefox") != -1) {//Firefox
      document.getElementsByTagName("body")[0].setAttribute("style","overflow:hidden;");
    //alert("Firefox");
    }
    else {
      if(navigator.userAgent.search("Netscape") != -1) {//Netscape Navigator
        document.getElementsByTagName("body")[0].setAttribute("style","position:fixed;");
      }
      else {
        if(navigator.userAgent.search("Gecko") != -1)//Mozilla
          document.getElementsByTagName("body")[0].setAttribute("style","position:fixed;");
        //alert("Mozilla");
      }
    }
  }
}
function checkScroll(substract,training) {
  var topFrameHoehe = 114;
  var spezBrowser = 0;
  if(navigator.appName == "Microsoft Internet Explorer")//IE6
    spezBrowser = 0;
  else if(navigator.appName == "Opera") {//Opera
    if(training == "Pkw")
      spezBrowser = 0;
    else if(training == "Alt" || training == "Krad")
      spezBrowser = -5;
    else
      spezBrowser = 0;
  }
  else if(navigator.appName == "Netscape") {
    if(navigator.userAgent.search("Firefox") != -1) {//Firefox
      if(training == "Pkw")
        spezBrowser = 3;
      else if(training == "Krad")
        spezBrowser = 6;
      else if(training == "Alt")
        spezBrowser = 3;
      else
        spezBrowser = 0;
    }
    else {
      if(navigator.userAgent.search("Netscape") != -1) {//Netscape Navigator
        if(training == "Pkw")
          spezBrowser = 1;
        else if(training == "Krad")
          spezBrowser = 2;
        else if(training == "Alt")
          spezBrowser = 1;
        else
          spezBrowser = 0;
      }
      else {
        if(navigator.userAgent.search("Gecko") != -1) {//Mozilla
          if(training == "Pkw" || training == "Alt")
            spezBrowser = 1;
          else if(training == "Krad")
            spezBrowser = 2;
          else
            spezBrowser = 0;
        }
      }
    }
  }
  window.document.write('<div style="height:'+(document.body.clientHeight - topFrameHoehe - spezBrowser - substract)+';overflow:auto;">');
}
function scroll() {
  window.document.write('<div style="height:'+(document.body.clientHeight - 114)+';overflow:auto;">');
}
function checkHorizontalScroll(img,s_width,s_height,b_width,b_height,alt) {
  if(screen.width < 1280) {
    if(navigator.appName == "Netscape") {
      if(navigator.userAgent.search("Firefox") != -1)//Firefox
        window.document.write('<div style="width:738px;border:0;overflow:auto;overflow-y:hidden"><img src="images/'+ img +'1.jpg" width="'+ s_width +'" height="'+ s_height +'" alt="'+ alt +'"></div>');
      else if(navigator.userAgent.search("Netscape") != -1)//Netscape Navigator
        window.document.write('<div style="width:736px;border:0;overflow:auto;overflow-y:hidden"><img src="images/'+ img +'1.jpg" width="'+ s_width +'" height="'+ s_height +'" alt="'+ alt +'"></div>');
      else if(navigator.userAgent.search("Gecko") != -1)//Mozilla
        window.document.write('<div style="width:738px;border:0;overflow:auto;overflow-y:hidden"><img src="images/'+ img +'1.jpg" width="'+ s_width +'" height="'+ s_height +'" alt="'+ alt +'"></div>');
    }
    else//alle anderen Browser
      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><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);
}
function choiceScrollImage(image,hight1,hight2,title) {
  if(screen.width < 1280)
    window.document.write('<img src="images/'+image+'_1024px.jpg" width="738" heigth="'+hight1+'" border="0" alt="'+image+'_1024px.jpg" title="'+title+'"></img><br /><br />');
  else
    window.document.write('<img src="images/'+image+'_1280px.jpg" width="994" heigth="'+hight2+'" border="0" alt="'+image+'_1280px.jpg" title="'+title+'"></img><br /><br />');
}