﻿function fnFormAccountCreateCheck(oForm) {
	sAlert = 'Alle markerede felter skal udfyldes'
	if (oForm.frmNameCompany1.value == '') {
		oForm.frmNameCompany1.focus()
		alert(sAlert)
		return false
	}
	if (oForm.frmAddress1.value == '') {
		oForm.frmAddress1.focus()
		alert(sAlert)
		return false
	}
	if (oForm.frmZipcode.value == '' ) {
		oForm.frmZipcode.focus()
		alert(sAlert)
		return false
	}
	if (oForm.frmZipcode.value != '' ) {
		var sValue = oForm.frmZipcode.value;
		if (!fnIsValidChars(sValue, '0123456789')) {
			alert("Postnr. må kun indeholde tal")
			oForm.frmZipcode.focus()
			return false
		}
	}
	if (oForm.frmCity.value == '') {
		oForm.frmCity.focus()
		alert(sAlert)
		return false
	}
	if (oForm.frmPhone.value == '' ) {
		oForm.frmPhone.focus()
		alert(sAlert)
		return false
	}
	if (oForm.frmPhone.value != '' ) {
		var sValue = oForm.frmPhone.value;
		if (!fnIsValidChars(sValue, '0123456789')) {
			alert("Tlf.nr. må kun indeholde tal\nDu skal ikke indtaste +45 eller (45)")
			oForm.frmPhone.focus()
			return false
		}
	}
	if (oForm.frmFax.value != '' ) {
		var sValue = oForm.frmFax.value;
		if (!fnIsValidChars(sValue, '0123456789')) {
			alert("Fax.nr. må kun indeholde tal\nDu skal ikke indtaste +45 eller (45)")
			oForm.frmFax.focus()
			return false
		}
	}
	if (oForm.frmCVR.value == '') {
		oForm.frmCVR.focus()
		alert(sAlert)
		return false
	}
	if (oForm.frmCVR.value != '') {
		var sValue = oForm.frmCVR.value;
		if (!fnIsValidChars(sValue, '0123456789')) {
			alert("CVR.nr. må kun indeholde tal")
			oForm.frmCVR.focus()
			return false
		}
	}
	if (oForm.frmCVR.value != '') {
		var sValue = oForm.frmCVR.value;
		if (sValue.length < 8) {
			alert("CVR.nr. skal minimum være 8 karakterer")
			oForm.frmCVR.focus()
			return false
		}
	}
	if (!fnEmailValidate(oForm.frmEmail.value)) {
		oForm.frmEmail.focus()
		return false
	}
	if (oForm.frmPassword.value == '' || oForm.frmPasswordRepeat.value == '') {
		if (oForm.frmPassword.value == '') {
			oForm.frmPassword.focus()
		} else {
			oForm.frmPasswordRepeat.focus()
		}
		alert(sAlert)
		return false
	}
	if (oForm.frmPassword.value != oForm.frmPasswordRepeat.value) {
		oForm.frmPassword.value = ''
		oForm.frmPasswordRepeat.value = ''
		oForm.frmPassword.focus()
		alert('De indtastede adgangskoder er ikke ens, indtast venligst igen')
		return false
	}
	if (!oForm.frmNewsMail.checked) {
		bConfirm = confirm('Er du sikker på du ikke vil modtage vores nyhedsbreve.')
		if (!bConfirm) {
			oForm.frmNewsMail.checked = true
		}
	}
	oForm.xfrmSubmit.disabled = true
}

