var logger="";
var lname="";
var lpsw="";


function testbrowser()
{
  isNS4 = (document.layers) ? true : false;
  isIE4 = (document.all && !document.getElementById) ? true : false;
  isIE5 = (document.all && document.getElementById) ? true : false;
  isNS6 = (!document.all && document.getElementById) ? true : false;
}

function daysToGo()
{
  var datum=new Date();
  var sek=datum.valueOf();
  var datum2=new Date(2004,8,5,0,0,0,0);
  var sek2=datum2.valueOf();
  var diff = 1+Math.floor((sek2-sek)/86400000);
  return diff;
}

function daysTo(d,m,y)
{
  var datum=new Date();
  var sek=datum.valueOf();
  if ((y<100) && (y>69)) {y+=1900; }; 
  if (y<70) {y+=2000; }; 
  var datum2=new Date(y,m-1,d,0,0,0,0);
  var sek2=datum2.valueOf();
  var diff = 1+Math.floor((sek2-sek)/86400000);
  return diff;
}

function emailme(name,domain)
{
  if ((name.length * domain.length) == 0) return;
  location.href='mailto:'+name+'@'+domain+'?subject=Email von der Vincenz-Welle Homepage';
}

function naviout(adr,nam)
{
  // Leiste zusammenbasteln
  menuleiste = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
  menuleiste += "<html>\n<head>\n";
  menuleiste += " <link rel=\"stylesheet\" type=\"text/css\" href=\"" + adr[0] +"quickb.css\">";
  menuleiste += "\n</head>\n\n<body background=\""+ adr[0] +"bilder/quickb.jpg\">\n\n";
  menuleiste += "<div class=\"navi\">";
  menuleiste += " <a href=\"http://www.vincenzwelle.de\" target=\"_top\">Vincenz-Welle</a>";
  for (i=1; i<adr.length + 1 - 1 ; i++) {
    menuleiste += " :: <a href=\"" + adr[i] + "\" target=\"rumpf\">" + nam[i] + "</a>";
  };
  //menuleiste += " :: " + nam[i] ;
  menuleiste += "<br></div>\n\n</body>\n\n</html>";
  // und reinkleistern
  parent.navi.document.open("text/html", "replace");
  parent.navi.document.write(menuleiste);
  parent.navi.document.close();
}


function test()
{
  // alert( "Test !!"+(maxwidth(window.innerWidth) / 2) );	
  testbrowser();
  if (isNS4) {alert("NS4");};
  if (isIE4) {alert("IE4");};
  if (isIE5) {alert("IE5");};
  if (isNS6) {alert("NS6");};
}

function maxwidth(breite)
{
  return breite;	
}

function getpasswd()
{
  var inp ="";
  var crypt = "";
  var i=0;
  var c1, c2;
  do {
    i++;
    inp = prompt("Der interne Bereich ist durch ein Passwort geschützt! Bitte geben Sie ein gültiges Passwort ein: ","Ihre Eingabe");
    crypt = "";
    if (inp!=null) for (p=1; p<inp.length; p++) {
      c1 = inp.charCodeAt(p-1);
      c2 = inp.charCodeAt(p);
      crypt = crypt.concat( c1 ^ c2 );
    };
  } while (crypt!="19513601" && i<3 && inp!=null); 	

  if (crypt == "19513601" ) {
    inp="";
    for (p=1; p<crypt.length; p++) {
      c1 = crypt.charCodeAt(p-1);
      c2 = crypt.charCodeAt(p);
      inp = inp.concat( c1 ^ c2 );
    };
    parent.rumpf.location.href=inp+"/index.html";
  } else {
    parent.rumpf.location.href="refused.html";
    alert ("Tut uns leid! Aber ohne richtiges Passwort gehts leider nicht in den internen Bereich!");
  }
}


function c_get()
{
  if (window.document.cookie) {
    inh=document.cookie;
    inh=inh.substring(inh.indexOf("logn=")+5,inh.length);
    if ((ende=inh.indexOf(";")) == -1) ende=inh.length;
    lname=decrypt(inh.substring(0,ende));
    inh=document.cookie;
    inh=inh.substring(inh.indexOf("logp=")+5,inh.length);
    if ((ende=inh.indexOf(";")) == -1) ende=inh.length;
    lpsw=decrypt(inh.substring(0,ende));
    logger=lname+":"+lpsw+"@";
  }
  else {
    logger="";
  }
}

function decrypt(wert)
{
  var w="";
  var c=wert.length/3;
  var v=c;
  for (i=0; i<c; i++) {
    w=w.concat(String.fromCharCode((wert.substr(3*i,3)*1)^v));
    v=wert.substr(i*3,3)*1; 
  };
  return w;
}

function go_intern()
{
  c_get();
  parent.rumpf.location.href="http://"+logger+"www.vincenzwelle.de/intern/index.html";
}


