$(function(){
	if($("#bannerbot").length){
		myResize();
		$(window).resize(myResize);
	}
	$.getScript("http://twitter.com/statuses/user_timeline/shop_butanta.json?callback=twitterCallback2&count=1");

	var totalBanner=$('#banner li').length;
	var banner=1;
	next();
	
	function next(){
		
			window.setTimeout(next,6000);
		

		$("#banner li").stop();

		$("#banner li[id!='b"+banner+"']").fadeTo("slow",0).css("z-index",10);
		$("#banner li[id='b"+banner+"']").fadeTo("slow",1).css("z-index",11);
		banner=banner==totalBanner?1:banner+1;		
	}
});

function myResize(){
	myHeight=($(window).height()-585)/2;
	if(myHeight<10){myHeight=10;}
	$("#header").css("margin-bottom",1+myHeight+"px");
	$("#footer").css("margin-top",myHeight+"px");
}

function twitterCallback2(twitters){
	var statusHTML=[];
	for(var i=0;i<twitters.length;i++){
		var status=twitters[i].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g,function(url){
			return '<a href="'+url+'">'+url+'</a>';
		}).replace(/\B@([_a-z0-9]+)/ig,function(reply){
			return reply.charAt(0)+'<a href="http://twitter.com/'+reply.substring(1)+'">'+reply.substring(1)+'</a>';
		});
		statusHTML.push('<li><span>'+status+'</span></li>');
	}
	document.getElementById('twitter_update_list').innerHTML=statusHTML.join('');
}
