$.fn.liveSearch = function(conf) {
	var config = $.extend({
		ajaxURL: 'http://wiki.envato.com/index.php?ajax=2&s='
	}, conf);

	return this.each(function() {
		var input		= $(this);
		var tmpOffset	= input.offset();
		var inputDim	= {
			left:	tmpOffset.left, 
			top:	tmpOffset.top, 
			width:	input.outerWidth(), 
			height:	input.outerHeight()
		};
		var results	= $('<div class="live-search-results"></div>').appendTo('#livesearch').hide().slideUp(0);
	

		input.keyup(function() {
								
			if ($.trim(this.value) == '') {
				results.slideUp(300);
			}
			else if(this.value != this.lastValue) {
				$('.ajax-loading').addClass('show_loading');

				var q = encodeURIComponent( encodeURIComponent( $.trim(this.value) ) );

				if(this.timer) {
					clearTimeout(this.timer);
				}
				
				this.timer = setTimeout(function() {
					$.get(config.ajaxURL +q, function(data) {
						
						$('.ajax-loading').removeClass('show_loading');

						if(data.length) {
							results.html(data).slideDown(300);
						}
						else {
							results.slideUp(300);
						}
						
					});
				}, 200);

				this.lastValue = this.value;
			}
		});
	});
};