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 evalForm(){
	var iResult = 1;
	var thisForm = document.forms['inputform'];
	var entry = thisForm.email.value;

	if (iResult == 1){
		if(thisForm.firmanavn.value == ""){
			alert("Du har ikke indtastet et firmanavn.");
			thisForm.firmanavn.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
		if(thisForm.navn.value == ""){
			alert("Du har ikke indtastet dit navn.");
			thisForm.navn.focus();
			iResult = 0;
		}
	}
	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 kan ikke indeholde et mellemrum");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (entry.indexOf("@") == -1){
		    alert("Din e-mail 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");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (entry.indexOf("@") == (entry.length-1)){
		    alert("@ kan ikke stå sidst i din email");
			thisForm.email.focus();
			iResult = 0;
		}
	}

	domain = entry.substring(entry.indexOf("@") + 1, entry.length);

	if (iResult == 1){
	    if (domain.indexOf(".") == -1){
		    alert("Domænet indeholder ikke et punktum");
			thisForm.email.focus();
			iResult = 0;
		}
	}
	if (iResult == 1){
	    if (domain.indexOf(".") == 0){
		    alert("Et punktum kan ikke stå først i din e-mail");
			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");
			thisForm.email.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.telefonnummer.value == ""){
			alert("Du har ikke indtastet dit telefonnummer.");
			thisForm.telefonnummer.focus();
			iResult = 0;
		}
	}
	
	if (iResult == 1){
		if(thisForm.telefonnummer.value != ""){
			if (!tjekTal(thisForm.telefonnummer.value)) {
			    alert("Du har ikke indtastet et korrekt 8 cifret tlf.nr.");
			    thisForm.telefonnummer.focus();
				iResult = 0;
			}
		}
	}

	if (iResult){
		thisForm.submit();
	}
}

