var submitcount = 0;
var capCode = 0;

$(document).ready(function(){
		
	$('#account_register').click(function() { 	window.location.href 	= 'account_register.php'} )
	$('#account_lost').click(function() { 		window.location.href 	= 'account_lost.php'} )
	$('#account_data').click(function() { 		window.location.href 	= 'account_data.php'} )
	$('#account_newsletter').click(function() { 		window.location.href 	= 'newsletters.php'} )
	$('#promo_phonesites').click(function() { 	window.location.href 	= 'call_promo_sites_standard.php'} )
	$('#promo_phonebanners').click(function() { window.location.href 	= 'call_promo_banners_standard.php'} )
	$('#account_logout').click(function() { 	window.location.href 	= 'account.php?logout=true'} )
	$('#promo_smssites').click(function() { 	window.location.href 	= 'sms_promo_sites_standard.php'} )
	$('.account_login').click(function() { 		
		$('#noticeBox').empty();
		$('#loginForm2').show("slow");
	} )
	
	$('#promotor_password').keyup(function(){$('#result').html(passwordStrength($('#promotor_password').val()))})
	$('#promotor_email').keyup(function(){$('#result2').html(checkMail($('#promotor_email').val()))})
	$('#promotor_captcha').keyup(function(){$('#result3').html(checkCaptcha($('#promotor_captcha').val(),$('#captchaVerify').val()))})
});


function checkCaptcha(inputTxt,captchaCode){
	
	captchaCode = 'P' + captchaCode
	if(inputTxt.toUpperCase() == captchaCode){
		capCode = 1;
		return "Geldige antispam code";
	}
	else{
		capCode = 0;
		return "<font color=red>Voer een geldige antispam code in</font>";
	}
}


function validateLostAccountLogin(thisform)
{
	thisform.id.className = 'field fld1';
	thisform.email.className = 'field fld2';
		
	if ((thisform.id.value == null || thisform.id.value == "") && (thisform.email.value == null || thisform.email.value == ""))
	{
		alert("Je bent vergeten een promotor id of emailadres in te vullen !");
		thisform.id.className = 'loginFieldError fld1';		
		thisform.id.focus();
		thisform.id.select();
		return false;
	}
	else
	{
   	if (submitcount == 0)
	      	{
	      	submitcount++;
	      	return true;
	      	}
	  	else
	      	{
	      	alert("Het formulier is reeds verstuurd en wordt verwerkt !");
	      	return false;
	      	}
	}
}



function validatePromotor(thisform)
{
	filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	
	thisform.promotor_payments_id.className = 'promofield';
	thisform.promotor_email.className = 'promofield';
	thisform.promotor_password.className = 'promofield';
	thisform.promotor_password2.className = 'promofield';
	thisform.promotor_firstname.className = 'promofield';
	thisform.promotor_lastname.className = 'promofield';
	thisform.promotor_captcha.className = 'promofield';
	
	if (thisform.promotor_payments_id.value == null || thisform.promotor_payments_id.value == "")
	{
		alert("Je bent vergeten een Payments id in te vullen !");
		thisform.promotor_payments_id.className = 'promofieldError';
		thisform.promotor_payments_id.focus();
		thisform.promotor_payments_id.select();
		return false;
	}	
	
	else if (isNaN(thisform.promotor_payments_id.value))
	{
		alert("Je hebt een ongeldig Payments id ingevuld !");
		thisform.promotor_payments_id.className = 'promofieldError';
		thisform.promotor_payments_id.focus();
		thisform.promotor_payments_id.select();
		return false;
	}	
	
	else if (thisform.promotor_firstname.value == null || thisform.promotor_firstname.value == "")
	{
		alert("Je bent vergeten een voornaam in te vullen !");
		thisform.promotor_firstname.className = 'promofieldError';
		thisform.promotor_firstname.focus();
		thisform.promotor_firstname.select();
		return false;
	}	
	
	else if (thisform.promotor_lastname.value == null || thisform.promotor_lastname.value == "")
	{
		alert("Je bent vergeten een achternaam in te vullen !");
		thisform.promotor_lastname.className = 'promofieldError';
		thisform.promotor_lastname.focus();
		thisform.promotor_lastname.select();
		return false;
	}		
	
	else if (thisform.promotor_email.value == null || thisform.promotor_email.value == "")
	{
		alert("Je bent vergeten je email in te vullen !");
		thisform.promotor_email.className = 'promofieldError';		
		thisform.promotor_email.focus();
		thisform.promotor_email.select();
		return false;
	}
	
	else if(!filter.test(thisform.promotor_email.value))	
	{
		alert("Je hebt een ongeldig emailadres ingevoerd !");
		thisform.promotor_email.className = 'promofieldError';		
		thisform.promotor_email.focus();
		thisform.promotor_email.select();
		return false;
	}	
	
	else if (thisform.promotor_password.value == null || thisform.promotor_password.value == "")
	{
		alert("Je bent vergeten een wachtwoord in te voeren !");
		thisform.promotor_password.className = 'promofieldError';
		thisform.promotor_password.focus();
		thisform.promotor_password.select();
		return false;
	}

	else if (thisform.promotor_password.value.length < 3)
	{
		alert("Het ingevoerde wachtwoord is te kort !");
		thisform.promotor_password.className = 'promofieldError';
		thisform.promotor_password.focus();
		thisform.promotor_password.select();
		return false;
	}	
	else if (thisform.promotor_password.value != thisform.promotor_password2.value)
	{
		alert("Je moet twee maal hetzelfde wachtwoord invoeren.");
		thisform.promotor_password.className = 'promofieldError';
		thisform.promotor_password2.className = 'promofieldError';
		thisform.promotor_password.focus();
		thisform.promotor_password.select();
		return false;
	}	
	
	else if (thisform.promotor_captcha.value == null || thisform.promotor_captcha.value == "")
	{
		alert("Je bent vergeten de antispam code in te voeren !");
		thisform.promotor_captcha.className = 'promofieldError';
		thisform.promotor_captcha.focus();
		thisform.promotor_captcha.select();
		return false;
	}

	else if (thisform.promotor_captcha.value.length < 5 || capCode == 0)
	{
		alert("De ingevoerde antispam code is ongeldig !");
		thisform.promotor_captcha.className = 'promofieldError';
		thisform.promotor_captcha.focus();
		thisform.promotor_captcha.select();
		return false;
	}		
	
	else 
	{
   	if (submitcount == 0)
	      	{
	      	submitcount++;
	      	return true;
	      	}
	  	else
	      	{
	      	alert("Het formulier is reeds verstuurd en wordt verwerkt !");
	      	return false;
	      	}
	}
}

