Init();

function EvalPwd(sP)
{
	var BG_COLOR_NEUTRAL = "#B0C4DE";
	var BG_COLOR_LOW = "#FF0000";
	var BG_COLOR_MEDIUM = "#FFFFAA";
	var BG_COLOR_HIGH = "#90EE90";
	var COLOR_NEUTRAL = "#336699";
	var COLOR_LOW = "#336699";
	var COLOR_MEDIUM = "#FFFFAA";
	var COLOR_HIGH = "#90EE90";
	
    if (ClientSideStrongPassword(sP, gSimilarityMap, gDictionary))
    {
		document.all.AdgkodeStyrke1.style.backgroundColor = BG_COLOR_HIGH;
		document.all.AdgkodeStyrke2.style.backgroundColor = BG_COLOR_HIGH;
		document.all.AdgkodeStyrke3.style.backgroundColor = BG_COLOR_HIGH;
		document.all.AdgkodeStyrke1.style.color = COLOR_HIGH;
		document.all.AdgkodeStyrke2.style.color = COLOR_HIGH;
    }
    else if (ClientSideMediumPassword(sP, gSimilarityMap, gDictionary))
    {
		document.all.AdgkodeStyrke1.style.backgroundColor = BG_COLOR_MEDIUM;
		document.all.AdgkodeStyrke2.style.backgroundColor = BG_COLOR_MEDIUM;
		document.all.AdgkodeStyrke3.style.backgroundColor = BG_COLOR_NEUTRAL;
		document.all.AdgkodeStyrke1.style.color = COLOR_MEDIUM;
		document.all.AdgkodeStyrke2.style.color = COLOR_NEUTRAL;
		document.all.AdgkodeStyrke3.style.color = COLOR_NEUTRAL;
    }
    else if (ClientSideWeakPassword(sP, gSimilarityMap, gDictionary))
    {
		document.all.AdgkodeStyrke1.style.backgroundColor = BG_COLOR_LOW;
		document.all.AdgkodeStyrke2.style.backgroundColor = BG_COLOR_NEUTRAL;
		document.all.AdgkodeStyrke3.style.backgroundColor = BG_COLOR_NEUTRAL;
		document.all.AdgkodeStyrke1.style.color = COLOR_LOW;
		document.all.AdgkodeStyrke2.style.color = COLOR_NEUTRAL;
		document.all.AdgkodeStyrke3.style.color = COLOR_NEUTRAL;
    }
    else
    {
		document.all.AdgkodeStyrke1.style.backgroundColor = BG_COLOR_NEUTRAL;
		document.all.AdgkodeStyrke2.style.backgroundColor = BG_COLOR_NEUTRAL;
		document.all.AdgkodeStyrke3.style.backgroundColor = BG_COLOR_NEUTRAL;
		document.all.AdgkodeStyrke1.style.color = COLOR_NEUTRAL;
		document.all.AdgkodeStyrke2.style.color = COLOR_NEUTRAL;
		document.all.AdgkodeStyrke3.style.color = COLOR_NEUTRAL;
    }
}

var TIME_OUT = 3000;	// Konstant der indeholder antal millisekunder en fejltekst skal vises
var gTimerID;

function clearErrMsg(id)
{
	eval(id).style.display = "none";
	eval(id).innerHTML = "";
}
function preventSpaces(oSPAN)
{
	// Hvis brugeren indtaster mellemrum flere gange i træk skal vi sørge for at nulstille de tidligere setTimeout's.
	if (gTimerID != null)
	{
		clearTimeout(gTimerID);
		gTimerID = null;
	}
	if (event.keyCode == 32)
	{
		oSPAN.innerHTML = "Mellemrum er ikke tilladt i dette felt";
		oSPAN.style.display = "block";
		event.returnValue = false;
		gTimerID = setTimeout("clearErrMsg(" + oSPAN.id + ")", TIME_OUT);
	}
	else
	{
		clearErrMsg(oSPAN.id);
	}
}

function preventLeadingSpaces(o, strWord)
{
	if (gTimerID != null)
	{
		clearTimeout(gTimerID);
		gTimerID = null;
	}
	if (erBlank.test(strWord) && event.keyCode == 32)
	{
		o.innerHTML = "Profilnavne må ikke begynde med mellemrum";
		o.style.display = "block";
		event.returnValue = false;
		gTimerID = setTimeout("clearErrMsg(" + o.id + ")", TIME_OUT);
	}
	else
	{
		clearErrMsg(o.id);
	}
}

