$=jQuery;
function move_stream()
	{
	$(".stream").css({"backgroundPosition":"0 0"}).animate({"backgroundPosition":"-301px 0"},30000,"linear",move_stream);
	}
function movefirst(s)
	{
	if(s == 0)
		{
		$(".egg:first").remove();
		}
	pos = Math.random()*70-30;
	$(".egg:first").animate({"width":"0","opacity":0},10000,"linear",function(){
		movefirst(0);
		})
		.parent().append('<div class="egg" style="width:0;opacity:0;top:'+pos+'px" rel="'+$(".egg:first").attr('rel')+'">'+$(".egg:first").html()+"</div>");
	pos = Math.random()*70-30;
	$(".egg:last").hide().animate({"width":"11%","opacity":1},10000,"linear")
		.animate({'top':pos},10000*8,"linear");
	}
function refreshstream()
	{
	$.get("ajax",{'_r':Math.random()},function(data){
		for(eggy in data)
			{
			$('.egg[rel="'+eggy+'"] a').attr('href','adopt/'+data[eggy][0]+'-'+data[eggy][1]).find('img').attr('src','http://magistatic.com/i/'+data[eggy][1]);
			}
		setTimeout(refreshstream,1000);
		},'json');
	}
$(document).ready(function(){
	/*$('.egg').each(function(){
		pos = Math.random()*70-30;
		$(this).animate({'top':pos},10000*8,"linear");
		});*/
	move_stream();
	movefirst(1);
	setTimeout(refreshstream,2000);
	});
