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.navn.value == ""){
			alert("Du har ikke indtastet dit navn.");
			thisForm.navn.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.adresse.value == ""){
			alert("Du har ikke indtastet din adresse.");
			thisForm.adresse.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.postnr.value == ""){
			alert("Du har ikke indtastet dit postnr.");
			thisForm.postnr.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 == 1){
		if(thisForm.email.value == ""){
			alert("Du har ikke indtastet din e-mail.");
			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.alder.value == ""){
			alert("Du har ikke indtastet din alder.");
			thisForm.alder.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.familie.value == ""){
			alert("Du har ikke beskrevet din familiesituation.");
			thisForm.familie.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.job.value == ""){
			alert("Du har ikke beskrevet din jobsituation.");
			thisForm.job.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.tiltraede.value == ""){
			alert("Du har ikke indtastet hvornår du kan tiltræde.");
			thisForm.tiltraede.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.uddannelse.value == ""){
			alert("Du har ikke beskrevet din uddannelse.");
			thisForm.uddannelse.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.kurser.value == ""){
			alert("Du har ikke beskrevet dit kursusforløb.");
			thisForm.kurser.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.kollega.value == ""){
			alert("Du har ikke beskrevet dig selv som kollega.");
			thisForm.kollega.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.kundebetjening.value == ""){
			alert("Du har ikke beskrevet dine erfaringer med kundebetjening.");
			thisForm.kundebetjening.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.itkendskab.value == ""){
			alert("Du har ikke beskrevet dit it kendskab.");
			thisForm.itkendskab.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.staerke.value == ""){
			alert("Du har ikke beskrevet dine stærke sider.");
			thisForm.staerke.focus();
			iResult = 0;
		}
	}

	if (iResult == 1){
		if(thisForm.svage.value == ""){
			alert("Du har ikke beskrevet dine svage sider.");
			thisForm.svage.focus();
			iResult = 0;
		}
	}

	if (iResult){
		thisForm.submit();
	}
}

