/* main.js */

/* Author: Sascha Meier \*/
/* LastChangedDate: 2008-02-25 \*/
/* LastChangedBy: SM \*/

function onLoadFunctions() {
// add function calls here
initPrint();
initFontStepper();
navHover();
}
if (window.addEventListener) {
window.addEventListener("load", onLoadFunctions, true);
} else if (window.attachEvent) {
window.attachEvent("onload", onLoadFunctions);
}


/* show navi items (ie 6) */
navHover = function() {
var nav = document.getElementById("Navigation");
if (nav) {
var lis = document.getElementById("Navigation").getElementsByTagName("LI");
for (var i=0; i<lis.length; i++) {

/* find Submenuitems for all browsers except ie */
if (navigator.appName != "Microsoft Internet Explorer") {
if (lis[i].firstChild.parentNode.lastChild.tagName != "A") {
lis[i].firstChild.className+=" hasSub";
}
}
/* find Submenuitems for ie */
if (lis[i].lastChild.tagName == "UL") {
if (lis[i].firstChild.tagName == "A") {
lis[i].firstChild.className+=" hasSub";
}
}

lis[i].onmouseover=function() {
curentClass = this.className;
this.className+=" ieHover";
}
lis[i].onmouseout=function() {
this.className=curentClass;
}
lis[i].onfocus=function() {
curentClass = this.className;
this.className=" ieHover";
}
lis[i].onblur=function() {
this.className=curentClass;
}
}
}
}


// initialize print function
function initPrint() {
// show print Link
var print = document.getElementById("print");
if (print) {
  print.style.visibility = "visible";

  // set print button events
  print.href="javascript:window.print();"
  }
}

// initialize font stepper
function initFontStepper() {
// show font stepper
if (document.getElementById("fontStepper")) {
document.getElementById("fontStepper").style.visibility = "visible";

// set font stepper button events
document.getElementById("fontdec").href="javascript:fontStepper(-1, false);"
document.getElementById("fontinc").href="javascript:fontStepper(1, false);"

// get cookie value and set font stepper
/*var stepValue = parseInt(getCookieValue());
if (stepValue < 0) {
  stepValue = stepValue*(-1);
  for (var i=0; i<stepValue; i++) {
    fontStepper(-1, false);
  }
} else {
  for (var i=0; i<stepValue; i++) {
    fontStepper(1, false);
  }
}
*/
}
}


/*
function getCookieValue() {
value1 = "";
if(document.cookie)
{
value1 = document.cookie;
value1 = value1.slice(value1.indexOf("=")+1,value1.length);
}
return value1;
}
*/

/* font stepper */
var spEmStepWidth 	= 0.125;	// increase/decrease font every step by spEmStepWidth
var spEmBasis 		= 1.125;		// font size of spArticleBody at startup
var spEmStep 		= -1;		// counter for current step (leave as 0)
var spEmMaxSteps 	= 2;		// maximum steps alowed

function fontStepper(spInc, spReset) {
// reset font size
if (spReset)
spEmStep = -1;
// inside allowed steps?
if (Math.abs(spEmStep + spInc) <= spEmMaxSteps) {
// increase/decrease spEmStep
spEmStep += spInc;
// set new font size for every tag inside "spEmStep"
spEmFontSize = spEmStep * spEmStepWidth + spEmBasis;
//get spArticleBody
spEmBody = document.getElementById('mainVolumeContent');
// set new fot size
spEmBody.style.fontSize = spEmFontSize + "em";
//spEmBody.style.lineHeight = spEmFontSize+0.54 + "em";
// save value in cookie
step = spEmStep+1;
document.cookie = 'spEmStep='+step+ ';path=/;';
}
}