function preventTrailingSpaces(o, strWord)
{
	var reTrailingSpaces = /[\s,]+$/;
	
	if (gTimerID != null)
	{
		clearTimeout(gTimerID);
		gTimerID = null;
	}
	if (reTrailingSpaces.test(strWord))
	{
		o.innerHTML = "Profilnavne må ikke slutte med mellemrum";
		o.style.display = "block";
		event.returnValue = false;
		gTimerID = setTimeout("clearErrMsg(" + o.id + ")", TIME_OUT);
	}
}

function formSubmit(handling)
{	
	if (handling == "Gem" || handling == "Opret")
	{
		
		// Fjern eventuelle fejl-asterix'er
		var oSPANS = document.forms.ProfilForm.getElementsByTagName("SPAN");
		for (i=0; i<=oSPANS.length-1; i++)
		{
			if (String(oSPANS[i].className).indexOf("asterix_error") != -1)
				oSPANS[i].className = "asterix";
		}
		
		if (!document.forms.ProfilForm.Koen[0].checked && !document.forms.ProfilForm.Koen[1].checked)
		{
			document.forms.ProfilForm.Koen[0].parentElement.children[document.forms.ProfilForm.Koen[0].parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt køn.");
			return false;
		}
		if (erBlank.test(document.forms.ProfilForm.Profilnavn.value))
		{
			document.forms.ProfilForm.Profilnavn.parentElement.children[document.forms.ProfilForm.Profilnavn.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke udfyldt profilnavn.");
			document.forms.ProfilForm.Profilnavn.focus();
			return false;
		}
		if (erBlank.test(document.forms.ProfilForm.Email.value))
		{
			document.forms.ProfilForm.Email.parentElement.children[document.forms.ProfilForm.Email.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke udfyldt e-mail.");
			document.forms.ProfilForm.Email.focus();
			return false;
		}
		// hotmail.dk domænet findes ikke. Gør brugeren opmærksom herpå.
		if (String(document.forms.ProfilForm.Email.value).indexOf("hotmail.dk") != -1)
		{
			document.forms.ProfilForm.Email.parentElement.children[document.forms.ProfilForm.Email.parentElement.children.length-1].className += " asterix_error";
			alert("Du har indtastet en Hotmail adresse med \".dk\". Da der kun findes Hotmail adresser med \".com\" bedes du rette din adresse.");
			document.forms.ProfilForm.Email.select();
			return false;
		}
		if (!emailCheck(document.forms.ProfilForm.Email.value))
		{
			document.forms.ProfilForm.Email.parentElement.children[document.forms.ProfilForm.Email.parentElement.children.length-1].className += " asterix_error";
			document.forms.ProfilForm.Email.focus();
			return false;
		}
		// Check lige om # findes i email adressen.
		var havelaage = /\#/g;
		if (havelaage.test(document.forms.ProfilForm.Email.value))
		{
			document.forms.ProfilForm.Email.parentElement.children[document.forms.ProfilForm.Email.parentElement.children.length-1].className += " asterix_error";
			alert("Du har indtastet en email adresse med \"#\". Det er ikke et gyldigt tegn.");
			document.forms.ProfilForm.Email.select();
			return false;
		}
		if (erBlank.test(document.forms.ProfilForm.Adgangskode.value))
		{
			document.forms.ProfilForm.Adgangskode.parentElement.children[document.forms.ProfilForm.Adgangskode.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke udfyldt adgangskode.");
			document.forms.ProfilForm.Adgangskode.focus();
			return false;
		}
		// Check adgangskodens styrke.
		var strongPwd = ClientSideStrongPassword(document.forms.ProfilForm.Adgangskode.value, gSimilarityMap, gDictionary);
		var mediumPwd = ClientSideMediumPassword(document.forms.ProfilForm.Adgangskode.value, gSimilarityMap, gDictionary);
		var weakPwd = ClientSideWeakPassword(document.forms.ProfilForm.Adgangskode.value, gSimilarityMap, gDictionary);
		if (!strongPwd && !mediumPwd && !weakPwd)
		{
			document.forms.ProfilForm.Adgangskode.parentElement.children[document.forms.ProfilForm.Adgangskode.parentElement.children.length-1].className += " asterix_error";
			alert("Din adgangskode er ikke sikker nok. Du kan først gemme når adgangskoden opnår styrke '" + document.all.AdgkodeStyrke1.innerHTML + "'.\nVi kan dog kun anbefale adgangskoder med styrke '" + document.all.AdgkodeStyrke3.innerHTML + "'.");
			document.forms.ProfilForm.Adgangskode.focus();
			return false;
		}
		if (!erBlank.test(document.forms.ProfilForm.Adgangskode.value) && erBlank.test(document.forms.ProfilForm.Adgangskode2.value))
		{
			document.forms.ProfilForm.Adgangskode2.parentElement.children[document.forms.ProfilForm.Adgangskode2.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke bekræftet din adgangskode.");
			document.forms.ProfilForm.Adgangskode2.focus();
			return false;
		}
		if (document.forms.ProfilForm.Adgangskode.value != document.forms.ProfilForm.Adgangskode2.value)
		{
			document.forms.ProfilForm.Adgangskode2.parentElement.children[document.forms.ProfilForm.Adgangskode2.parentElement.children.length-1].className += " asterix_error";
			alert("\"" + document.forms.ProfilForm.Adgangskode.parentElement.parentElement.children[0].innerHTML + "\" og \"" + document.forms.ProfilForm.Adgangskode2.parentElement.parentElement.children[0].innerHTML + "\" er forskellige.");
			document.forms.ProfilForm.Adgangskode2.focus();
			return false;
		}
		if (document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Dag.parentElement.children[document.forms.ProfilForm.Dag.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt dag i fødselsdato.");
			document.forms.ProfilForm.Dag.focus();
			return false;
		}
		if (document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Maaned.parentElement.children[document.forms.ProfilForm.Maaned.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt måned i fødselsdato.");
			document.forms.ProfilForm.Maaned.focus();
			return false;
		}
		if (document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Aar.parentElement.children[document.forms.ProfilForm.Aar.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt år i fødselsdato.");
			document.forms.ProfilForm.Aar.focus();
			return false;
		}
		
	    // Vi checker lige om måned og månedsdag passer sammen. F.eks er 30. februar ikke en gyldig dato.
	    if (document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value > 28)
	    {
	        // Månedsdagen er større end 28. Der kan være problemer med datoen. Vi foretager lige et par check.
	        if (document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value == 2 && document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value > 29)
	        {
	            // Datoen er ugyldig fordi februar ikke kan bestå af mere end 29 dage.
			    document.forms.ProfilForm.Dag.parentElement.children[document.forms.ProfilForm.Dag.parentElement.children.length-1].className += " asterix_error";
		        alert("Du har angivet fødelsdato til den " + document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value + ". februar " + document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value + ". Februar " + document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value + " har ikke mere end " + (erSkudaar(document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value) ? "29" : "28") + " dage.");
			    document.forms.ProfilForm.Dag.focus();
		        return false;
		    }
		    else if (document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value == 2 && document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value <= 29)
		    {
		        // Brugeren har angivet den 29. februar. Vi skal lige checke om året et et skudår.
                if (!erSkudaar(document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value))
                {
                    // Datoen er ugyldig fordi året ikke er et skudår.
    			    document.forms.ProfilForm.Dag.parentElement.children[document.forms.ProfilForm.Dag.parentElement.children.length-1].className += " asterix_error";
		            alert("Du har angivet din fødselsdato til den 29. februar " + document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value + ". Februar " + document.forms.ProfilForm.Aar.options[document.forms.ProfilForm.Aar.selectedIndex].value + " har ikke mere end 28 dage fordi det ikke er et skudår.");
    			    document.forms.ProfilForm.Dag.focus();
		            return false;
                }
            }
            else
            {
                // Måneden er ikke februar. Vi skal checke om måneden indeholder de angivne antal dage.
                var dageIMaaned = new Array(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
                var maaneder = new Array("", "Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December");
                if (parseInt(document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value) > dageIMaaned[document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value])
                {
                    // Datoen er ugyldig fordi den indeholder flere dage end måneden indeholder.
    			    document.forms.ProfilForm.Dag.parentElement.children[document.forms.ProfilForm.Dag.parentElement.children.length-1].className += " asterix_error";
		            alert("Du har angivet din fødselsdato til den " + document.forms.ProfilForm.Dag.options[document.forms.ProfilForm.Dag.selectedIndex].value + ". " + String(maaneder[document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value]).toLowerCase() + ". " + maaneder[document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value] + " måned har ikke mere end " + dageIMaaned[document.forms.ProfilForm.Maaned.options[document.forms.ProfilForm.Maaned.selectedIndex].value] + " dage.");
    			    document.forms.ProfilForm.Dag.focus();
		            return false;
                }
	        }
	    }
		
		if (document.forms.ProfilForm.Region.options[document.forms.ProfilForm.Region.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Region.parentElement.children[document.forms.ProfilForm.Region.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt bopælsregion.");
			document.forms.ProfilForm.Region.focus();
			return false;
		}
		if (erBlank.test(document.forms.ProfilForm.Hoejde.value))
		{
			document.forms.ProfilForm.Hoejde.parentElement.children[document.forms.ProfilForm.Hoejde.parentElement.children.length-1].className += " asterix_error";
			alert("Da har ikke angivet din højde.");
			document.forms.ProfilForm.Hoejde.focus();
			return false;
		}
		if (!erNumerisk.test(document.forms.ProfilForm.Hoejde.value))
		{
			document.forms.ProfilForm.Hoejde.parentElement.children[document.forms.ProfilForm.Hoejde.parentElement.children.length-1].className += " asterix_error";
			var hoejde = parseInt(document.forms.ProfilForm.Hoejde.value);
			if (isNaN(hoejde))
			    hoejde = 170;
			alert("Du skal angive din højde som et tal (uden bogstaver). F.eks. skal der kun stå \"" + hoejde + "\" og ikke \"" + hoejde + " cm\", hvis du er " + hoejde + " cm høj.");
			document.forms.ProfilForm.Hoejde.focus();
			return false;
		}
		if (parseInt(document.forms.ProfilForm.Hoejde.value) < minHoejde || parseInt(document.forms.ProfilForm.Hoejde.value) > maxHoejde)
		{
			document.forms.ProfilForm.Hoejde.parentElement.children[document.forms.ProfilForm.Hoejde.parentElement.children.length-1].className += " asterix_error";
			alert("Den angivne højde ligger uden for vores grænseværdier.\nDu kan angive højden mellem " + minHoejde + " og " + maxHoejde + ".");
			document.forms.ProfilForm.Hoejde.focus();
			return false;
		}
		if (erBlank.test(document.forms.ProfilForm.Vaegt.value))
		{
			document.forms.ProfilForm.Vaegt.parentElement.children[document.forms.ProfilForm.Vaegt.parentElement.children.length-1].className += " asterix_error";
			alert("Da har ikke angivet din vægt.");
			document.forms.ProfilForm.Vaegt.focus();
			return false;
		}
		if (!erNumerisk.test(document.forms.ProfilForm.Vaegt.value))
		{
			document.forms.ProfilForm.Vaegt.parentElement.children[document.forms.ProfilForm.Vaegt.parentElement.children.length-1].className += " asterix_error";
			var vaegt = parseInt(document.forms.ProfilForm.Vaegt.value);
			if (isNaN(vaegt))
			    vaegt = 75;
			alert("Du skal angive din vægt som et tal (uden bogstaver). F.eks. skal der kun stå \"" + vaegt + "\" og ikke \"" + vaegt + " kg\", hvis du vejer " + vaegt + " kg");			
			document.forms.ProfilForm.Vaegt.select();
			return false;
		}
		if (parseInt(document.forms.ProfilForm.Vaegt.value) < minVaegt || parseInt(document.forms.ProfilForm.Vaegt.value) > maxVaegt)
		{
			document.forms.ProfilForm.Vaegt.parentElement.children[document.forms.ProfilForm.Vaegt.parentElement.children.length-1].className += " asterix_error";
			alert("Den angivne vægt ligger uden for vores grænseværdier.\nDu kan angive vægten mellem " + minVaegt + " og " + maxVaegt + ".");
			document.forms.ProfilForm.Vaegt.focus();
			return false;
		}
		if (document.forms.ProfilForm.Haarfarve.options[document.forms.ProfilForm.Haarfarve.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Haarfarve.parentElement.children[document.forms.ProfilForm.Haarfarve.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt hårfarve.");
			document.forms.ProfilForm.Haarfarve.focus();
			return false;
		}
		if (document.forms.ProfilForm.Oejenfarve.options[document.forms.ProfilForm.Oejenfarve.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Oejenfarve.parentElement.children[document.forms.ProfilForm.Oejenfarve.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt øjenfarve.");
			document.forms.ProfilForm.Oejenfarve.focus();
			return false;
		}
		if (document.forms.ProfilForm.Partnerstatus.options[document.forms.ProfilForm.Partnerstatus.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Partnerstatus.parentElement.children[document.forms.ProfilForm.Partnerstatus.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt partnerstatus.");
			document.forms.ProfilForm.Partnerstatus.focus();
			return false;
		}
		if (document.forms.ProfilForm.JegSoeger.options[document.forms.ProfilForm.JegSoeger.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.JegSoeger.parentElement.children[document.forms.ProfilForm.JegSoeger.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt hvilke profiler du søger.");
			document.forms.ProfilForm.JegSoeger.focus();
			return false;
		}
		if (document.forms.ProfilForm.Stjernetegn.options[document.forms.ProfilForm.Stjernetegn.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Stjernetegn.parentElement.children[document.forms.ProfilForm.Stjernetegn.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt stjernetegn.");
			document.forms.ProfilForm.Stjernetegn.focus();
			return false;
		}
		if (document.forms.ProfilForm.Ryger.options[document.forms.ProfilForm.Ryger.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Ryger.parentElement.children[document.forms.ProfilForm.Ryger.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt ryger.");
			document.forms.ProfilForm.Ryger.focus();
			return false;
		}
		if (document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Boern.parentElement.children[document.forms.ProfilForm.Boern.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt børn.");
			document.forms.ProfilForm.Boern.focus();
			return false;
		}
		if (erBlank.test(document.forms.ProfilForm.AntalBoern.value))
		{
			/*alert("Da har ikke angivet antal børn.");
			document.forms.ProfilForm.AntalBoern.focus();
			return false;*/
			document.forms.ProfilForm.AntalBoern.value = 0;
		}
		if (!erNumerisk.test(document.forms.ProfilForm.AntalBoern.value))
		{
			document.forms.ProfilForm.AntalBoern.parentElement.children[document.forms.ProfilForm.AntalBoern.parentElement.children.length-1].className += " asterix_error";
			alert("Det angivne antal børn er ikke et tal.");
			document.forms.ProfilForm.AntalBoern.focus();
			return false;
		}
		// Stop brugeren hvis vedkommende har angivet antal til mindre end 0 eller større end 20
		if (document.forms.ProfilForm.AntalBoern.value < 0 || document.forms.ProfilForm.AntalBoern.value > 20)
		{
			document.forms.ProfilForm.AntalBoern.parentElement.children[document.forms.ProfilForm.AntalBoern.parentElement.children.length-1].className += " asterix_error";
			alert("Du kan angive mellem 0 og 20 børn. Du har valgt et antal som ligger uden for dette antal.");
			document.forms.ProfilForm.AntalBoern.focus();
			return false;
		}
		// Check om der er overensstemmelse mellem antal angivne børn (>0) og børne-status
		if (document.forms.ProfilForm.AntalBoern.value > 0 && (document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 1 || document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 5 || document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 6))
		{
			document.forms.ProfilForm.Boern.parentElement.children[document.forms.ProfilForm.Boern.parentElement.children.length-1].className += " asterix_error";
			alert("Der er ikke overensstemmelse mellem antal børn og status for børn");
			document.forms.ProfilForm.Boern.focus();
			return false;
		}
		// Check om der er overensstemmelse mellem antal angivne børn (=0) og børne-status
		if (document.forms.ProfilForm.AntalBoern.value < 1 && (document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 2 || document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 3 || document.forms.ProfilForm.Boern.options[document.forms.ProfilForm.Boern.selectedIndex].value == 4))
		{
			document.forms.ProfilForm.Boern.parentElement.children[document.forms.ProfilForm.Boern.parentElement.children.length-1].className += " asterix_error";
			alert("Der er ikke overensstemmelse mellem antal børn og status for børn.");
			document.forms.ProfilForm.Boern.focus();
			return false;
		}
		if (document.forms.ProfilForm.Uddannelse.options[document.forms.ProfilForm.Uddannelse.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Uddannelse.parentElement.children[document.forms.ProfilForm.Uddannelse.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt uddannelse.");
			document.forms.ProfilForm.Uddannelse.focus();
			return false;
		}
		if (document.forms.ProfilForm.Beskaeftigelse.options[document.forms.ProfilForm.Beskaeftigelse.selectedIndex].value == 0)
		{
			document.forms.ProfilForm.Beskaeftigelse.parentElement.children[document.forms.ProfilForm.Beskaeftigelse.parentElement.children.length-1].className += " asterix_error";
			alert("Du har ikke valgt beskæftigelse.");
			document.forms.ProfilForm.Beskaeftigelse.focus();
			return false;
		}
		
		// Inden vi gemmer skal vi lige checke om brugeren har indsat mellemrum før og efter profilnavnet. Hvis vedkommende har det, gør vi lige opmærksom herpå.
		if (harStartSlutMellemrum.test(document.forms.ProfilForm.Profilnavn.value))
		{
			var str1 = "";
			var str2 = "";
			if (harStartMellemrum.test(document.forms.ProfilForm.Profilnavn.value) && harSlutMellemrum.test(document.forms.ProfilForm.Profilnavn.value))
			{
				str1 = "begynder og slutter";
				str2 = "Disse";
			}
			else if (harStartMellemrum.test(document.forms.ProfilForm.Profilnavn.value))
			{
				str1 = "begynder";
				str2 = "Dette";
			}
			else if (harSlutMellemrum.test(document.forms.ProfilForm.Profilnavn.value))
			{
				str1 = "slutter";
				str2 = "Dette";
			}
			if (!confirm("Dit profilnavn " + str1 + " med mellemrum. Profilnavne må hverken begynde eller slutte med mellemrum. " + str2 + " mellemrum vil blive fjernet automatisk når du gemmer eller du kan fjerne dem selv.\nVil du gemme nu?"))
			{
				document.forms.ProfilForm.Profilnavn.focus();
				return false;
			}
		}
		
		
		document.forms.ProfilForm.Handling.value = handling;
		document.forms.ProfilForm.submit();
	}
	else if (handling == "Slet")
		document.location.href = "/Profil/SletProfil_Anmodning.asp";
}

function erSkudaar(aar)
{
    if (isNaN(aar))
        return false;
    if (window.XMLHttpRequest)
    {
        // Hvis IE7, Mozilla, Safari, etc: Brug native objekt
        var xmlHttp = new XMLHttpRequest();
        // Hvis IE7
        if (xmlHttp.overrideMimeType)
            xmlHttp.overrideMimeType("text/xml");
    }
    else
    {
        // ...ellers brug ActiveX kontrollen til IE5 og IE6
        var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlHttp.open("POST", location.protocol + "//" + location.hostname + "/Include/ErSkudaar.asp", false);
    xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-1');
    xmlHttp.send("Aar=" + aar);
    if (document.implementation.createDocument)
    {
        // Mozilla, FF
        var oNodeList = xmlHttp.responseXML.getElementsByTagName("ErSkudaar");
    }
    else if (window.ActiveXObject)
    {
        // IE
        if (xmlHttp.responseXml)
            var oNodeList = xmlHttp.responseXml.documentElement.getElementsByTagName("ErSkudaar");
        else if (xmlHttp.responseXML)
            var oNodeList = xmlHttp.responseXML.documentElement.getElementsByTagName("ErSkudaar");
    }
    if (oNodeList[0].text == "True")
        return true;
    else
        return false;
}

function sletProfilBillede()
{
	if (confirm("Du er ved at slette dit profilbillede.\nØnsker du at fortsætte?"))
	{
		document.forms.ProfilForm.Handling.value = "SletProfilbillede";
		document.forms.ProfilForm.submit();
	}
}