$(document).ready(function(){
	$('form.documentBlock').submit(function(){
		
		name = $(this).find('input[name="name"]').val();
		email = $(this).find('input[name="email"]').val();
		
		organization = $(this).find('input[name="organization"]').val();
		city = $(this).find('input[name="city"]').val();
		state = $(this).find('input[name="state"]').val();
		country = $(this).find('input[name="country"]').val();
		
		
		
		
		
		blocked_file = $(this).find('input[name="blocked_file"]').val();
		
		
		
		var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
	    if(!re.test(email) || name==""){
	    	alert('Please enter your name and a valid email.')
	    	return false;
	    }
	    
	    form = $(this);
	    
	    $.post('/download_submit.php',{name:name, email:email, organization:organization, city:city, state:state, country:country, blocked_file:blocked_file},function(data){
	    	form.closest('div').replaceWith(data);
	    	return;
	    })
		
		return false;
	})
})
