
function activateNav(aElem) {
	if(document.getElementById("img" + aElem)) {
		var src = document.getElementById("img" + aElem).src;
		var path = src.substring(0, src.lastIndexOf("."));
		var ext = src.substring(src.lastIndexOf("."), src.length);
		
		document.getElementById("img" + aElem).src = path + "_over" + ext;
	}
}


function showNews(aId) {
	for(var i = 1; i <= highestID; i++) {
		if(document.getElementById("DIV" + i)) document.getElementById("DIV" + i).style.display = "none";
		if(document.getElementById("TR" + i)) stripClass("TR" + i, "active");
		//debug(i);
	}
	
	if(document.getElementById("DIV" + aId)) document.getElementById("DIV" + aId).style.display = "block";
	if(document.getElementById("TR" + aId)) appendClass("TR" + aId, "active");
}


/*
	erweitert das Attribut "class" eines Elementes
*/
function appendClass(aElem, aAppendClass) {
	if(typeof aElem == "string") aElem = document.getElementById(aElem);

	//var old_class = aElem.getAttribute('class');
	var old_class = aElem.attributes['class'].nodeValue;	// IE7-Fix
	
	//if(old_class.indexOf(aAppendClass) < 0) aElem.setAttribute('class', old_class + " " + aAppendClass);
	if(old_class.indexOf(aAppendClass) < 0) aElem.className = old_class + " " + aAppendClass;
}


/*
	löscht einen Klassennamen im Attribut "class" eines Elementes
*/
function stripClass(aElem, aStripClass) {
	if(typeof aElem == "string") aElem = document.getElementById(aElem);

	//var old_class = aElem.getAttribute('class');
	var old_class = aElem.attributes['class'].nodeValue;	// IE7-Fix
	
	if(old_class.indexOf(aStripClass) >= 0) {
		var pos = old_class.indexOf(aStripClass);

		var slice1 = old_class.substring(0, pos);
		slice1 = slice1.replace(/ /, "");
		var slice2 = old_class.substring(pos + aStripClass.length, old_class.length);
		slice2 = slice2.replace(/ /, "");

		//aElem.setAttribute('class', slice1 + " " + slice2);
		aElem.className = slice1 + " " + slice2;
	}

}


function hoverImg(aWhich, aMode) {
	if(aWhich.id == "img" + activeNavImg) return false;
	
	var iSrc = aWhich.src;
	var iFile = iSrc.substring(0, iSrc.lastIndexOf("."));
	var iExt = iSrc.substring(iSrc.lastIndexOf("."), iSrc.length);
	
	if(aMode) {
		aWhich.src = iFile + "_over" + iExt;
	}
	else {
		iFile = iFile.substring(0, iFile.length - 5);
		aWhich.src = iFile + iExt;
	}
	
	return true;
}


function debug(aMsg) {
	setTimeout(function() { throw new Error("[debug] " + aMsg); }, 0);
}