$(function(){

	//menu navigation hovering
	$("ul#mainNav li:not('.iphone') a").hover(function() {
		//store initial background colour
		if($(this).attr("rel") == "")
		{ $(this).attr("rel", $(this).css("background-color")); }
	   
		//stop, reset colour, and then fade to hover colour
		$(this).stop().css({
			backgroundColor: $(this).attr("rel")
		}).animate({
			backgroundColor: "#fe4902"
		}, 300);
	},
	function() {
		//stop and fade to stored background colour
		$(this).stop().animate({
			backgroundColor: $(this).attr("rel")
		}, 150);
	});
	
	$("#bottom a").hover(function(){
		$(this).stop().animate({
			paddingLeft: "20px"
		}, 150);
	}, function(){
		$(this).stop().animate({
			paddingLeft: "0px"
		}, 250);
	});
	
	getTwitters('tweet', {
		id: 'chriscoyier', 
		count: 1, 
		enableLinks: true, 
		ignoreReplies: false,
		template: '%text%',
		timeout: 8000,
		onTimeout: function () {
			this.innerHTML = 'Twitter is being slow... this area will only load if Twitter is being a good boy.';
		},
		onTimeoutCancel: true
	}); 
	
    $('a').filter(function() {
    	var theHref = this;
    	if (theHref.hostname && theHref.hostname !== location.hostname) {
    		$(theHref).bind('click keypress', function(event) {
    			var code=event.charCode || event.keyCode;
    			if (!code || (code && code == 13)) {
    				if(pageTracker){
    					var fixedLink = this.href;
    					fixedLink = fixedLink.replace(/https?:\/\/(.*)/,"$1");
    					fixedLink = '/outgoing/' + fixedLink;
    					pageTracker._trackPageview(fixedLink);
    				};
    			};
    		});
    	};
    });
});