// JavaScript Document
$(function() 
{
	$('.social-menu li').hover(function()
	{
		$(this).css('background-position','0 -288px');
	}, function()
	{
		$(this).css('background-position','0 -428px');
	});
	
	var username='MichelePolico'; // set user name
	var format='json'; // set format, you really don't have an option on this one
	var url='http://api.twitter.com/1/statuses/user_timeline/'+username+'.'+format+'?callback=?'; // make the url
	var text;


	$.getJSON(url,function(tweet){ // get the tweets
		var t0,t1,t2,t3,t4,t5;
		tweet[0].text = tweet[0].text+ " ";
		tweet[1].text = tweet[1].text+ " ";
		tweet[2].text = tweet[2].text+ " ";
		tweet[3].text = tweet[3].text+ " ";
		tweet[4].text = tweet[4].text+ " ";
		tweet[5].text = tweet[5].text+ " ";
		t0 = tweet[0].text.replace(/(((http\:\/\/)|(www\.)).*(?=[^\.\w\d\/]))/gm,'<a href="$1">$1</a>').replace(/([\w\d\.]+\@[\w\d\.]+(\/)?)/gm,'<a href="mailto:$1$>$1</a>');
		t1 = tweet[1].text.replace(/(((http\:\/\/)|(www\.)).*(?=[^\.\w\d\/]))/gm,'<a href="$1">$1</a>').replace(/([\w\d\.]+\@[\w\d\.]+(\/)?)/gm,'<a href="mailto:$1$>$1</a>');
		t2 = tweet[2].text.replace(/(((http\:\/\/)|(www\.)).*(?=[^\.\w\d\/]))/gm,'<a href="$1">$1</a>').replace(/([\w\d\.]+\@[\w\d\.]+(\/)?)/gm,'<a href="mailto:$1$>$1</a>');
		t3 = tweet[3].text.replace(/(((http\:\/\/)|(www\.)).*(?=[^\.\w\d\/]))/gm,'<a href="$1">$1</a>').replace(/([\w\d\.]+\@[\w\d\.]+(\/)?)/gm,'<a href="mailto:$1$>$1</a>');
		t4 = tweet[4].text.replace(/(((http\:\/\/)|(www\.)).*(?=[^\.\w\d\/]))/gm,'<a href="$1">$1</a>').replace(/([\w\d\.]+\@[\w\d\.]+(\/)?)/gm,'<a href="mailto:$1$>$1</a>');
		t5 = tweet[5].text.replace(/(((http\:\/\/)|(www\.)).*(?=[^\.\w\d\/]))/gm,'<a href="$1">$1</a>').replace(/([\w\d\.]+\@[\w\d\.]+(\/)?)/gm,'<a href="mailto:$1$>$1</a>');
		
		text = "<ul><li>"+ t0 +"</li><li>"+ t1 +"</li><li>"+ t2 +"</li><li>"+ t3 +"</li><li>"+ t4 +"</li><li>"+ t5 +"</li></ul>";
		$("#friendfeed").html(text); // get the first tweet in the response and place it inside the div
	});
});
