$(document).ready(function(){		
	$(".menu ul").hover(
		function(){$(this).parent().children('a:first').addClass('dropdown');},
		function(){$(this).parent().children('a:first').removeClass('dropdown');}
	);
	 $('#fsearch').val('street, suburb, post code or property id').focus(function(){ $(this).val(''); }).blur(function(){ if($(this).val() == '') $(this).val('street, suburb, post code or property id'); });
	var SITE_PATH = '/';
	options = { serviceUrl: SITE_PATH+'fsbsearch.php',
			minChars:3, 
			delimiter: /(,|;)\s*/, // regex or character
			maxHeight:200,
			width:233,
			zIndex: 100000,
			deferRequestBy: 0, //miliseconds
			noCache: true, //default is false, set to true to disable caching
			// callback function:
			onSelect: function(value, data){ $('#suburb_id').val(data); }
			};
	$('#fsearch').autocomplete(options);
	$('#header_search_form input[type="button"]').click(function() {
		if($(this).attr('name') == 'buy_btn') {
			$('#header_search_form').attr('action', SITE_PATH+'buying/listings.php');
			if($('#suburb_id').val() != "" && $('#fsearch').val() == "") {$('#suburb_id').val('');}
		}else if($(this).attr('name') == 'rent_btn') {
			$('#header_search_form').attr('action', SITE_PATH+'renting/rental-listings.php');
			if($('#suburb_id').val() != "" && $('#fsearch').val() == "") {$('#suburb_id').val('');}
		}
		$('#header_search_form').submit();
	});
});

