
window.onload = starter;


function starter() {
	createTitles();
		
	//check for textsize
	if(getCookie("textsize")) {		
		setTextSize(getCookie("textsize"));
	}
}


function createTitles() {
	if(document.getElementsByTagName && !document.all) {
		var imageTags =  document.getElementsByTagName("img")  ;
		for (var i = 0; i < imageTags.length ; i++) {
			var imageTag = imageTags[i];
			
			if(imageTag.alt != null || "") {
				imageTag.setAttribute("title", imageTag.alt);
			} else if(imageTag.alt == null) {
				imageTag.alt = "";
			}
			
		} 
	}
}
// Cookie Funktionen
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function deleteCookie(name, path, domain) {
  if (readCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
// Textsize

	//check for textsize
	
/*

function setTextSize(size) {
	if(document.getElementsByTagName) {
		var bodyTag = document.getElementsByTagName("body");
		
		if(bodyTag) {			
			switch(size) {
				case "small": 
					document.getElementById('medium').className = "medium replace";
					document.getElementById('large').className = "large replace";
					bodyTag.item(0).style.fontSize = "100%";
					
					break;
				case "medium": 
					document.getElementById('small').className = "small replace";
					document.getElementById('large').className = "large replace";
					bodyTag.item(0).style.fontSize = "110%";
					break;
				case "large": 
					document.getElementById('small').className = "small replace";
					document.getElementById('medium').className = "medium replace";
					bodyTag.item(0).style.fontSize = "125%";
					break;
			}
			//bodyTag.item(0).className = bodyTag.item(0).className.replace(" small", "").replace(" medium", "").replace(" large","");			
			//bodyTag.item(0).className += " " + size
			document.getElementById('size').className += " selected";
			
			// Set code to add this setting to a cookie; Invalidate the cookie after session?
			//setCookie("textsize", size, null, "/", "www.apples-to-oranges.com");
			createCookie("textsize", size, 365);
		}
	}
}*/

// switching the styles for fucking Internet Explorer
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
  		
		setTextSize(readCookie("textsize"));
	
}



var cookie = readCookie("style");
var cookie2 = readCookie("textsize");
//alert (cookie);
//alert (cookie2);
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

if(readCookie("textsize")) {		
		setTextSize(readCookie("textsize"));
	}
// Darstellungs-Selector
function showToolbox()
{
document.write( "Darstellung: " );
document.write( "<form action=\"switch\" style=\"width:50px\">" );
document.write( "<select  id=\"style\"  onchange=\"setActiveStyleSheet(value);\">" );
document.write( "<option  id=\"show\" value=\"Standard\"  > Bitte wählen<\/option>" );
document.write( "<option id=\"show\" value=\"Standard\" title=\"Gestaltung f&uuml;r grafische Browser\" class=\"opt1\"> Standard<\/option>" );	
document.write( "<option id=\"show\" value=\"Text\" title=\"Ansicht mit gro&szlig;er, invertierter Schrift\" class=\"opt2\"> Text invertiert<\/option>" );
document.write( "<option id=\"show\" value=\"Ohne\" title=\"Kein Layout\" class=\"opt4\"> Kein Layout<\/option>" );
document.write( "<option id=\"show\" value=\"Druck\" title=\"Text zum Drucken\" class=\"opt3\"> Drucken<\/option>" );
document.write( "<\/select>" );
document.write( "<\/form>" );
}

function setTextSize(size) {
	if(document.getElementsByTagName) {
		var bodyTag = document.getElementsByTagName("body");
		
		if(bodyTag) {			
			switch(size) {
				case "small": 
					document.getElementById('medium').className = "medium replace";
					document.getElementById('large').className = "large replace";
					bodyTag.item(0).style.fontSize = "100%";					
					break;
				case "medium": 
					document.getElementById('small').className = "small replace";
					document.getElementById('large').className = "large replace";
					bodyTag.item(0).style.fontSize = "110%";
					break;
				case "large": 
					document.getElementById('small').className = "small replace";
					document.getElementById('medium').className = "medium replace";
					bodyTag.item(0).style.fontSize = "125%";
					break;
			}
			document.getElementById(size).className += " selected";
						
			// Set code to add this setting to a cookie; Invalidate the cookie after session?
			createCookie("textsize", size, null, "/", "witikohof.de", null);
		}
	}
}
window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
  createCookie("textsize", size, 365);
}
//  MM_part of the game
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_jumpMenuGo(selName,targ,restore){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore);
}
function NewClass(obj1, new_style) { 
  obj1.className=new_style;

}

function MM_findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function mm_createTitles() {
	if(document.getElementsByTagName && !document.all) {
		var imageTags =  document.getElementsByTagName("img")  ;
		for (var i = 0; i < imageTags.length ; i++) {
			var imageTag = imageTags[i];
			
			if(imageTag.alt != null || "") {
				imageTag.setAttribute("title", imageTag.alt);
			} else if(imageTag.alt == null) {
				imageTag.alt = "";
			}
			
		} 
	}
}

function popup(url, title) {
	if(!title) {
		title = "Popup";
	}
	window.open(url,title,'width=600,height=500,resizable,scrollbars');
}


