// JavaScript Document
 $(document).ready(function() {  
  getTweet();
  scrollUp();
});  
function closePop() {
		$("#newsletter").css("display", "none");
		$("#greybackground").css("display", "none");
}
function openPop() {
		$("#newsletter").css("display", "block");
		$("#greybackground").css("display", "block");
}
function closeInt() {
		$("#interview").css("display", "none");
		$("#greybackground").css("display", "none");
}
function openInt() {
		$("#interview").css("display", "block");
		$("#greybackground").css("display", "block");
}

function scrollUp()
{
	$(function()
	{
		$.fn.scrollToTop=function()
		{
			$(this).click(function()
			{
				$("html, body").animate({scrollTop:0},"slow");
			})
		}
	});

	$(function() 
	{
		$("#toTop").scrollToTop();
		$("#toTop2").scrollToTop();
	});

}

function getTweet()  
{  
	var results = ""; 
	$.get("scripts/gettweet.php",  
		  function(xml)
		  {  
				var tweets=new Array(1);
				var index = 0;
				$('item',xml).each(
				function(i)
				{  
					
					var user_id = $(this).find("user_id").text();
					var screen_name = $(this).find("screen_name").text();
					var text = $(this).find("text").text();
					var profile_image_url = $(this).find("profile_image_url").text();
					var tweetid = $(this).find("tweetid").text();
					var date = $(this).find("date").text();
				
					tweets[i] = [user_id,screen_name,text,profile_image_url,tweetid,date];
				});  
				
				results = "<p><a href='http://twitter.com/" + tweets[index][1] + "' target='_blank'><img src='" + tweets[index][3] + "' hspace='5' align='left' border='0'>" + tweets[index][1] + "</a>: <br />" + tweets[index][2] + "</p>";
				
			  $("#feed").html(results);
			  
			  
	}); 
	setTimeout("getTweet();", 60000);
}
	
