var odd = "", count = 0;
function tweet(tweet){
			var t = eval(tweet), e = document.getElementById('conversation');
				
				tweet_text = t.text;
				user_icon = t.user.profile_image_url;
				
				/* this is SO not right, but fuck it, it's 1:30 in the morning */
				e.innerHTML += "<div class='tweet "+ odd.toString() +"'>\
					<img src='"+ user_icon +"'/><div class='text'>"+ tweet_text +"</div>\
				</div><div class='clear'></div>";
				
				if(t.in_reply_to_status_id){
					var head = document.getElementsByTagName('head')[0], script = document.createElement('script');
						
						script.src = 'http://twitter.com/statuses/show/' + t.in_reply_to_status_id + '.json?callback=tweet';
						script.type = 'text/javascript';
						
						head.appendChild(script);
				} else {
					updateLimit();
					if(count == 0)
						e.innerHTML += "<br/><br/><p class='note'>Err, I couldn't find any more tweets. Sure this was a conversation?</p>";
				}

				odd = (odd  == "") ? "odd" : "";
				count++;
		}

function limit(limit){//just so people know how many more tweets they can get — Peoplearedumb™
	var l = eval(limit);
	var fd = (l.reset_time_in_seconds * 1000 - (new Date()).getTime());
	console.log(fd/1000/60);
	console.log(window.fluid);
	window.notify({"title":"Conversation", "description":"You can fetch " + l.remaining_hits + " more tweets, which will be reset in about " + Math.floor(fd/1000/60) + " minutes"});
	document.getElementById('l').innerHTML = "Remaining calls: " + l.remaining_hits + ", Reset in about " + Math.floor(fd/1000/60) + " minutes";
}

function updateLimit(){
	var script = document.createElement('script');
		script.src = "http://twitter.com/account/rate_limit_status.json?callback=limit&random=" + Math.random();
		script.type = "text/javascript";
		document.getElementsByTagName('head')[0].appendChild(script);
}
