// Form validation for login-form
function LoginFormFP() {
	
	if (document.LoginForm.Username.value=="")
	{ alert("You have not entered your email address");
	document.LoginForm.Username.focus();
	return false;}
	
	else if (document.LoginForm.Password.value=="")
	{ alert("You have not entered your password");
	document.LoginForm.Password.focus();
	return false;}
	
	return true;}

function LoginFormNormal() {
	
	if (document.LoginForm2.Username.value=="")
	{ alert("You have not entered your email address");
	document.LoginForm2.Username.focus();
	return false;}
	
	else if (document.LoginForm2.Password.value=="")
	{ alert("You have not entered your password");
	document.LoginForm2.Password.focus();
	return false;}
	
	return true;}


// Formvalidation - send password to user
function sendpasswordValidate() {
	if (document.passwordform.email.value=="")
	{ alert("You have not entered your email address");
	document.passwordform.email.focus();
	return false;}
	
	else if (document.passwordform.email.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.passwordform.email.focus();
	return false;}
	
	else if (document.passwordform.email.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.passwordform.email.focus();
	return false;}

	return true;}

// Form validation for add class
function AddUnionFormCheck() {
	
	if (document.AddUnionForm.UnionName.value=="")
	{ alert("You have not entered your club’s name");
	document.AddUnionForm.UnionName.focus();
	return false;}
	
	else if (document.AddUnionForm.UnionAddress.value=="")
	{ alert("You have not entered your club’s address");
	document.AddUnionForm.UnionAddress.focus();
	return false;}
	
	else if (document.AddUnionForm.UnionZIP.value=="")
	{ alert("You have not entered your club’s post code");
	document.AddUnionForm.UnionZIP.focus();
	return false;}
	
	else if (document.AddUnionForm.UnionCity.value=="")
	{ alert("You have not entered your club’s city");
	document.AddUnionForm.UnionCity.focus();
	return false;}
	
	else if (document.AddUnionForm.MemberName.value=="")
	{ alert("You have not entered your name");
	document.AddUnionForm.MemberName.focus();
	return false;}
	
	else if (document.AddUnionForm.MemberEmail.value=="")
	{ alert("You have not entered your email address");
	document.AddUnionForm.MemberEmail.focus();
	return false;}
	
	else if (document.AddUnionForm.MemberEmail.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.AddUnionForm.MemberEmail.focus();
	return false;}
	
	else if (document.AddUnionForm.MemberEmail.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.AddUnionForm.MemberEmail.focus();
	return false;}
	
	else if (document.AddUnionForm.MemberEmail2.value=="")
	{ alert("You have not entered your email address twice");
	document.AddUnionForm.MemberEmail2.focus();
	return false;}
	
	else if (document.AddUnionForm.MemberEmail.value != document.AddUnionForm.MemberEmail2.value)
	{ alert('Your email address is not identical');
	return false;}
	
	else if (document.AddUnionForm.Password.value=="")
	{ alert("You have not entered your password");
	document.AddUnionForm.Password.focus();
	return false; }
	
	else if (document.AddUnionForm.Password2.value=="")
	{ alert("You have not entered  your password");
	document.AddUnionForm.Password2.focus();
	return false; }
	
	else if (document.AddUnionForm.Password.value != document.AddUnionForm.Password2.value)
	{ alert('The password is not identical');
	return false;}
	
	else if(!document.AddUnionForm.Terms.checked)
	{ alert('You have not accepted our Terms and Conditions!');
	return false; }
	
	else if (document.AddUnionForm.captchacode.value=="")
	{ alert("You have not entered the security code");
	document.AddUnionForm.captchacode.focus();
	return false; }
	
	return true;}

// Form validation for new user form (step 2)
function AddClassCheck() {
	
	if (document.AddClassForm.ClassName.value=="")
	{ alert("Du har ikke indtastet din klasse");
	document.AddClassForm.ClassName.focus();
	return false;}
	
	return true;}

