////////////////////////////////////////////////////////////////
//
// 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 showStyleSelectorListbox(){
  document.write('<form name="frmStyleselector" 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="full" title="Großansicht mit Formatierungen und Bilder">Große Schrift</option>');
  document.write('<option value="default" title="Standardansicht mit Formatierungen und Bilder">Standardansicht</option>');
  document.write('<option value="text" title="Reine Textversion ohne Formatierungen und Bilder">Nur Text</option>');
  document.write('</select></form>');
}

function showStyleSelectorTextlink(){
  if(getStyleCur() != 'full'){
    document.write('<a class="viewmode" href="javascript:changeStyle(\'full\')">Grössere Ansicht</a>');
  }
  else{
    document.write('<a class="viewmode" href="javascript:changeStyle(\'default\')">Kleiner</a>');
  }    
}

function changeStyle(styleNew) {
  document.cookie = 'styleCurrent=' + styleNew + ';path=/';
  location.reload();
}

function selectStyle(styleNew) {
  if(!styleNew || styleNew == ''){;
    styleNew = getStyleCur();
  }
  if(styleNew != ''){
    if(styleNew == 'design'){
      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=/';
  }
}

function getStyleCur(){
  
  var styleNew = '';  
    
  var getStyleReg = /styleCurrent=(\w+)/;
  if(getStyleReg.test(document.cookie) == true){
    styleNew = RegExp.$1;
  }
  return styleNew;
}


// Neue Funktion Schriftgrößen verändern

var prefsLoaded = false;
var defaultFontSize =100;
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 > 140){
		currentFontSize = 140;
	}else if(currentFontSize < 80){
		currentFontSize = 80;
	}

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