function getElementsByClassName(classname,tag) {
	if(!tag) tag = "*";
	var anchs =		document.getElementsByTagName(tag);
	var total_anchs = anchs.length;
	var regexp = new RegExp('\\b' + classname + '\\b');
	var class_items = new Array()
 
	for(var i=0;i<total_anchs;i++) {
		var this_item = anchs[i];
		if(regexp.test(this_item.className)) {
		 class_items.push(this_item.id);
		}
	}
	return class_items;
}

function external_links() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
	var anchor = anchors[i];
	if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
		anchor.onclick = klick;
		anchor.title = (anchor.title != "") ? anchor.title+" [öffnet in neuem Fenster]" : anchor.getAttribute("href")+" [öffnet in neuem Fenster]";
		anchor.className = (anchor.className != '') ? anchor.className+' external' : 'external';
	  }
  } 
}

function klick () {
	window.open(this.href,'_blank');
	return false;
}

function popup_links() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "popup") {
			anchor.onclick=function() {
				popup_window(this.href+'?popup=true'); return false;
			}
			anchor.title = (anchor.title != "") ? anchor.title+" [öffnet in Popup-Fenster]" : anchor.getAttribute("href")+" [öffnet in Popup-Fenster]";
			anchor.className = (anchor.className != '') ? anchor.className+' popup' : 'popup';
		}
	} 
}

function popup_window(url) {
	window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=560,height=600,screenX=150,screenY=150,top=150,left=150');
} 

function popup_closelink() {
	document.writeln('<p class="closelink">');
	document.writeln('  <a href="#" onClick=\'window.close();\' title="Popup-Fenster schließen">Fenster schließen</a>');
	document.writeln('</p>');
}

window.onload = function() {
 	external_links();
	popup_links();
}
