function getContents(elm) {
	divs = elm.getElementsByTagName('div');
	var contents=new Array();
	var j = 0;
	for (var i = 0; i < divs.length; i++)
	{
		if (cls.has(divs[i],'content')) 
		{
			contents[j++] = divs[i];
		}
	}
	return contents;
}

function getItems(elm) {
	return elm.getElementsByTagName('li');
}

function switchOff(items,contents)
{
	for (var i = 0; i < items.length; i++)
	{
		cls.remove(items[i],'active');
	}
	for (i = 0; i < contents.length; i++)
	{
		cls.remove(contents[i],'active');
	}
}

function switchContent(elm,contentId)
{
	// zjistime si potrebne rodicovske elementy
	parentSwitchBox = elm.parentNode.parentNode.parentNode;
	parentUl = elm.parentNode.parentNode;
	parentAnchor = elm.parentNode;
	// zjistime si potrebne obsahy = boxiky a jejich zapinaci odkazy
	contents = getContents(parentSwitchBox);
	items = getItems(parentUl);
	// cilovy boxik, ktery ma byt zapnut
	content = document.getElementById(contentId);
	// vypneme
	switchOff(items,contents);
	// zapneme
	cls.add(content,'active');
	cls.add(parentAnchor,'active');
	return false;
}


var cls = {
	
	
	get : function (elm) {
		if (elm && elm.tagName) {
			var classes = [];
			if (elm.className) {	
				var cl = elm.className.replace(/\s+/g, " ");
				classes = cl.split(" ");
			}
			return classes;
		}
		return false;
	},
	
	
	has : function (elm, cl) {
		if ((actCl = cls.get(elm)) && (typeof(cl) == "string")) {
			for (var i = 0; i < actCl.length; i++) {
				if (actCl[i] == cl) {
					return true;
				}
			}
		}
		return false;
	},
	
	
	add : function (elm, cl) {
		if ((actCl = cls.get(elm)) && (typeof(cl) == "string")) {
			if (!cls.has(elm, cl)) {
				elm.className += (actCl.length > 0) ? " " + cl : cl;
			}
			return true;
		}
		return false;
	},
	
	
	remove : function (elm, cl) {
		if ((actCl = cls.get(elm)) && (typeof(cl) == "string")) {
			tempCl = "";
			for (var i = 0; i < actCl.length; i++) {
				if (actCl[i] != cl) {
					if (tempCl != "") {tempCl += " ";}
					tempCl += actCl[i];
				}
				elm.className = tempCl;
			}
			return true;
		}
		return false;
	},
	
	
	replace : function (elm, oldCl, newCl) {
		if ((actCl = cls.get(elm)) && (typeof(oldCl) == "string") && (typeof(newCl) == "string")) {
			tempCl = "";
			if (cls.has(elm, newCl)) {
				cls.remove(elm, oldCl);
			} else if (cls.has(elm, oldCl)) {
				for (var i = 0; i < actCl.length; i++) {
					if (tempCl != "") {tempCl += " ";}
					tempCl += (actCl[i] == oldCl) ? newCl : actCl[i];
				}
				elm.className = tempCl;
			} else {
				cls.add(elm, newCl);
			}
			return true;
		}
		return false;
	}

}
