////////////////////////////////////////////////////////////////
//
// wStyleselector.js 1.0.2
// erstellt durch Scholl Communications AG, 77694 Kehl, www.scholl.de
// erstellt mit Weblication® Content Management Server, www.weblication.de
//
////////////////////////////////////////////////////////////////

function showStyleSector(){
  document.write('<form style="display:inline" action="styleSelector"><select id="selectbox" onchange="if(this.selectedIndex > 0){selectStyle(this.options[this.selectedIndex].value);}">');
  document.write('<option selected disabled>Ansicht wechseln</option>');
  document.write('<option value="text" title="Reine Textversion ohne Formatierungen und Bilder"> Nur Text</option>');
  document.write('<option value="default" title="Standardansicht mit Formatierungen und Bilder"> Standardansicht</option>');
  document.write('</select></form>');
}

function selectStyle(styleNew) {
  if(!styleNew || styleNew == ''){;
    var getStyleReg = /styleCurrent=(\w+)/;
    if(getStyleReg.test(document.cookie) == true){
      styleNew = RegExp.$1;
    }
    else{
      styleNew = '';
    }
  }
  if(styleNew != ''){
    if(styleNew == 'default'){
      styleNew = '';
    }
    var stylesAll = document.getElementsByTagName('link');
    for(var i = 0; i < stylesAll.length; i++){
      if(stylesAll[i].title == styleNew){
        stylesAll[i].disabled = false
      }
      else{
        stylesAll[i].disabled = true
      }
    }
    document.cookie = 'styleCurrent=' + styleNew + ';path=/';
  }
}


// Neue Funktion Schriftgrößen verändern

var prefsLoaded = false;
var defaultFontSize =75;
var currentFontSize = defaultFontSize;

function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);

}

function toggleColors(){
	if(currentStyle == "White"){
		setColor("Black");
	}else{
		setColor("White");
	}
}

function changeFontSize(sizeDifference){
	currentFontSize = parseInt(currentFontSize) + parseInt(sizeDifference * 5);

	if(currentFontSize > 100){
		currentFontSize = 100;
	}else if(currentFontSize < 70){
		currentFontSize = 70;
	}

	setFontSize(currentFontSize);
};

function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('content_area') : document.all('content_area');
	document.body.style.fontSize = fontSize + '%';


};


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;
};

window.onload = setUserOptions;

function setUserOptions(){
	if(!prefsLoaded){

		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);

		prefsLoaded = true;
	}

}

window.onunload = saveSettings;

function saveSettings()
{
  createCookie("fontSize", currentFontSize, 365);
}
