
function changeDescription(id)	{
	var splitter = id.split('-');
	var statusLong = document.getElementById('long-'+splitter[1]).className.split(' ')[1];
	
	readChilds(id);
	if (statusLong == 'visible')	{
		if (document.getElementById('long-'+splitter[1])!=null) {
			document.getElementById('long-'+splitter[1]).className = document.getElementById('long-'+splitter[1]).className.split(' ')[0];
		}
		if (document.getElementById('short-'+splitter[1])!=null) {
			document.getElementById('short-'+splitter[1]).className = document.getElementById('short-'+splitter[1]).className.split(' ')[0] + ' visible';
		}
	} else	{
		if (document.getElementById('long-'+splitter[1])!=null) {
			document.getElementById('long-'+splitter[1]).className = document.getElementById('long-'+splitter[1]).className.split(' ')[0] + ' visible';
		}
		if (document.getElementById('short-'+splitter[1])!=null) {
			document.getElementById('short-'+splitter[1]).className = document.getElementById('short-'+splitter[1]).className.split(' ')[0];
		}
	}
}


function readChilds(id)	{
	var count = 0;
	if (id==undefined)	{
		var mainNode = document.getElementById('head-1').parentNode.parentNode.parentNode;
	} else	{
		var mainNode = document.getElementById(id).parentNode.parentNode.parentNode;
	}
	
	var childLength = mainNode.childNodes.length;
	for (var i=0;i<childLength;i++) {
		if (mainNode.childNodes[i].nodeName!='#text') {
			if (document.getElementById('long-'+(count+1)))	{
				count++;
			}
			document.getElementById('long-'+count).className = document.getElementById('long-'+count).className.split(' ')[0] + ' visible';
			document.getElementById('short-'+count).className = document.getElementById('short-'+count).className.split(' ')[0];
			if(document.getElementById('long-impress')!=null) {
				if (document.getElementById('long-impress').className.split(' ')[1] != 'visible') {
					document.getElementById('long-impress').className = document.getElementById('long-impress').className.split(' ')[0] + ' visible';
				}
			}
		}
	}
}


/**
 * opens the the link in a new window
 *
 * @return	boolean		returns false to prevent from deafault behavior
 */
function openThisInNewWindow() {
	var newWin = window.open(this.href);
	newWin.focus();
	return false;
};

// do on load
oldOnload = window.onload;
window.onload = function() {
	if (typeof(oldOnload) === "function") {
		oldOnload();
	}
	if (document.getElementById && document.createTextNode) {
		readChilds();
		initExternalLinks();
	}
};

/**
 * initiates all external links
 *
 * @return	void		returns nothing
 */
function initExternalLinks () {
	var allLinks = document.getElementsByTagName("a");
	var count = allLinks.length;
	for (var i=0; i<count; i++) {
		if (allLinks[i].className === "external-link-new-window") {
			allLinks[i].onclick = allLinks[i].onkeypress = openThisInNewWindow;
		}
	}
}
