illegal = new Array("(",")","<",">",",","€","http://","https://","ftp://","$");
function errormsg(text)
{
	window.document.emailcheck.ausgabe.className = "wrong";
	window.document.emailcheck.ausgabe.value = text;
	error=true;
}
function mailcheck(mail)
{	
	error = false;
	if (mail.charAt(0) == ".") { errormsg("No dot as first symbol"); }
	else if (!(mail.indexOf("@") > 0)) { errormsg("@ is missing or 1 symbol before @"); }
	else if (mail.lastIndexOf("@") != mail.indexOf("@")) { errormsg("Only one @ allowed"); }
	else if ((mail.charAt(mail.indexOf("@")-1) == ".") || (mail.charAt(mail.indexOf("@")+1) == ".")) { errormsg("Before and after @ no dot allowed"); }
	else if (mail.charAt(mail.indexOf("@")+2) == ".") { errormsg("At least two symbols before @"); }
	else if (mail.lastIndexOf(".") < mail.lastIndexOf("@")) { errormsg(".suffix missing (local@domain.suffix)"); }
	else if (!(mail.length > (mail.lastIndexOf(".")+2))||!(mail.length < (mail.lastIndexOf(".")+6))) { errormsg("After last dot at least 2-4 letters"); }
	if (window.document.emailcheck.eingabe.value == "") { window.document.emailcheck.ausgabe.value = ""; }
	for(i in illegal) { if (mail.indexOf(illegal[i]) != -1) { errormsg(illegal[i] + " not allowed!"); } }
	if (error==false)
	{
		window.document.emailcheck.ausgabe.className = "right";
		window.document.emailcheck.ausgabe.value ="E-Mail is valid!";
		return true;
	}
}