function emailcheck(txt)
{
	if(txt.length>0) return true; else return false;
}
function textcheck(txt)
{
	if(txt.length>0) return true; else return false;
}


$(document).ready(function(){
						   
	$('a[rel=confirm]').click(function(){
		return confirm("Weet u zeker dat u dit wilt doen?");
	});
  
  $("form").submit(function(){
	error=0;	
	//check all EMAILS
	$(this).find('input[rel=email]').each(function(){
		if(!emailcheck(this.value))
		{
			error=1;
			$(this).parents('td:first').addClass('red');
		}
		else
		{
			$(this).parents('td:first').removeClass('red');
		}
	});
	
	//check all mandatory text
	$(this).find('input[rel=text]').each(function(){
		if(!textcheck(this.value))
		{
			error=1;
			$(this).parents('td:first').addClass('red');
		}
		else
		{
			$(this).parents('td:first').removeClass('red');
		}
	});
	
	//check all mandatory select boxes
	$(this).find('select[rel=select]').each(function(){
		if(this.value=='')
		{
			error=1;
			$(this).parents('td:first').addClass('red');
		}
		else
		{
			$(this).parents('td:first').removeClass('red');
		}
	});	
	

	if(error==1)
	{
		$('.red input:first').focus();
		alert('Rood gemarkeerde items zijn niet correct ingevuld.');
		return false;
	}
	
	})
});

