function tjekTal(str)
{
  var str_tilladte = '0123456789';
  
  if (str.length != 8)
    return false;
  else
    for (var i = 0; i < str.length; i++)
    {  
      var boo_fundet = false;
      for (var j = 0; j < str_tilladte.length; j++)
        if (str.charAt(i) == str_tilladte.charAt(j))
          boo_fundet = true
      if (!boo_fundet)
        return false;
    }
  
  return true;
}

function tjekPost(str)
{
  var str_tilladte = '0123456789';
  
  if (str.length != 4)
    return false;
  else
    for (var i = 0; i < str.length; i++)
    {  
      var boo_fundet = false;
      for (var j = 0; j < str_tilladte.length; j++)
        if (str.charAt(i) == str_tilladte.charAt(j))
          boo_fundet = true
      if (!boo_fundet)
        return false;
    }
  
  return true;
}

function evalForm(){
	var iResult = 1;
	var thisForm = document.forms['inputform'];
	var entry = thisForm.email.value;

	if (iResult == 1){
		if(thisForm.email.value == ""){
			alert("Du har ikke indtastet din e-mail adresse.");
			thisForm.email.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
	    if (entry.indexOf(" ") != -1){
		    alert("Din e-mail adresse kan ikke indeholde et mellemrum.");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (entry.indexOf("@") == -1){
		    alert("Din e-mail adresse indeholder ikke et @.");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (entry.indexOf("@") == 0){
		    alert("@ kan ikke stå først i din e-mail adresse.");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (entry.indexOf("@") == (entry.length-1)){
		    alert("@ kan ikke stå sidst i din email adresse.");
			thisForm.email.focus();
			iResult = 0;
		}
	}

	domain = entry.substring(entry.indexOf("@") + 1, entry.length);

	if (iResult == 1){
	    if (domain.indexOf(".") == -1){
		    alert("Du har ikke indtastet en korrekt e-mail adresse.");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (domain.indexOf(".") == 0){
		    alert("Et punktum kan ikke stå først i din e-mail adresse.");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (domain.indexOf(".") == (domain.length-1)){
		    alert("Et punktum kan ikke stå sidst i din e-mail adresse.");
			thisForm.email.focus();
			iResult = 0;
		}
	}

	if (iResult){
		thisForm.submit();
	}
}

