/**
 * A rather primitive Tabs - Switcher
 *
 * created for www.eurobox.at
 * (c) 200-2009 by viamedia (www.viamedia.at)
 */


var switchContent, initSwitcher; // Those must be global, since they are implemented as event - handler - attributes

(function() { // Dont pollute the global namespace

	var activeIndex = 0;
	var indizes = [];

	// Better for YUI Compressor
	function docId(id) {
		return document.getElementById(id);
	}

	switchContent = function(newActiveIndex) {
		setBoxes("normal", "none");
		activeIndex = newActiveIndex;
		setBoxes("active", "block");
	}

	/**
	 * Apply the given attr. to the active box
	 */
	function setBoxes(linkClass, boxDisplayStyle) {	
		docId("header_" + activeIndex).className = linkClass;
		docId("content_" + activeIndex).style.display = boxDisplayStyle;
	}


	/**
	 * Some initializing
	 */
	initSwitcher = function() {
		var links = docId("header_row");
		
		useIEmethod = false;
		if (navigator.appVersion.indexOf("MSIE") > 2) {
			var useIEmethod = true;
		}
		
		
		for(e=0; e < links.childNodes.length; e++) {
			
			for (f = 0; f < links.childNodes[e].attributes.length; f++) {
				var tmp = links.childNodes[e].attributes[f].value;
				
				if (typeof tmp == "string") {
					if (tmp.indexOf("header") == 0) {
						var index = tmp;
					}
				}
			}
			
			var num = parseInt(index.substr(7));
			
			if (isNaN(num) == false) {
				indizes.push(num);
			} 
		}

		if (indizes.length > 0) {
			for (i=0; i<indizes.length; i++) {
					activeIndex = indizes[i];
				if (i==0) {
					setBoxes("active", "block");
				} else {
					setBoxes("normal", "none");		
				}
			}	
			activeIndex = indizes[0];
		}
	}
})();