var initialRetrieval = false;
$(document).ready(function() {
	updateListings();
	if ($.browser.mozilla) {
		$("#searchKeyword").keypress(checkForEnter);
	} else {
		$("#searchKeyword").keydown(checkForEnter);
	}
	
	function checkForEnter(event) {
		if (event.keyCode == 13) {
			updateListings();
		}
	}


	$("input[type='button']").click(updateListings);
	$("#searchOptions select,input[type=text]").each(function() {
		if ((this.value != "ALL" && this.value != "") && initialRetrieval == false) {
			updateListings();
			initialRetrieval = true;
		}
	});
});

function updateListings() {
	$('#listings').html("<br /><br /><img src='/images/ajax-loader.gif'>&nbsp;&nbsp;&nbsp;<strong>Searching...</strong>");
	$.get("/landing_pages/data/getlistings.php", $('#searchOptions').serialize(),
		function(data){
			$('#listings').html(data);
			$('.multicolumn').makeacolumnlists({cols: 3, colWidth: 0, equalHeight: false, startN: 1});
		}
	);
}
