/* main.js */

/* Author: Sascha Meier \*/
/* LastChangedDate: 2008-02-25 \*/
/* LastChangedBy: SM \*/

function onLoadFunctions() {
// add function calls here
navHover();
initHovers("ul","destination");
initPrint();
initFontStepper();
}
if (window.addEventListener) {
window.addEventListener("load", onLoadFunctions, true);
} else if (window.attachEvent) {
window.attachEvent("onload", onLoadFunctions);
}

// 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('volume');
// 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=/;';
}
}

/* Bookmark functionality */
function addBookmark() {
	if (window.navigator.appName == "Microsoft Internet Explorer") {
		window.external.addFavorite('http://www.derpartner.de','Derpart Travel Service');
	}
	else {
		window.external.addPanel('Derpart Travel Service', 'http://www.derpartner.de/', '');
	}
}

/* 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 hovers
function initHovers(tag,IdName) {
// set hover
var lis = document.getElementsByTagName(tag);
for (var i=0; i<lis.length; i++) {
if (lis[i].id == IdName) {
lis[i].onmouseover=function() {
this.className = this.id+"Hover";
}
lis[i].onmouseout=function() {
this.className = "";
}
} else if (!IdName) {
if (lis[i].className) {
lis[i].classNames = lis[i].className.split(" ");
if (lis[i].classNames.length > 0) {
lis[i].classes = "";
for (var z=0; z<lis[i].classNames.length; z++) {
lis[i].classes +=  " "+lis[i].classNames[z];
}

}



lis[i].onmouseover=function() {
this.className = this.classes+" "+this.classNames[0]+"Hover";
}
lis[i].onmouseout=function() {
this.className = this.classes;
}
lis[i].onfocus=function() {
this.className = this.classes+" "+this.classNames[0]+"Hover";
}
lis[i].onblur=function() {
this.className = this.classes;
}
}
}
}
}