$(document).ready(function() {
	$("input#refer").val("Jewell Real Estate Agency");
});

String.prototype.trim = function(){
	return this.replace(/^s+|\s+$/,'');
}


var LDB = {
   
	Validate:function(f){

		var msg = '';
		
		if($('#first-name').val().trim() == '' ) {
			msg += '\nFirst name is required'
		}
		
		if($('#last-name').val().trim() == '' ) {
			msg += '\nLast name is required'
		}
		
		if($('#email').val().trim() == '' ) {
			msg += '\nEmail is required'
		}
		
		if($('#refer').val().trim() == '' ) {
			msg += '\nReferring broker is required'
		}
		
		if(msg != ''){
			alert('There were errors with your form:\n'+msg);
			return false;			
		}  		
		
		var f = $('<input type="hidden" name="ajax" value="submit" />');
		
		$('#contact-form').append(f);
		
		var params = $('#contact-form').serialize();
		
		$.ajax({
			type	: "POST",
			url		: "the-grand-post.asp",
			dataType: 'text',
			async	: false,
			data	: params,
			success: function(updated) {
				if(updated == 'SUCCESS') {				
					$('#contact-form').hide();
					$('#thanks').show();
					alert(updated);
					return false;
					document.write = function(s){
				     $('body').append(s);
					}					
				}else{
					alert('An error occurred submitting the form.  Please contact webmaster for support.');
					return false;
				}			
			}
		});   
	}     
}