


function m(post1, pre, post2)
{
	return '<a href="mailto:'+ma(post1, pre, post2)+'">'+ma(post1, pre, post2)+'</a>';
}


function ma(post1, pre, post2)
{
	return pre+"@"+post1+"."+post2;
}

function checkEmpty(obj, text)
{
	var str = obj.value;
	if (str.length <= 0)
	{
		obj.focus();
		alert("FEHLER!\n\n"+text);
		return false;
	}
	return true;
}

function checkLength(obj, chlength, text)
{
	var str = obj.value;
	if (str.length+1 <= chlength)
	{
		obj.focus();
		alert("FEHLER!\n\n"+text);
		return false;
	}
	return true;
}

function checkEqual(obj1, obj2, text)
{
	var str1 = obj1.value;
	    str2 = obj2.value;

	if (str1 != str2)
	{
		obj2.focus();
		alert("FEHLER!\n\n"+text);
		return false;
	}
	return true;
}


function checkEqualString(str1, str2)
{
	if (str1 != str2)
	{
		return false;
	}
	return true;
}

function checkSilentEmpty(obj)
{
	var str = obj.value;
	if (str.length <= 0)
	{
		return false;
	}
	return true;
}

function checkDate(obj_day, obj_month, obj_year,str_empty)
{

	var strCurrentChar;
	var spaceOK = true;
	var str = "";

	if (str_empty == "notempty")
	{
		if (!checkEmpty(obj_day,"Tag leer") || !checkEmpty(obj_month,"Monat leer") || !checkEmpty(obj_year,"Jahr leer"))
		{
			return false;
		}
	}
	else
	{
		if ((checkSilentEmpty(obj_day) && checkSilentEmpty(obj_month) && checkSilentEmpty(obj_year)) ||
		   (!checkSilentEmpty(obj_day) && !checkSilentEmpty(obj_month) && !checkSilentEmpty(obj_year)))
		{
		}
		else
		{
			alert("FEHLER!\n\nSie haben das Datum nicht vollständig");
			return false;
		}
	}


	var str = obj_day.value;
	for (var iLoop=0; iLoop < str.length; iLoop++)
	{
		strCurrentChar = str.substring(iLoop,iLoop+1);
		if ((strCurrentChar >= '0') && (strCurrentChar <= '9'))	{}
		else {	if (strCurrentChar == ' ') {alert("Sie haben ein Leerzeichen bei Tag eingegeben"); return false;}else{ alert("Sie haben keine Zahl bei Tag eingegeben"); return false; }}
	}

	str = obj_month.value;
	for (var iLoop=0; iLoop < str.length; iLoop++)
	{
		strCurrentChar = str.substring(iLoop,iLoop+1);
		if ((strCurrentChar >= '0') && (strCurrentChar <= '9'))	{}
		else {	if (strCurrentChar == ' ') {alert("Sie haben ein Leerzeichen bei Monat eingegeben"); return false;}else{alert("Sie haben keine Zahl bei Monat eingegeben"); return false;}	}
	}

	str = obj_year.value;
	for (var iLoop=0; iLoop < str.length; iLoop++)
	{
		strCurrentChar = str.substring(iLoop,iLoop+1);
		if ((strCurrentChar >= '0') && (strCurrentChar <= '9'))	{}
		else {	if (strCurrentChar == ' ') {alert("Sie haben ein Leerzeichen bei Jahr eingegeben"); return false;}else{alert("Sie haben keine Zahl bei Tag eingegeben"); return false;	}}
	}

  if (checkSilentEmpty(obj_day) && checkSilentEmpty(obj_month) && checkSilentEmpty(obj_year))
  {

	if ((obj_day.value < 0) || (obj_month.value < 0) || (obj_year.value < 0))
	{
		alert("Falsches Datum");
		return false;
	}

	if (obj_year.value < 2001)
	{
		alert("Falsches Datum");
		return false;
	}

	if ((obj_month.value == 4) || (obj_month.value == 6) || (obj_month.value == 9) || (obj_month.value == 11))
	{
		if (obj_day.value > 30)
		{
			alert("Falsches Datum");
			return false;
		}
	}
	
	if ((obj_month.value == 2) && (obj_day.value > 29))
	{
		alert("Falsches Datum");
		return false;
	}
	
	if ((obj_month.value == 2) && (obj_day.value == 29) && (obj_year.value % 4 != 0))
	{
		alert("Falsches Datum");
		return false;
	}
	
	if ((obj_month.value == 1) || (obj_month.value == 3) || (obj_month.value == 5) || 
		(obj_month.value == 7) || (obj_month.value == 8) || (obj_month.value == 10) || (obj_month.value == 12))
	{
		if (obj_day.value > 31)
		{
			alert("Falsches Datum");
			return false;
		}
	}
  }
  return true;
}

function mess(m)
{
	window.status = m;
}
