// JavaScript Document

// E-Mailadresse verschlüsselt ausgeben
function email(name, domain,tld, link)
	{
	var link = "<a href='mailto:"+name+"@"+domain+"."+tld+"'>"+link+"</a>";
	document.write(link);
	return true;
	}

// FELDINHALT PRÜFEN
function check(data,id)
	{			
	if (document.getElementById(id).value == data) {
		document.getElementById(id).value = '';
		}
	}
function check2(data,id)
	{			
	if (document.getElementById(id).value == '') {
		document.getElementById(id).value = data;
		}
	}	

// Ein- und Ausblenden von LAYERN
function display(name,shut)
	{
	if (shut == 1) { view = 'none'; }
	if (shut == 0) { view = 'block'; }
	if (!shut) { view = (document.getElementById(name).style.display == 'none') ? 'block' : 'none'; }
	document.getElementById(name).style.display = view;
	return true;
	}


// POPUP öffnen
function popup(datei,height,width)
	{
	var fenster = 'datei';
	fenster = window.open(datei,'_blank', 'innerHeight=' + height + ',innerWidth=' + width + 'resizeable=no,scrollbars=no,status=no,toolbar=no,location=no,dependent=yes');
	fenster.focus();
	return true;	
	}
	
// ALLE CHECKBOXEN AUSWÄHLEN
function ALLChoice(field, i)
{
  var checkcount = 0;
  var loop;
  for (loop = 1; loop < field.length; loop++)
  {
    if (i == 0)
    {
      field[loop].checked = field[0].checked;
    }
    else
    {
      if (field[loop].checked)
      {
        checkcount++;
      }
      field[0].checked = (checkcount == field.length-1);
    }
  }
}

// EXTERNE LINKS KENNZEICHEN ##############################################################################################
function enhanceLinks() {
	var links = document.getElementsByTagName("a");
	var thisDomain = document.domain.split('www.');
	var thisDomain = (thisDomain[1]) ? thisDomain[1] : document.domain ;
	for (var i = 0; i < links.length; i++) {
  		if((links[i].href.indexOf(thisDomain) == -1) && (links[i].href != '') && (!document.links[i].href.match(/^mailto:/)) && !document.links[i].className.match(/noenhance/)) {
			document.links[i].className = document.links[i].className + 'link_ext';
			document.links[i].onclick = function() { window.open(this.href); return false; };
 		 }
		// or else do this too if you like
		// else
		// {
		//	links[i].target = '_self';
		//	links[i].className = 'link_int';
		// }
		}
	}
	
// MEHRERE ONLOAD-EVENTS HINZUFÜGEN #######################################################################################
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

addLoadEvent( function() {enhanceLinks()} );
