 function testEncode(form) {
 var dater = new Date();
 Day = dater.getDate();
 dater = null;
 var Ret = encode (form.pwd.value, 12)
 location.href = Ret + ".htm"
 }
 function encode (OrigString, CipherVal) {
 Ref="0123456789abcdefghijklmnopqrstuvwxyz._~ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 CipherVal = parseInt(CipherVal)
 var Temp=""
 for (Count=0; Count < OrigString.length; Count++) {
 var TempChar = OrigString.substring (Count, Count+1)
 var Conv = cton(TempChar)
 var Cipher=Conv^CipherVal
 Cipher=ntoc(Cipher)
 Temp += Cipher
 }
 return (Temp)
 }
 function cton (Char) {
 return (Ref.indexOf(Char));
 }
 function ntoc (Val) {
 return (Ref.substring(Val, Val+1))
 }
function doit(){
document.write('<html><body>');
	document.write('<form name="testform" onsubmit="return(false)">');
	document.write('Passwort: <input type="password" name="pwd" value="">');
	document.write('<input type="button" name="button" value=" OK " onclick="testEncode(this.form)">');
	document.write('</form>');
	document.write('</body></html>');
}



spzzchn=  "*+-./_@";

function ersetze(text,find,repl){
  var found = text.indexOf(find);
  var retVal= ""; var start = 0;
  while(found != -1){
    retVal +=text.substring(start,found) +repl;
    start = found+find.length;
    found =text.indexOf(find,start);
  }
  retVal +=text.substring(start,text.length);
  return retVal;
}

function WertSpeichern(eingabe) {
  var a=escape(eingabe);
  for(var i=0;i<spzzchn.length;i++)
    a=ersetze(a,spzzchn.charAt(i),"%X"+i);
  a=ersetze(a,"%","_");
  self.name=a;
}

function WertAusgeben() {
  var b=""+self.name;
  b=ersetze(b,"_","%");
  for(var i=0;i<spzzchn.length;i++)
    b=ersetze(b,"%X"+i,spzzchn.charAt(i));
  b=unescape(b);
  return b;
}



function pruefestyles(){
	var wa = WertAusgeben().toLowerCase()
	if (wa == 'standard'){
		document.write('<style type="text/css">@import url(style.css);</style>');
	}else if (wa == 'gelb-blau'){
		document.write('<style type="text/css">@import url(gelb-blau.css);</style>');
	}else if (wa == 'blau-gelb'){
		document.write('<style type="text/css">@import url(blau-gelb.css);</style>');
	}else if (wa == 'weiss-gelb'){
		document.write('<style type="text/css">@import url(weiss-gelb.css);</style>');
	}else if (wa == 'gruen-blau-rot'){
		document.write('<style type="text/css">@import url(gruen-blau-rot.css);</style>');
	}else if (wa == 'blau-creme-gelb'){
		document.write('<style type="text/css">@import url(blau-creme-gelb.css);</style>');
	}else if (wa == 'schwarz'){
		document.write('<style type="text/css">@import url(schwarz.css);</style>');
	}else if (wa == 'weiss'){
		document.write('<style type="text/css">@import url(weiss.css);</style>');
	}else if (wa == 'standard-gr'){
		document.write('<style type="text/css">@import url(style-gr.css);</style>');
	}else if (wa == 'gelb-blau-gr'){
		document.write('<style type="text/css">@import url(gelb-blau-gr.css);</style>');
	}else if (wa == 'blau-gelb-gr'){
		document.write('<style type="text/css">@import url(blau-gelb-gr.css);</style>');
	}else if (wa == 'weiss-gelb-gr'){
		document.write('<style type="text/css">@import url(weiss-gelb-gr.css);</style>');
	}else if (wa == 'gruen-blau-rot-gr'){
		document.write('<style type="text/css">@import url(gruen-blau-rot-gr.css);</style>');
	}else if (wa == 'blau-creme-gelb-gr'){
		document.write('<style type="text/css">@import url(blau-creme-gelb-gr.css);</style>');
	}else if (wa == 'schwarz-gr'){
		document.write('<style type="text/css">@import url(schwarz-gr.css);</style>');
	}else if (wa == 'weiss-gr'){
		document.write('<style type="text/css">@import url(weiss-gr.css);</style>');
	}else if (wa == ''){
		WertSpeichern('standard');
	}
}
pruefestyles();


function browsertest(){
	if (WertAusgeben().charCodeAt(0) < 97){		//  falls grossbuchstabe
		if (navigator.userAgent == "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3.1) Gecko/20030425"){
			location.href = location.href;
		}
		WertSpeichern(WertAusgeben().toLowerCase());
	}
}
