//ヘッドライン用初期化
var twt=new Array();// 表示する文字列の配列
twt[0]="Twitterからデータを取得できませんでした。限界のようです。";
var blg=new Array();// 表示する文字列の配列
blg[0]="Newsが取得できませんでした。調子が悪いようです。";

var i=0;
function headline(){
	if(i<twt.length){
		$("tweets").set('html', twt[i]);
		i++;
	}else{
		i=0;
	}
	setTimeout("headline()",2500);
}
var j=0;
function headline_b(){
	if(j<blg.length){
		$("news").set('html', blg[j]);
		j++;
	}else{
		j=0;
	}
	setTimeout("headline_b()",2500);
}

window.addEvent('domready', function() { 
	init();

	var jsonRequest1 = new Request.JSON({
		url: "/tweet_json.php",
		method: "post",
		onSuccess: function(response){
			if(response){
				$each(response.tweets,function(value,key){
					twt[key]="<a href=\""+value.link+"\" target=\"_blank\">" + value.date + " " + value.name +"<br>" + value.desc +"<\/a>";
				});
			}
			headline();
		}});
	jsonRequest1.send();

	var jsonRequest2 = new Request.JSON({
		url: "/blog_json.php",
		method: "post",
		onSuccess: function(response){
			if(response){
				$each(response.news,function(value,key){
					blg[key]="<a href=\""+value.link+"\">" + value.date + " updated<br>" + value.desc +"<\/a>";
				});
			}
			headline_b();
		}})
	jsonRequest2.send();
});


