$(document).ready(function(){
	
	//erase the hint text
	$("#sterm").click(function(){
		$("#sterm").attr("value","");
	});
	
	//get search results count as key is pressed
	$("#sterm").keyup(function(){
		var str; 
		str = $("#sterm").val();
		if (str.length > 0) {
			res = $.post ("livesearch.php", { sterm: str } , function() {
				if (res.readyState == 4) {
					if (res.status == 200)
						$("#results").html("<p>Results: "+res.responseText);
				}
			});
		}
		else {
			$("#results").empty();
		}
	});
	
	//the advanced pane
	$("#advanced").click(function(){
		alert('This feature is under development...');
	});
	
	//show the loader while fetching data with ajax
	$().ajaxStart(function(){
		$("#results").html ("<p><img src='img/loading.gif' alt='loading...' /></p>");
	});

});