// Form validation for new user form (step 3)
function AddUser3Validate() {
	
	if (document.AddUserForm.MemberName.value=="")
	{ alert("You have not entered your name");
	document.AddUserForm.MemberName.focus();
	return false;}
	
	else if (document.AddUserForm.MemberEmail.value=="")
	{ alert("You have not entered your email address");
	document.AddUserForm.MemberEmail.focus();
	return false;}
	
	else if (document.AddUserForm.MemberEmail.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.AddUserForm.MemberEmail.focus();
	return false;}
	
	else if (document.AddUserForm.MemberEmail.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.AddUserForm.MemberEmail.focus();
	return false;}
	
	else if (document.AddUserForm.MemberEmail.value != document.AddUserForm.MemberEmail2.value)
	{ alert('Your email address is not identical');
	return false;}
	
	else if (document.AddUserForm.MemberPassword.value=="")
	{ alert("You have not entered your password");
	document.AddUserForm.MemberPassword.focus();
	return false; }
	
	else if (document.AddUserForm.MemberPassword2.value=="")
	{ alert("You have not entered  your password");
	document.AddUserForm.MemberPassword2.focus();
	return false; }
	
	else if (document.AddUserForm.MemberPassword.value != document.AddUserForm.MemberPassword2.value)
	{ alert('The password is not identical');
	return false;}
	
	else if(!document.AddUserForm.Terms.checked)
	{ alert('You have not accepted our Terms and Conditions!');
	return false; }

	return true;}

// Form validation for recommend class form
function RecommendUnionFormCheck() {
	
	if (document.RecommendForm.RecipientName.value=="")
	{ alert("You have not entered a name");
	document.RecommendForm.RecipientName.focus();
	return false;}
	
	else if (document.RecommendForm.RecipientEmail.value=="")
	{ alert("You have not entered your email address");
	document.RecommendForm.RecipientEmail.focus();
	return false;}
	
	else if (document.RecommendForm.RecipientEmail.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.RecommendForm.RecipientEmail.focus();
	return false;}
	
	else if (document.RecommendForm.RecipientEmail.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.RecommendForm.RecipientEmail.focus();
	return false;}

	return true;}

// Form validation for recommend shop form
function RecommendShopFormCheck() {
	
	if (document.RecommendForm.RecipientEmail.value=="")
	{ alert("You have not entered your friend’s email address");
	document.RecommendForm.RecipientEmail.focus();
	return false;}
	
	else if (document.RecommendForm.RecipientEmail.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.RecommendForm.RecipientEmail.focus();
	return false;}
	
	else if (document.RecommendForm.RecipientEmail.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.RecommendForm.RecipientEmail.focus();
	return false;}
	
	else if (document.RecommendForm.SenderName.value=="")
	{ alert("You have not entered your name");
	document.RecommendForm.SenderName.focus();
	return false;}
	
	else if (document.RecommendForm.SenderEmail.value=="")
	{ alert("You have not entered your own email address");
	document.RecommendForm.SenderEmail.focus();
	return false;}
	
	else if (document.RecommendForm.SenderEmail.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.RecommendForm.SenderEmail.focus();
	return false;}
	
	else if (document.RecommendForm.SenderEmail.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.RecommendForm.SenderEmail.focus();
	return false;}
	
	return true;}

// Form validation for basket
function BasketFormCheck() {
	if (document.BasketForm.Name.value=="")
	{alert("You have not entered your name");
	document.BasketForm.Name.focus();
	return false;}
	
	else if (document.BasketForm.Address.value=="")
	{ alert("You have not entered an address");
	document.BasketForm.Address.focus();
	return false;}
	
	else if (document.BasketForm.ZIP.value=="")
	{ alert("You have not entered a post code");
	document.BasketForm.ZIP.focus();
	return false;}
	
	else if(!document.BasketForm.ZIP.value.match(/^[0-9]/))
	{ alert("The post code is not valid");
	document.BasketForm.ZIP.focus();
	return false; }
	
	else if (document.BasketForm.City.value=="")
	{ alert("You have not entered a city");
	document.BasketForm.City.focus();
	return false;}
	
	else if (document.BasketForm.Telephone.value=="")
	{ alert("You have not entered your phonenumber");
	document.BasketForm.Telephone.focus();
	return false;}
	
	else if (document.BasketForm.Email.value=="")
	{ alert("You have not entered your email address");
	document.BasketForm.Email.focus();
	return false;}
	
	else if (document.BasketForm.Email.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.BasketForm.Email.focus();
	return false; }
	
	else if (document.BasketForm.Email.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.BasketForm.Email.focus();
	return false; }
}

