
function processJson (data) {
	$('.alert').hide();
	if(data['success'] == true) {

		// Good stuff here.
		$('.alert.success .alert-text').html(data.message);
		$('.alert.success').show();

	} else {

		// Bad stuff here.
		$('.alert.error .alert-text').html(data.message);
		$('.alert.error').show();

	}
}

function requestContract() {

	var offset = $('.email-agents').offset();

	$('html, body').scrollTop(offset.top - 54);

	$('select[name=subject]').val('contract');

	$('#email-name').focus();

	return false;
}


$(function () {

	var afterText = '<li class="seperator">|</li>';
	// Adds the pipes between the footer navigation links.
	$('.after').after(afterText);

	$('#main-menu ul').superfish({
		delay: 400
	});

	$('#main-menu ul').bgiframe();

	$('#rwdb-search').css('opacity', .5);
	$('#rwdb-search *').focus(function(){
		if($('.search-term').val() == 'Search') {
			$('.search-term').val('');
		}
		$('#rwdb-search').css('opacity', 1);
	});

	$('#rwdb-search *').blur(function(){ 
		if($('.search-term').val() == '') {
			$('.search-term').val('Search');
		}
		$('#rwdb-search').css('opacity', .5);
	});

	$('.email-agents #enquiry').live('submit', function() {

		$.post(
			'property/email/json',
			$('.email-agents #enquiry').serialize(),
			function(data) {
				processJson(data);
			},
			'json'
		);
/*
		$('.email-agents #enquiry').ajaxForm({

			dataType: 'json',
			success: processJson

		});
 */	
		return false;
	
	});


});


