var tw_id;
var tw_idx;
var msg_error_alter='<div class="fs12 pd10 lh_1_7">船宿検索・船宿情報・乗船予約なら沖釣り・海釣り・船釣り・釣り船情報サイト-爆釣-で決まり! !初心者・女性・ファミリーで気軽に楽しめる釣りをご紹介いたします！</div>';

function search_text(text) {
	$('#stext').val(text);
	document.forms('frm_search').submit();
}

function get_tw_sp() {

	$.ajax({
		url : 'class/f_tw_shopmsg',
		type : 'get',
		dataType : 'html',
		async: true,
		success : function(result) {
			$('#top_shopmsg_plc').html(result);
		},
		error : function(result, msg) {
			$('#top_shopmsg_plc').html(msg_error_alter);
		}
	});

}


function get_tw(idx) {

	$.ajax({
		url : 'class/f_tw',
		type : 'post',
		data : 'type=usertimeline&idx=' + idx,
		dataType : 'json',
		async: true,
		success : function(result) {
			$('#top_tw_text').html(result[0]['text'][0]);
			$('#top_tw_dt').html(result[0]['datetime']);
			if(tw_id != result[0]['status_id'][0]) {
				tw_id = result[0]['status_id'][0];
				tw_idx = idx;
			}
		},
		error : function(result,msg) {
			$('#top_tw_text').html(msg_error_alter);
		}
	});

}

function tw_next() {
	get_tw(tw_idx + 1);
}

function tw_prev() {
	var idx = tw_idx - 1;
	if(idx < 1) {
		return;
	}
	get_tw(idx);
}
$(function() {
	$('#top_shopmsg_plc').everyTime(60000, function() {
		get_tw_sp();
	});
});

$(document).ready(function(){
	get_tw_sp();
	get_tw(1);
});
