
function linker(linkurl)
{
	if (linkurl.indexOf('http://') != -1)
		var fenster = window.open(linkurl, "_blank")
	else
		var fenster = window.open("http://"+linkurl, "_blank")
}


function getCSSrules()
{
	if (!document.styleSheets)
		return;
		
	var theRules = new Array();
	
	if (document.styleSheets[0].cssRules)
	{
		/* Firefox */
		theRules = document.styleSheets[0].cssRules;
	}
	else if (document.styleSheets[0].rules)
	{
		/* Internet Explorer */
		theRules = document.styleSheets[0].rules;
	}
	else return;
		
	return(theRules);
}



/* return the id of a CSS rule specified by name */
function findCSSrule(name)
{
	var theRules = getCSSrules();

	for (var i = 0; i < theRules.length; i++)
	{
		/* always compare case insensitive */
		if (theRules[i].selectorText.toLowerCase() == name.toLowerCase())
		{
			return(i);
		}
	}
}



/* set isTable to TRUE for table elements */
function toggleCSSdisplaystatus(class_name, isTable)
{
	
	/* todo: save status in cookies; toggle UI element to reflect status */
	
	var theRules = getCSSrules();

	idx = findCSSrule(class_name);

	if ((theRules[idx].style.display == 'none') || (theRules[idx].style.display == ''))
	{
		/* for table elements: handle FF and IE differently */
		if (isTable)
		{
			if (navigator.appName == "Microsoft Internet Explorer")
				theRules[idx].style.display = 'block';
			else
				theRules[idx].style.display = 'table-row';
		}
		else
			theRules[idx].style.display = 'block';
	}
	else
	{
		theRules[idx].style.display = 'none';
	}
	
	return true;
}


function togglevisibilitybyid(id)
{
	if ( (document.getElementById(id).style.display == 'none') || (document.getElementById(id).style.display == '') )
	{
		document.getElementById(id).style.display = 'block';
	}
	else
	{
		document.getElementById(id).style.display = 'none';
	}
}


function showinfolayer(id_name, head, content)
{
	if (content == '')
	{
		// empty content => hide layer
		document.getElementById(id_name).style.display = 'none';
	}
	else
	{
		if (head != '')
		{
			html = '<h4>' + head + '</h4><p>' + content;
		}
		else
		{
			html = '<p>' + content;
		}
		document.getElementById(id_name).innerHTML = html;
		document.getElementById(id_name).style.display = 'block';
	}
}



function rendertogglelink(id, text_show, text_hide)
{
	text_show = '<img src="/img/symbol-expand.gif" style="margin-right:4px;">' + text_show;
	text_hide = '<img src="/img/symbol-collapse.gif" style="margin-right:4px;">' + text_hide;

	if (document.getElementById(id).innerHTML.indexOf("collapse") == -1)
		document.getElementById(id).innerHTML = text_hide;
	else
		document.getElementById(id).innerHTML = text_show;

/* -- good for replacing text only - does not work for HTML

	if(document.all)
	{
		// IE version
		if (document.getElementById(id).innerText == text_show)
			document.getElementById(id).innerText = text_hide;
		else
			document.getElementById(id).innerText = text_show;
	}		
	else
	{
		// Firefox
		if (document.getElementById(id).textContent == text_show)
			document.getElementById(id).textContent = text_hide;
		else
			document.getElementById(id).textContent = text_show;
	}
*/
}
