function validate(formData, jqForm, options) { 
    // formData is an array of objects representing the name and value of each field 
    // that will be sent to the server;  it takes the following form: 
    // 
    // [ 
    //     { name:  username, value: valueOfUsernameInput }, 
    //     { name:  password, value: valueOfPasswordInput } 
    // ] 
    // 
    // To validate, we can examine the contents of this array to see if the 
    // username and password fields have values.  If either value evaluates 
    // to false then we return false from this method. 
	
	//var usernameValue = $('input[@name=username]').fieldValue(); 
    var passwordValue = $('input[@name=message]').fieldValue(); 
	
 
    for (var i=0; i < formData.length; i++) { 
        if (!passwordValue[0]) { 
            alert('Please enter a message.'); 
            return false; 
        } else{
			//alert('IM IN HERE.'); 
			$('#log_res').fadeOut('slow');	
			$('#myForm').fadeOut('fast');
			$('#during').fadeIn('fast');
		} 
    } 
     
}





// prepare the form when the DOM is ready 
$(document).ready(function() { 
    // bind form using ajaxForm 
	$('#closeLink').click( function(){ $('#writeForm').fadeOut('fast'); $('#messageInput').value = '';	 }  )
	$('#markers').click( function(){
			$('#writeForm').fadeIn('fast');				  
			$('#during').hide();
			$('#success').hide();	
			$('#myForm').show();
			$('#messageInput').value = '';
			
	} )
	
	
	
	 $('#myForm').ajaxForm({ 
		beforeSubmit: validate,
        // target identifies the element(s) to update with the server response 
        target: '#log_res', 
        // success identifies the function to invoke when the server response 
        // has been received; here we apply a fade-in effect to the new content 
        success: function() { 
			//$('#myForm').fadeOut('slow'); 
			$('#during').fadeOut('fast');
			$('#success').fadeIn('fast');
			//$('#writeForm').fadeOut('fast');
			$('#log_res').fadeIn('fast'); 
		} 
    }); 
});