// FORMULARVALIDERING TIL ORDREFORMULAR - DANSK
function OrderFormDA() {
	
	submitState = "true"
	
	var i,c=0;
	for (i=0;i<document.check.betaling.length;i++)
		if (document.check.betaling[i].checked) c++;
	if (c==0) {
	alert('You have not selected a method of payment');
	submitState = "false"; }

	if (document.check.navn.value==""){
	alert("You have not entered your name");
	document.check.navn.focus();
	submitState = "false"; }
	
	else if (document.check.adresse.value==""){
	alert("You have not entered your address");
	document.check.adresse.focus();
	submitState = "false"; }
	
	else if (document.check.postnummer.value=="")
	{ alert("You have not entered your post code");
	document.check.postnummer.focus();
	submitState = "false"; }
	
	else if (document.check.postdistrikt.value=="")
	{ alert("You have not entered your post code");
	document.check.postdistrikt.focus();
	submitState = "false"; }
	
	else if (document.check.land.value=="")
	{ alert("you have not entered your country");
	document.check.land.focus();
	submitState = "false"; }
	
	else if (document.check.telefon.value=="")
	{ alert("You have not entered your phonenumber");
	document.check.telefon.focus();
	submitState = "false"; }
	
	else if (document.check.email.value=="")
	{ alert("You have not entered your email address");
	document.check.email.focus();
	submitState = "false"; }
	
	else if (document.check.email.value.indexOf("@") == -1 )
	{ alert("The email address is not valid");
	document.check.email.focus();
	submitState = "false"; }
	
	else if (document.check.email.value.indexOf(".") == -1 )
	{ alert("The email address is not valid");
	document.check.email.focus();
	submitState = "false"; }
	
	if (submitState=="true") { document.forms['check'].submit(); }
}

//FORMVALIDERING TIL ORDER STEP 2 (OPSUMMERING)
function OrderForm2DA() {
	
	submitState = "true"
	
	if(!document.check.terms.checked)
	{ alert('Du har ikke accepteret salgs- og leveringsbetingelserne!');
	submitState = "false"; }
	
	if (submitState=="true") { document.forms['check'].submit(); }
}

//FORMVALIDERING TIL KREDITKORTBETALING
function CreditCardForm() {
	
	submitState = "true"
	
	if (document.myForm.cardnum.value=="")
	{ alert("Du har ikke indtastet et kortnummer");
	document.myForm.cardnum.focus();
	submitState = "false"; }
	
	else if(!document.myForm.cardnum.value.match(/^[0-9]/))
	{ alert("Kortnummer er ikke korrekt udfyldt");
	document.myForm.cardnum.focus();
	submitState = "false"; }
	
	else if(document.myForm.cardnum.value.length <= 15)
	{ alert("Kortnummer er ikke korrekt udfyldt");
	document.myForm.cardnum.focus();
	submitState = "false"; }
	
	else if (document.myForm.emonth.value=="")
	{ alert("Du har ikke indtastet en udløbsmåned");
	document.myForm.emonth.focus();
	submitState = "false"; }
	
	else if(!document.myForm.emonth.value.match(/^[0-9]/))
	{ alert("Udløbsmåned er ikke korrekt udfyldt");
	document.myForm.emonth.focus();
	submitState = "false"; }
	
	else if(document.myForm.emonth.value.length <= 3)
	{ alert("Udløbsmåned er ikke korrekt udfyldt");
	document.myForm.emonth.focus();
	submitState = "false"; }
	
	else if (document.myForm.eyear.value=="")
	{ alert("Du har ikke valgt et udløbsår");
	document.myForm.eyear.focus();
	submitState = "false"; }
	
	else if(!document.myForm.eyear.value.match(/^[0-9]/))
	{ alert("Udløbsår er ikke korrekt udfyldt");
	document.myForm.eyear.focus();
	submitState = "false"; }
	
	else if(document.myForm.eyear.value.length <= 3)
	{ alert("Udløbsår er ikke korrekt udfyldt");
	document.myForm.eyear.focus();
	submitState = "false"; }
	
	else if (document.myForm.cvc.value=="")
	{ alert("Du har ikke indtastet kontrolcifre");
	document.myForm.cvc.focus();
	submitState = "false"; }
	
	else if(!document.myForm.cvc.value.match(/^[0-9]/))
	{ alert("Kontrolcifre er ikke korrekt udfyldt");
	document.myForm.cvc.focus();
	submitState = "false"; }
	
	else if(document.myForm.cvc.value.length <= 2)
	{ alert("Kontrolcifre er ikke korrekt udfyldt");
	document.myForm.cvc.focus();
	submitState = "false"; }
	
	if (submitState=="true") { document.forms['check'].submit(); }
}