var BreiteDesktop=800;        // Mindestbreite für komplette Darstellung (PC mit allen Links/ Schriftgrößenänderung)
var BreiteMobil=640;          // Mindestbreite für reduzierte Darstellung (PC/ darunter Mobile-Darstellung)
var BreiteMin=240;            // Mindestbreite
                              // darunter evtl. abgespeckte Version
function BrowserType()
{
 this.TypA="Desktop";
 this.TypG="full";
 this.Nr=99;
 Bri=screen.width;
 Hoi=screen.height;

// Breite + Höhe ermitteln
 if (window.innerWidth)
 {
  Bri=window.innerWidth;
  Hoi=window.innerHeight;
 }
 else
  if (document.documentElement.clientWidth)
  {
   Bri=document.documentElement.clientWidth;
   Hoi=document.documentElement.clientHeight;
  }
  else
  {
   if (document.body.offsetWidth)
   {
    Bri=document.body.offsetWidth;
    Hoi=document.body.offsetHeight;
   }
  }

 gefunden=false;
 if (Bri < BreiteMin) Bri=BreiteMin;
 this.Br=Bri;
 this.Ho=Hoi;
// mobile Endgeräte zuordnen (iPod, iPad, iPhone, Opera mobil), Werte korrigieren
 if (!gefunden)
  if (navigator.userAgent.indexOf("iPod") != -1)
  {
   this.Nr=19;
   this.TypA="iPod";
   this.Br-=0; this.Ho-=0;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("iPad") != -1)
  {
   this.Nr=18;
   this.TypA="iPad";
   this.Br-=0; this.Ho-=0;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("iPhone") != -1)
  {
   this.Nr=17;
   this.TypA="iPhone";
   this.Br=960; this.Ho-=8;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("Opera Mobi") != -1)
  {
   this.Nr=16;
   this.TypA="Opera Mobile";
   this.Br=document.documentElement.clientWidth; this.Ho=document.documentElement.clientHeight;
//   this.Br=800; this.Ho-=0;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("Pre/") != -1)
  {
   this.Nr=15;
   this.TypA="Palm Pre";
   this.Br-=0; this.Ho-=0;
   gefunden=true;
  }

 // PPC zuordnen, Werte korrigieren
 if (!gefunden)
  if (navigator.userAgent.indexOf("Opera Mini") != -1)
  {
   this.Nr=9;
   this.TypA="Opera Mini";
   this.Br-=0; this.Ho-=0;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("PPC") != -1)
  {
   this.Nr=8;
   this.TypA="PPC";
   this.Br-=0; this.Ho-=0;
   gefunden=true;
  }

// Desktop-Browser zuordnen, Werte korrigieren
 if (!gefunden)
  if (navigator.userAgent.indexOf("MSIE") != -1)
  {
   this.Nr=21;
   this.Br-=8; this.Ho-=24;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("Navigator") != -1)
  {
   this.Nr=22;
   this.Br-=24; this.Ho-=24;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("Opera") != -1)
  {
   this.Nr=23;
   this.Br-=24; this.Ho-=24;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("Firefox") != -1)
  {
   this.Nr=24;
   this.Br-=8; this.Ho-=24;
   gefunden=true;
  }
 if (!gefunden)
  if (navigator.userAgent.indexOf("Safari") != -1)
  {
   this.Nr=25;
   this.Br-=24; this.Ho-=24;
   gefunden=true;
  }

// Generic-Browser
 if (!gefunden)
 {
  this.TypA="GenericDesktop";
  if (Bri < BreiteDesktop)
  {
   this.Nr=11;
   this.Br-=0; this.Ho-=0;
   this.TypA="GenericMobil";
  }
  if (Bri < BreiteMobil)
  {
   this.Nr=1;
   this.Br-=0; this.Ho-=8;
   this.TypA="GenericMini";
  }
 }

// Größenklasse zuordnen
 if (Bri < BreiteDesktop)
  this.TypG="medium";
 if ((Bri < BreiteMobil) && (this.Nr > 20))
 {
  this.TypG="small";
  this.Nr=1;
  this.Br-=0; this.Ho-=8;
  this.TypA="GenericMini";
 }

 if (this.TypA == "GenericDesktop")
 {
  this.Br-=24; this.Ho-=24;
  if (this.Br < BreiteDesktop-8)
   this.Br=BreiteDesktop-8;
 }
 if (this.TypA=="Desktop")
  if (this.Br < BreiteDesktop-8)
   this.Br=BreiteDesktop-8;



};
// ----------------------------------------------------------------------------------------
function set_cookie(name,value,live)
{
 document.cookie=name+"="+escape(value)+"; path=/; expires="+cookie_live(live);
}
// ----------------------------------------------------------------------------------------
function get_cookie(name)
{
 var value=null;
 if(document.cookie)
 {
  var kk=document.cookie.indexOf(name+"=");
  if(kk >= 0)
  {
   kk=kk+name.length+1;
   var ll=document.cookie.indexOf(";", kk);
   if(ll < 0)
    ll=document.cookie.length;
   value=document.cookie.substring(kk, ll);
   value=unescape(value);
  }
 }
 return value;
}
// ----------------------------------------------------------------------------------------
function cookie_live(value)
{
 var ablauf = new Date();
 var zeit=ablauf.getTime() + (value * 24 * 60 * 60 * 1000);
 ablauf.setTime(zeit);
 return ablauf.toGMTString();
}
// ----------------------------------------------------------------------------------------
function Zeitstempel()
{
 var Jetzt = new Date();
 var Tag = Jetzt.getDate();
 var Monat = Jetzt.getMonth() + 1;
 var Jahr = Jetzt.getYear();
 var Stunden = Jetzt.getHours();
 var Minuten = Jetzt.getMinutes();
 var NachVoll = ((Minuten < 10) ? ":0" : ":");
 if (Jahr < 2000)
  Jahr = Jahr + 1900;
 var BX=new BrowserType();
 document.write("Ich bin ein '"+BX.TypA+"'! ("+BX.TypG+")/ ["+BX.Nr+"]<br />");
 document.write("("+BX.Br+" x "+BX.Ho+")");
 document.write("<br>"+Tag + "." + Monat + "." + Jahr + "/ " + Stunden + NachVoll + Minuten +"<br>");
}
// ----------------------------------------------------------------------------------------
function SMSchreiben(wert)
{
 var str=wert;
 if (str.indexOf("google") >=0 )
  set_cookie('SM_Google',str,7);
 if (str.indexOf("yahoo") >=0 )
  set_cookie('SM_Yahoo',str,7);
}