function validatePromotor_account_data(thisform)
{
	filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

	thisform.promotor_email.className = 'promofield';
	thisform.promotor_password.className = 'promofield';
	thisform.promotor_password2.className = 'promofield';	

	
	if (thisform.promotor_email.value == null || thisform.promotor_email.value == "")
	{
		alert("Je bent vergeten je email in te vullen !");
		thisform.promotor_email.className = 'promofieldError';		
		thisform.promotor_email.focus();
		thisform.promotor_email.select();
		return false;
	}
	
	else if(!filter.test(thisform.promotor_email.value))	
	{
		alert("Je hebt een ongeldig emailadres ingevoerd !");
		thisform.promotor_email.className = 'promofieldError';		
		thisform.promotor_email.focus();
		thisform.promotor_email.select();
		return false;
	}	
	
	else if (thisform.promotor_password.value == null || thisform.promotor_password.value == "")
	{
		alert("Je bent vergeten een wachtwoord in te voeren !");
		thisform.promotor_password.className = 'promofieldError';
		thisform.promotor_password.focus();
		thisform.promotor_password.select();
		return false;
	}

	else if (thisform.promotor_password.value.length < 3)
	{
		alert("Het ingevoerde wachtwoord is te kort !");
		thisform.promotor_password.className = 'promofieldError';
		thisform.promotor_password.focus();
		thisform.promotor_password.select();
		return false;
	}	
	else if (thisform.promotor_password.value != thisform.promotor_password2.value)
	{
		alert("Je moet twee maal hetzelfde wachtwoord invoeren.");
		thisform.promotor_password.className = 'promofieldError';
		thisform.promotor_password2.className = 'promofieldError';
		thisform.promotor_password.focus();
		thisform.promotor_password.select();
		return false;
	}	

	
	else 
	{
   	if (submitcount == 0)
	      	{
	      	submitcount++;
	      	return true;
	      	}
	  	else
	      	{
	      	alert("Het formulier is reeds verstuurd en wordt verwerkt !");
	      	return false;
	      	}
	}
}

function getTimeMessage(){
	
	var d = new Date();
	var time=d.getHours();
	
	if(time < 6) {
		document.write("Goedenacht");
	}	
	else if(time < 12) {
		document.write("Goedemorgen");
	}
	else if(time < 18){
		document.write("Goedemiddag");
	}
	else if(time < 24){
		document.write("Goedenavond");
	}	
}


function checkMail(email)
{
	var x = email;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return "Geldig emailadres";
	else return "<font color=red>Voer een geldig emailadres in</font>";
}


