



$(function(){
	
 		var windowHeight = $(window).height();
		var windowWidth = $(window).width();
				if(windowHeight<680){windowHeight = 680}
		var windowHeightTxt = windowHeight +"px";
		var windowWidthTxt = windowWidth +"px";

		
		$("#bgTwitter").css({
			"height":windowHeightTxt,
			"width":windowWidthTxt
		})
		
		windowHeight += 50;
		windowWidth +=50;
		
	
		windowHeightTxt = windowHeight +"px";
		windowWidthTxt = windowWidth +"px";
		
		$("#loadtweets").css({
			"height":windowHeightTxt,
			"width":windowWidthTxt
		})
		
		if(windowWidth < 1500){
			var paged = 5;
		}else{
			var paged = 7;
		}
		
		$(".users,#theCampaign").live('mouseover mouseout', function(event) {
		  hoverObject = $(this).attr("id");
		  var caller=$(this).attr("id")
		  if (event.type == 'mouseover') {	  	
		  	setTimeout('hovering("'+caller+'")',1200)	
		  } else {
		    $(this).find("span").not(".property").fadeOut(300)
		  }
		});
		
		var searchQuery = "abettermobileweb";
		var addToList ="";
		var page = 1;
		callTwitter()
		function callTwitter(){
			$.ajax({
			   url: "http://search.twitter.com/search.json?q="+searchQuery+"&rpp=92&since=2010-01-10&page="+page+"&callback=?",
			   dataType: 'json',
			   success: function(data){	
					$(data.results).each(function(item){
			     		addToList += "<a id=a"+this.id+" class='users' target='_blank' href='http://twitter.com/"+this.from_user+"/status/"+this.id+"'><img src="+this.profile_image_url+" width='60px' height='60px'><span>"+this.from_user+" tweeted it!</span></a>";
			  	  	})
			  	  	page++	
			  	  	if(page == paged){
			  	  		appendHtml();
			  	  	}else{
			  	  		callTwitter();
			  	  	}
			   }
			});
		}
		function appendHtml(){
			$("#loadtweets").html(addToList)
			setTimeout('$("#bgTwitter").fadeIn(500)',3000)
			
		}
})	

var hoverObject = ""
function hovering(getcaller){

	if(hoverObject == getcaller){
		getcallerText = "#"+getcaller
		$(getcallerText).find("span").not(".property").fadeIn(300)
	
    }
}