$(document).ready(function () {

	$('#contactform').bind('submit', function(){
		
			$(this).find('.error:visible').hide();
			 $('span.required').each(function(){
					
					var elem = $(this).closest('.row').find(':input');
					var elem_val =	$.trim( $(elem).val() );
					$(elem).val(elem_val);
					
					// kijken of de waarde leeg is
					if ( elem_val == '' ){
						// omhoog, de .error vinden en show
						$(elem).next('.error').show();
					} 
					else if ( $(elem).attr('name') == 'address' && !echeck(elem_val) ) {
					$(elem).next('.error').show();
					}					
				});
					
				// kijken of er errors zijn, if yes return false
				if ( $(this).find('.error:visible').length >= 1 ){
					return false;
				}
		
	});
	
		
		$('#nav ul li a:not(.active)')
			.css( {backgroundPosition: "0 -164px"} )
			.find('span').css( {backgroundPosition: "100% -164px"} )
			
		$('#nav ul li a:not(.active)')
			.mouseover(function(){
				$(this).stop().animate({backgroundPosition:"(0 0px)"}, {duration:350})
				$(this).find('span').stop().animate({backgroundPosition:"(100% 0px)"}, {duration:350})
			})
			.mouseout(function(){
				$(this).stop().animate({backgroundPosition:"(0px -164px)"}, {duration:350})
				$(this).find('span').stop().animate({backgroundPosition:"(100% -164px)"}, {duration:350})
			});
			
		
	
		
});


function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
  return false;
	}
	return true;
}


