// Copyright by sichtwerk.com

window.activeBt = undefined;
window.activeTableDay = 0; // day number for which the tables are visible
window.offColor;
window.bgActiveColor = '#C0E5F3 url("../../images/wetterTabBg.jpg")';
window.isIE = navigator.appName.indexOf("Microsoft") != -1;

/*
function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}*/



function init() {
	showFirstDay();
	initButtons();
}

function initButtons() {
	
	//c = document.getElementsByTagName("caption");
	//alert (c[1].nodeName);
	//alert (getStyle(c[1], "backgroundColor"));
	
	
	window.offColor = document.getElementById("day0").firstChild.style.color;
	//window.bgActiveColor = document.getElementById("day0").firstChild.style.backgroundColor;
	window.activeBt = document.getElementById("day0");
	
	if (!window.isIE) {
		numberOfDays = Math.floor(document.getElementById("days").childNodes.length/2);
	} else {
		numberOfDays = Math.floor(document.getElementById("days").childNodes.length);
	}
	
	for (var i=0; i<numberOfDays; i++) {
		var b = document.getElementById("day"+i);
		b.firstChild.style.background="transparent";
		
		b.tableE = document.getElementById("ebenalpDay"+i);
		b.tableW = document.getElementById("wasserauenDay"+i);
		b.day = i;
		
		b.onclick = function() {
			if (this != window.activeBt){
	
				//s = this.firstChild.style;
				this.firstChild.style.color="#00396A";
				this.firstChild.style.background=window.bgActiveColor;
				window.activeBt.firstChild.style.color=window.offColor;
				window.activeBt.firstChild.style.background="transparent";
				window.activeBt = this;
				this.tableE.style.display = "block";
				this.tableW.style.display = "block";
				
				t1 = document.getElementById("ebenalpDay"+window.activeTableDay);
				t2 = document.getElementById("wasserauenDay"+window.activeTableDay);
				t1.style.display = "none";
				t2.style.display = "none";
				window.activeTableDay = this.day;
			}
			
		}
		
	}
	
	
	window.activeBt.firstChild.style.color="#00396A";
	window.activeBt.firstChild.style.background=window.bgActiveColor;
	
}

function showFirstDay() {
		var e = document.getElementById("ebenalpDay0");
		var w = document.getElementById("wasserauenDay0");
		e.style.display = "block";
		w.style.display = "block";
}





