function blog() {
	$('#searchform input#s').liveSearch();

	$("#blogAdmin a").hover(function(){
		$(this).css("background-position-x", "-60px")
	}, function() {
		$(this).css("background-position-x", "0")
	});
	
	$("#blogAdmin").hover(function(){
		$("#blogAdmin a#logout").stop().animate({ right: "60px", opacity: "1" }, 200);
	}, function() {
		$("#blogAdmin a#logout").stop().animate({ right: "60px" }, 1000).animate({ right: "0", opacity: "0" }, 200);
	});
}

jQuery.fn.liveSearch = function(conf) {
	var config = jQuery.extend({
		ajaxURL: '/blog/?ajax=true&s=',
		results: '#search-results'
	}, conf);
	
	/*jQuery(document.body).click(function(event) {
		if(!$(event.target).parents(config.results).length) {
			jQuery(config.results).slideUp(300);
		}
	});*/
 
	return this.each(function() {
		var input	= jQuery(this);
		var results	= jQuery(config.results).hide().slideUp(0);
 
		input.keyup(function() {
		
			if((this.value != this.lastValue) && (this.value != '')) {
				input.addClass('ajax-loading');
 
				var q = this.value;
 
				if(this.timer) {
					clearTimeout(this.timer);
				}
 
				this.timer = setTimeout(function() {
					jQuery.get(config.ajaxURL +q, function(data) {
						input.removeClass('ajax-loading');
 
						if(data.length) {
							results.html(data).slideDown(300);
						}
						else {
							results.slideUp(300);
						}
					});
				}, 200);
 
				this.lastValue = this.value;
			}
		});
		
	});
};
