/**
 * @author takenaka
 */

var autoRefreshInterval = 60;
var autoRefreshCount = 21;
var stopFlag = false;

/**
 * New Method
 */
function dispTweetFunction(){
	$('#jTweetsAnywhereSample_timeLine').jTweetsAnywhere({
		username: 'handaiClub',
		list: 'club',
	    count: 20,
	    showTweetFeed: {
	        showTimestamp: {
	            refreshInterval: 15
	        },
	        autorefresh: {
	            mode: 'trigger-insert',
	            interval: autoRefreshInterval
	        },
	        paging: { mode: 'more' }
	    },
	    onDataRequestHandler: function(stats, options) {
	        if (stats.dataRequestCount < autoRefreshCount) {
	            return true;
	        }
	        else {
	            stopAutorefresh(options);
	            result = dispStopMessage(options);
	            if(result){
	            	return true;
	            }
	        }
	    }
	});
	/*
	$('#jTweetsAnywhereSample_tweetBox').jTweetsAnywhere({
	    showTweetBox:{
	        counter: true,
	        width: 400,
	        height: 65,
	        label: 'あなたは今どんな活動をしていますか？',
	        defaultContent: '#Handai ',
	        onTweet: function(textTweet, htmlTweet){
	            alert('You tweeted: ' + textTweet);
	        }
	    }
	});
	*/
}

function dispStopMessage(options){
	if(stopFlag == false){
		stopMassageTextDiv = $("<div/>").text(autoRefreshInterval*(autoRefreshCount-1)
			+"秒を越えたため自動更新を一時停止しました。ここをクリックすると再開します。");
		stopMassageTextDiv.click(function(){
			$("#stopMassage").hide();
			$("#stopMassage").empty();
			options._tweetFeedConfig.autorefresh.duration = -1;
			options._stats.dataRequestCount = 0;
			startAutorefresh(options);
			stopFlag = false;
		});
		$("#stopMassage").append(stopMassageTextDiv);
		$("#stopMassage").show();
		stopFlag = true;
		return false;
	}else{//Moreボタンが押された場合
		$("#stopMassage").hide();
		$("#stopMassage").empty();
		options._tweetFeedConfig.autorefresh.duration = -1;
		options._stats.dataRequestCount = 0;
		startAutorefresh(options);
		stopFlag = false;
		return true;
	}

}










