// init.js  Version 1.05

var hostname     = document.domain;
var urlreferrer  = document.referrer;
var hostdomain   = "undef";
var PathPic      = "";
var countersrc   = "";
var MailGene     = "genealogy@bartels.com";
var MailKB       = "Bartels@bartels.com";
var MailWeb      = "Webmaster@bartels.com";

PathPic  = "";
PathPic  = "http://home.t-online.de/home/Klaus_Bartels/";

if (hostname == "") {
	hostdomain = "local" 
	PathPic    = "images/";
	};
if (hostname == "home.t-online.de") {
	hostdomain = "T-Online" 
	PathPic    = "";
	};
if (hostname == "ourworld.compuserve.com") {
	hostdomain = "CompuServe" 
	PathPic    = "http://home.t-online.de/home/Klaus_Bartels/";
	};
if (hostname == "www.bartels.com") {
	hostdomain = "Bartels" 
	PathPic    = "http://home.t-online.de/home/Klaus_Bartels/";
	PathPic    = "images/";
	};


function counter(counter){
    var countersrc = "http://www.netzsupport.com/cgi-bin/livecounter/nph-counter.cgi?id=6465&dd=t&seite="+counter+"&ref="+urlreferrer;
    return countersrc;
    }



//
// Cookies
//

// Setzen eines Cookies II
function SetzeCookie2(name, value)
{
  // Name setzen (oder mit neuem Datum aktualisieren)
//var ThePath    = location.pathname ? location.pathname : "/"
//var ThePath    = location.hostname ? location.hostname : "/"
  var ThePath    = location.pathname ? location.pathname.substring(0,location.pathname.length - 12) : "/"
  var TheDomain  = location.hostname
  var TheExpDate = new Date()

  TheExpDate.setTime(TheExpDate.getTime() + (30 * 24 * 3600 * 1000))

  SetzeCookie(name, value, TheExpDate, ThePath, TheDomain)
}

// Setzen eines Cookies
function SetzeCookie(name, value)
{
  var argv    = SetzeCookie.arguments
  var argc    = SetzeCookie.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 ? ("; expires=" + expires.toGMTString()) : "") +
                    (path ? ("; path=" + path) : "") +
                    (domain ? ("; domain=" + domain) : "") +
                    (secure ? "; secure" : "")
}

// Ermitteln eines Cookiewerts
function HoleCookieVal(offset)
{
  var endstr = document.cookie.indexOf(";", offset)

  if(endstr == -1)
    endstr = document.cookie.length

  return(unescape(document.cookie.substring(offset, endstr)))
}

// Ermitteln eines Cookies
function HoleCookie(name)
{
  var arg  = name + "="
  var alen = arg.length
  var clen = document.cookie.length
  var i    = 0

  // Cookiewerte durchsuchen
  while(i < clen)
  {
    var j = i + alen
    if(document.cookie.substring(i, j) == arg)
      return(HoleCookieVal(j))
    i = document.cookie.indexOf(" ", i) + 1
    if(!i)
      break
  }
  return(null)
}

// Beispiel: Ermitteln des Namens
function Benutzer()
{
  var UserName = HoleCookie("username")

  // Name noch nicht eingegeben?
  if(!UserName)
  {
    UserName = prompt("Gib doch bitte Deinen Vornamen an:", "")
    if(!UserName)
    {
      alert("OK, so bleibe denn anonym!")
      UserName = "anonymus"
    }
  }

  // Name setzen (oder mit neuem Datum aktualisieren)
//var ThePath    = location.pathname ? location.pathname : "/"
//var ThePath    = location.hostname ? location.hostname : "/"
  var ThePath    = location.pathname ? location.pathname.substring(0,location.pathname.length - 12) : "/"
  var TheDomain  = location.hostname
  var TheExpDate = new Date()

  TheExpDate.setTime(TheExpDate.getTime() + (30 * 24 * 3600 * 1000))

  SetzeCookie("username", UserName, TheExpDate, ThePath, TheDomain)

  return(UserName)
}

// Beispiel: Ermitteln der Zugriffsrechte
function ZugriffsR()
{
  var Zugriffs = HoleCookie("zugriff")

  // ZugriffsR noch nicht gesetzt?
  if(!Zugriffs)
  {
    Zugriffs  = "undef"
  }

  // Name setzen (oder mit neuem Datum aktualisieren)
  var ThePath    = location.pathname ? location.pathname.substring(0,location.pathname.length - 12) : "/"
  var TheDomain  = location.hostname
  var TheExpDate = new Date()

  TheExpDate.setTime(TheExpDate.getTime() + (30 * 24 * 3600 * 1000))

  SetzeCookie("zugriff", Biblio, TheExpDate, ThePath, TheDomain)

  return(Zugriffs)
}

// Beispiel: Ermitteln der Bibliothek
function Bibliothek()
{
  var Biblio = HoleCookie("bibliothek")

  // Bibliothek noch nicht gesetzt?
  if(!Biblio)
  {
    Biblio = "undef"
  }

  // Name setzen (oder mit neuem Datum aktualisieren)
  var ThePath    = location.pathname ? location.pathname.substring(0,location.pathname.length - 12) : "/"
  var TheDomain  = location.hostname
  var TheExpDate = new Date()

  TheExpDate.setTime(TheExpDate.getTime() + (30 * 24 * 3600 * 1000))

  SetzeCookie("bibliothek", Biblio, TheExpDate, ThePath, TheDomain)

  return(Biblio)
}

// Beispiel: Ermitteln der Anzahl der Besuche
function Besuche()
{
  var AnzahlBesuche = HoleCookie("visits")

  // Besuche weiterzaehlen
  if(!AnzahlBesuche)
    AnzahlBesuche = 1
  else
    AnzahlBesuche++

  // Name setzen (oder mit neuem Datum aktualisieren)
//var ThePath    = location.pathname ? location.pathname.substring(0,location.pathname.length - 12) : "/"
  var ThePath    = location.pathname ? location.pathname : "/"
  var TheDomain  = location.hostname
  var TheExpDate = new Date()

  TheExpDate.setTime(TheExpDate.getTime() + (30 * 24 * 3600 * 1000))

  SetzeCookie("visits", AnzahlBesuche, TheExpDate, ThePath, TheDomain)

  return(AnzahlBesuche)
}

// end of INIT.JS