var q_init;
jQuery(function($) {
	
	// Grab recent tweets and stick 'em in the ...
	var url = "http://twitter.com/statuses/user_timeline/54728667.rss";
	new google.feeds.Feed(url).load(function(result) {
		var html = '';
		if (!result.error) $.each(result.feed.entries, function() {
			html = html + '<li>'+
				this.content.replace(/^(.*: )/, '').
				replace(/((?:https?:\/\/)(?:[^\s]*))/i, '<a href="$1">$1</a>').
				replace(/@([A-Za-z0-9_]*)/, '@<a class="handle" href="http://twitter.com/$1">$1</a>')+
				' <a class="time" href="'+this.link+'">'+new Date(this.publishedDate).format('h:MM TT mmm dS')+'</a></li>';
		});
		$('#twitter').append('<h3>Recently on Twitter</h3><ul>'+html+'</ul>');
	});
	// ...'cause geeks are good for some things! :)
	

	// Hook up the niceness for the search form
	q_init = $('#q').val();
	$('#q').focus(function(){
		if ($('#q').val() == q_init) {
			$('#q').val('');
		}
	});
	$('#q').blur(function(){
		if ($('#q').val() == '') {
			$('#q').val(q_init);
		}
	});


	if (!location.host.match(/shop/i)) {
		$.getJSON('http://nogeekneeded.myshopify.com/pages/cart-count?__json_cart_callback=?');
	}
});
function __json_cart_callback(json) {
	$("#account-bar span.cart-item-count").html(json.cartcount);
}
