Cufon.replace('#content.front h2, #content.blog h1, #menu li');

function parseTwitterDate(text) {
	//var newtext = text.replace(/(\+\S+) (.*)/, '$2 $1');
	var newtext = text.replace(/^\w+ (\w+) (\d+) ([\d:]+) \+0000 (\d+)$/, "$1 $2 $4 $3 UTC");

	var date = new Date(Date.parse(newtext));
	var time = new Date(Date.parse(newtext));

	var month = date.getMonth() + 1;
	if (month < 10) {
		month = '0' + month;
	}

	var day = date.getDate();
	if (day < 10) {
		day = '0' + day;
	}

	var hours = time.getHours();
	if (hours < 10) {
		hours = '0' + hours;
	}

	var minutes = time.getMinutes();
	if (minutes < 10) {
		minutes = '0' + minutes;
	}
	
	return date.getFullYear() + '-' + month + '-' + day + ' ' + hours + ':' + minutes;
}

(function($) {
$(document).ready(function() {

	// ajax feed
	$.ajax({  
		url: "http://twitter.com/statuses/user_timeline/ludwigbell.json?count=1&include_rts=1&callback=?",  
		dataType: "json",  
		timeout:15000,  		
		success : function(data) {

			
			latestTweet = data[0].text;
			tweetDate	= data[0].created_at;

			$('#twitter').prepend(latestTweet);
			$('#twitter span').append(parseTwitterDate(tweetDate));
		},  
	    error : function() 
		{},
	});
	
	// menu
	$('#content.front ul#menu li a.blog').click(function(){
		$.scrollTo(70, 1000, { axis:'y' });
		return false;
	});				
	$('#content.front ul#menu li a.music').click(function(){
		$.scrollTo($('a.musicanchor').position().top - 50, 1000, { axis:'y' });
		return false;
	});				
	$('#content.front ul#menu li a.videos').click(function(){
		$.scrollTo($('a.videosanchor').position().top - 50, 1000, { axis:'y' });
		return false;
	});
	$('#content.front ul#menu li a.pictures').click(function(){
		$.scrollTo($('a.picturesanchor').position().top - 50, 1000, { axis:'y' });
		return false;
	});				
	$('#content.front ul#menu li a.bio').click(function(){
		$.scrollTo($('a.bioanchor').position().top - 50, 1000, { axis:'y' });
		return false;
	});				
	$('#content.front ul#menu li a.merch').click(function(){
		$.scrollTo($('a.merchanchor').position().top - 50, 1000, { axis:'y' });
		return false;
	});
	
	// force anchor
	var file = document.location.toString();
	
	if (file.match('#')) {
	  var anchor = file.split('#')[1];
	  $('#content.front ul#menu li a.' + anchor).click();
	} else {
		var v = file.split('?v')[1];
		if (v != undefined) {
			$('#content.front ul#menu li a.videos').click();
		}
	}
});
})(jQuery);
