$(document).ready(function(){

var options = { 
    dataType:	'json',
    success:    function(r) { 
        if(r.status == 'fail'){
        	
        	// Fill in the #status div with the returned message
        	$('#status').html(
        		'<p class="error">' + r.message + '</p>'
        	);
        	
        	// And focus the first email field
        	$('#fmail_0').css('border-color','#bb0000');
        	$('#fmail_0').focus();
        }
        
        if(r.status == 'success'){
        	
        	// Fill in the #thanks div with the returned message
        	$('#thanks').html(
        		'<h4>' + r.message + '</h4>'
        	);
        	
        	// And hide the form
        	$('#refer_form').hide();
        } 
    } 
    
}; 

var v = jQuery("#refer_form").validate({
			submitHandler: function(form) {
				jQuery(form).ajaxSubmit(options);
			}
		});
});
