var prefsLoaded = false;
var defaultFontSize = 69;
var currentFontSize = defaultFontSize;
var currentStyle = "";

function revertStyles(){

	currentFontSize = defaultFontSize;
	changeFontSize(0);
	

}

function switchDef(){
	if(currentStyle == "Sw" || currentStyle == "Neg"){
		setColor("");
	}
}

function switchSw(){
	if(currentStyle == "" || currentStyle == "Neg"){
		setColor("Sw");
	}
}

function switchNeg(){
	if(currentStyle == "" || currentStyle == "Sw"){
		setColor("Neg");
	}
}

function setColor(color){
	if(color == "Sw"){
		document.body.className = 'bodysw';
		currentStyle = "Sw";
	}else if(color == "Neg"){
		document.body.className = 'bodyneg';
		currentStyle = "Neg";	
	}else{
		document.body.className = '';
		currentStyle = "";
	}
}

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

	if(currentFontSize > 150){
		currentFontSize = 150;
	}else if(currentFontSize < 53){
		currentFontSize = 53;
	}

	setFontSize(currentFontSize);
};

function setFontSize(fontSize){
	var stObj = (document.getElementById) ? document.getElementById('content_area') : document.all('content_area');
	document.body.style.fontSize = fontSize + '%';
	
	//alert (document.body.style.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 = setWidthFont;

function setWidthFont(){
	if(!prefsLoaded){

		cookie = readCookie("fontSize");
		currentFontSize = cookie ? cookie : defaultFontSize;
		setFontSize(currentFontSize);
		
		cookie = readCookie("pageColor");
		currentStyle = cookie ? cookie : "";
		setColor(currentStyle);
		prefsLoaded = true;
	}

}

window.onunload = saveSettings;

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



/* faq funktion */
function switchDisplay(nr){
ans='ans_'+nr;
faq='faq_'+nr;
ans=document.getElementById(ans);
faq=document.getElementById(faq);
	if(ans.style.display == 'none') {
		ans.style.display = 'block';
		faq.className += " open";
		// alert (doc2.className);
	} else {
		ans.style.display = 'none';
		faq.className=faq.className.replace(" open", "");
		// alert (doc2.className);
	}
	top.focus();
}

/* faq block - anzeige - funktion */
function showFAQBlock(slist) {
	block_nr = slist.options.selectedIndex + 1;
	for (i=1; i <= slist.options.length; i++){
		the_block = document.getElementById('faq_block_' + i);
		if (i != block_nr)
			the_block.style.display = 'none';
		else
			the_block.style.display = 'block';
	}
}


/* popup product microsite*/
function open_microsite(URL) {
	var ok;
	ok=window.open (URL,"microsite","width=705,height=725,resizable=yes,scrollbars=yes,top=10");
	if (ok) return false;
	else return true;
}


function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/**
 * Hilfsfunktion zum String-Rückwärtsschreiben
 */
function strrev(str){
  var s = "";
  var i = str.length;
  while (i>0) {
      s += src.substring(i-1,i);
      i--;
  }
  return s;
}

/**
 * Fügt allen Bildern mit klasse 'switchColor' die gewünschte endung an
 */
function switchCol(neue_endung){
	images = getElementsByClass('switchColor',null,'img');
	new_endung = neue_endung != '' ? '_'+neue_endung : '';
	for (i=0; i<images.length; i++){
		src = images[i].src;
		src = src.replace('_sw.','.');
		src = src.replace('_bw.','.');
		src = strrev(src);
		endung = strrev(src.substr(0,src.indexOf('.')));
		src = strrev(src);
		images[i].src = src.replace('.'+endung,new_endung+'.'+endung);
	}
}


function popup(url,xsize,ysize) {
	var win_popup= window.open(url,"popup","width="+xsize+",height="+ysize+",scrollbars=no,resizable=no");
	win_popup.focus();
} 
// BROWSERABFRAGE **********************

//plattform:
os=navigator.platform;
Mac = (os.indexOf("Mac") != -1) ? 1 : 0;
Win = (os.indexOf("Win") != -1) ? 1 : 0;

//browser:
var agt=navigator.userAgent.toLowerCase();

d=document;
OP = (agt.indexOf("opera") != -1) ? 1 : 0;
IE = (d.all && !OP) ? 1 : 0;
MOZ = (!d.all && d.getElementById) ? 1 : 0; // Mozillas => Firefox!!
N = (agt.indexOf("netscape") != -1 && d.getElementById) ? 1 : 0; // NTSC ab Vers. 6!!
N4 = (d.layers && !d.getElementById) ? 1 : 0;
SAF = (Mac && agt.indexOf("safari") != -1) ? 1 : 0;

// ENDE BROWSERABFRAGE **********************

// extra anweisung, damit die navigation auch auf netscape funktioniert!!
if (N) {
	document.write("<style>div.navibox {height: 2.3em}<\/style>");
}