/*
	Easydynfont
	Version 1.0
	written by Chris Heilmann
	please refer to the homepage at http://www.onlinetools.org/tools/easydynfont.php
*/

// Standard setting, separate fonts with "," and make sure to set standardfont
// and size to avoid errors
var fonts="Arial,Times New Roman,Verdana,Courier".split(",");
var standardfont="Arial"
var standardsize="100%"
var nosave=false;
var swidth = "";
/*
	function drawform()
	adds the standard form to the document.
*/


/*
	function init()
	loads the cookiedata and changes the document accordingly, if there is no
	cookie, sets the standard settings and stores it
*/
function init(){


       self.moveTo(0,0);
self.resizeTo(screen.availWidth,screen.availHeight);



      if (screen.width > "800")
       {
	   standardsize="100%";




       document.getElementById("LOGO2").src = "/style_images/1/logo.gif";

       }
	  if (screen.width <= "800"){

      standardsize="80%";
      document.getElementById("LOGO2").src = "/style_images/1/logo800.gif";
          }

    if (!document.layers){
	size=getCookie("kbrfontsize");




   if (size!=null){
		c=size.split(":");
		document.getElementsByTagName("body").item(0).style.fontSize=c[0];
		document.getElementsByTagName("body").item(0).style.fontFamily=c[1];
	}
	if (size==null || c[0]=="" || c[1]==""){
		document.getElementsByTagName("body").item(0).style.fontSize=standardsize;
		document.getElementsByTagName("body").item(0).style.fontFamily=standardfont;
		storeSize()
		}
	}
	// Special setting, if you want to use the "don't save" chekbox

}
/*
	function addSize(add)
	increases the size of the document font by "add", negative values make the
	font smaller.
*/
function addSize(add){
    if (!document.layers){
	doc = document.getElementsByTagName("body").item(0)
	size=parseInt(doc.style.fontSize)+add;

/*
Everytime you do the addSize, you add or substract 10%.
When size is set to 130, the function doesn't continue, which means the font stays
120%. Same for substracting, only font stays 80%. The test happens at 130 and 70, so to speak.
Adjust these numbers to enlarge bandwith.
Adjust the alertmessage to change it in anything you like ;)
*/
    if (screen.width >= "1024"){
    if (size < 130 && size > 70){
	doc.style.fontSize=size+"%";}
	else{
	alert("Die maximale Vergrösserung bzw. minimale Verkleinerung wurde erreicht. Wennn Sie Probleme mit der Darstellung der Schrift haben, sollen Sie in Erägung ziehen die Standardeinstellung der Schrift zu verändern. Sie finden dazu einen Artikel in der Hilfe des Kreisbehindertenportals.");
	}
    }
        if (screen.width <= "800"){
    	if (size < 100 && size > 70){
	doc.style.fontSize=size+"%";}
	else{
	alert("Not allowed, reached maximum/minimum");
	}
    }

	if (nosave==false) storeSize()
	}
}
/*
	function SetSize(add)
	sets the font size of the document.
*/
function setSize(add){
    if (!document.layers){
	document.getElementsByTagName("body").item(0).style.fontSize=add+"%";
	if (nosave==false) storeSize()
	}
}

/*
	function SetFont(add)
	sets the font face of the document.
*/
function setFont(add){
    if (!document.layers){
	doc = document.getElementsByTagName("body").item(0)
	doc.style.fontFamily=add;
	if (nosave==false) storeSize()
	}
}

/*
	function storeSize()
	saves the current settings of the document in a cookie
*/
function storeSize(){
	var exp = new Date();
	exp.setTime(exp.getTime() + 24*60*60*90*1000);
	size=document.getElementsByTagName("body").item(0).style.fontSize;
	font=document.getElementsByTagName("body").item(0).style.fontFamily;
    swidth =	 (screen.width)
	setCookie("kbrfontsize",size+":"+font+swidth,exp);
}
/*
	function setCookie()
	sets the cookie
*/
function setCookie(name, value, expires, path, domain, secure) {
	var curCookie = name + "=" + escape(value) +
	((expires) ? "; expires=" + expires.toGMTString() : "") +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	((secure) ? "; secure" : "")
	document.cookie = curCookie
}
/*
	function getCookie()
	reads the cookie
*/
function getCookie(name) {
	var prefix = name + "="
	var cookieStartIndex = document.cookie.indexOf(prefix)
	if (cookieStartIndex == -1)
	return null
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex +
	prefix.length)
	if (cookieEndIndex == -1)
	cookieEndIndex = document.cookie.length
	return unescape(document.cookie.substring(cookieStartIndex +
	prefix.length,
	cookieEndIndex))
}
