$(document).ready(function()
{
	
	$('#query').keyup(function() 
	{
	if($('#query').val() != this.lastValue) {
	  if(this.timer) { clearTimeout(this.timer); }
	  this.timer = setTimeout(function() {
		
		var url=baseurl;
		
		$.post(url, {query: $('#query').val(), 'viewfile':'contentmodule/ajaxworkcontainer', 'contentid':contentid }, function(data) 
		{
			$('#searchresult').html(data);
				
		  if (data.length) { 
		  		results.html(data).slideDown(300); 
			}
		  else { results.slideUp(100); }
		}), 200 });
	
	
	  this.lastValue = this.value;
	}
	})
	
	// Prevent the form from being submitted on returns
	$('#searchfield').submit(function() {
		return false;
	})
  
});
