var mycarousel_itemList = [
    {url: 'img_gotouchi/bnr_1.png', title: '美瑛カレーうどん研究会',id: '1'},
    {url: 'img_gotouchi/bnr_2.png', title: '富良野オムカレー推進協議会',id: '2'},
    {url: 'img_gotouchi/bnr_3.png', title: '深川そばめし会',id: '3'},
    {url: 'img_gotouchi/bnr_4-2.png', title: 'オホーツク北見塩やきそば推進協議会',id: '4'},
    {url: 'img_gotouchi/bnr_5.png', title: '羽幌えびタコ餃子推進協議会',id: '5'},
    {url: 'img_gotouchi/bnr_6-2.png', title: '南富良野エゾカツカレー推進協議会',id: '6'},
    {url: 'img_gotouchi/bnr_7.png', title: '根室さんまロール寿司開発普及専門部会',id: '7'},
    {url: 'img_gotouchi/bnr_8.png', title: '十勝芽室コーン炒飯地域活性化協議会',id: '8'},
    {url: 'img_gotouchi/bnr_9.png', title: '別海ジャンボホタテバーガー地域活性化協議会',id: '9'},
    {url: 'img_gotouchi/bnr_10.png', title: '天塩タコキムチ丼推進協議会',id: '10'},
    {url: 'img_gotouchi/bnr_11.png', title: '松前マグロ三色丼推進協議会',id: '11'},
    {url: 'img_gotouchi/bnr_12.png', title: 'オホーツク干貝柱塩ラーメン地域活性化協議会',id: '12'},
    {url: 'img_gotouchi/bnr_13.png', title: '十勝おびひろ枝豆サラダ麺',id: '13'},
    {url: 'img_gotouchi/bnr_14.png', title: '那須の内弁当地域活性化協議会',id: '14'},
    {url: 'img_gotouchi/bnr_15.png', title: '阿寒やきとり丼地域活性化協議会',id: '15'},
    {url: 'img_gotouchi/bnr_16.png', title: '日南一本釣りカツオ料理推進協議会',id: '16'},
		
    {url: 'img_gotouchi/bnr_17.png', title: 'オホーツク網走ザンギ丼推進協議会',id: '17'},
    {url: 'img_gotouchi/bnr_18.png', title: '十勝清水牛玉ステーキ丼地域活性化協議会',id: '18'},
    {url: 'img_gotouchi/bnr_19.png', title: '豊富ホッキチャウダー推進協議会',id: '19'},
    {url: 'img_gotouchi/bnr_20.png', title: 'いずみ親子メニュー推進協議会',id: '20'},
    {url: 'img_gotouchi/bnr_21.png', title: '大潟村ご当地グルメ推進協議会',id: '21'},
    {url: 'img_gotouchi/bnr_22.png', title: '境港ベニズワイガニ料理推進協議会',id: '22'},
    {url: 'img_gotouchi/bnr_23.png', title: '竹原タケノコ料理推進協議会',id: '23'}
];

var img_linkList = [
    {//美瑛カレーうどん研究会
	img: 'img_gotouchi/image_1.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.649988,142.476196&amp;spn=0.544532,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//富良野オムカレー推進協議会
	img: 'img_gotouchi/image_2.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post_1.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.399061,142.382813&amp;spn=0.546802,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//深川そばめし会
	img: 'img_gotouchi/image_3.png',
	link: 'http://www.shingotochi.com/lineup/-_2/post_2.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.773077,142.036743&amp;spn=0.543415,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//オホーツク北見塩やきそば推進協議会
	img: 'img_gotouchi/image_4-2.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_3.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.864238,143.907166&amp;spn=0.542586,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//羽幌えびタコ餃子推進協議会
	img: 'img_gotouchi/image_5.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post_4.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=44.41024,141.70166&amp;spn=0.537592,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//南富良野エゾカツカレー推進協議会
	img: 'img_gotouchi/image_6-2.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post_5.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.213183,142.575073&amp;spn=0.548476,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//根室さんまロール寿司開発普及専門部会
	img: 'img_gotouchi/image_7.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_6.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.361132,145.585327&amp;spn=0.547144,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//十勝芽室コーン炒飯地域活性化協議会
	img: 'img_gotouchi/image_8.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_7.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=42.966472,143.039246&amp;spn=0.55069,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//別海ジャンボホタテバーガー地域活性化協議会
	img: 'img_gotouchi/image_9.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_8.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.440955,145.121155&amp;spn=0.546424,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//天塩タコキムチ丼推進協議会
	img: 'img_gotouchi/image_10.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post_9.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=44.935641,141.748352&amp;spn=0.53274,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//松前マグロ三色丼推進協議会
	img: 'img_gotouchi/image_11.png',
	link: 'http://www.shingotochi.com/lineup/-_3/post_10.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=41.485949,140.116882&amp;spn=0.563759,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//オホーツク干貝柱塩ラーメン地域活性化協議会
	img: 'img_gotouchi/image_12.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post_12.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=44.465151,142.948608&amp;spn=0.537087,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//十勝おびひろ枝豆サラダ麺
	img: 'img_gotouchi/image_13.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_11.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=42.974511,143.204041&amp;spn=0.550618,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//那須の内弁当地域活性化協議会
	img: 'img_gotouchi/image_14.png',
	link: 'http://www.shingotochi.com/lineup/cat6/post_13.html',
//	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=37.083667,140.127869&amp;spn=0.600361,0.799255&amp;z=9&amp;output=embed"></iframe>'
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,1&amp;hl=ja&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;ll=37.040928,140.013885&amp;spn=0.30035,0.399628&amp;z=10&amp;output=embed"></iframe>'
	},
    {//阿寒やきとり丼地域活性化協議会
	img: 'img_gotouchi/image_15.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_14.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=43.157109,144.126892&amp;spn=0.54898,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
    {//日南一本釣りカツオ料理推進協議会
	img: 'img_gotouchi/image_16.png',
	link: 'http://www.shingotochi.com/lineup/cat11/post_15.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?hl=ja&amp;ie=UTF8&amp;msa=0&amp;msid=111427621138161479132.000486db18bd16864b916&amp;brcurrent=3,0x5f727ab271bf385b:0xfa262b6017d58c5b,0&amp;ll=31.653381,131.393738&amp;spn=0.640609,0.799255&amp;z=9&amp;output=embed"></iframe>'
	},
	
    {//オホーツク網走ザンギ丼推進協議会
	img: 'img_gotouchi/image_17.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_16.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=44.02294,144.272804&amp;spn=0.067642,0.10334&amp;z=12&amp;output=embed"></iframe>'
	},
    {//十勝清水牛玉ステーキ丼地域活性化協議会
	img: 'img_gotouchi/image_18.png',
	link: 'http://www.shingotochi.com/lineup/-_1/post_17.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=43.014187,142.885437&amp;spn=0.068783,0.10334&amp;z=12&amp;output=embed"></iframe>'
	},
    {//豊富ホッキチャウダー推進協議会
	img: 'img_gotouchi/image_19.png',
	link: 'http://www.shingotochi.com/lineup/cat-1/post_18.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=45.1123,141.775818&amp;spn=0.265549,0.413361&amp;z=10&amp;output=embed"></iframe>'
	},
    {//いずみ親子メニュー推進協議会
	img: 'img_gotouchi/image_20.png',
	link: 'http://www.shingotochi.com/lineup/cat11/post_19.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=32.0977,130.348663&amp;spn=0.318764,0.413361&amp;z=10&amp;output=embed"></iframe>'
	},
    {//大潟村ご当地グルメ推進協議会
	img: 'img_gotouchi/image_21.png',
	link: 'http://www.shingotochi.com/lineup/cat5/post_20.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=40.044438,139.952087&amp;spn=0.576121,0.826721&amp;z=9&amp;output=embed"></iframe>'
	},
    {//境港ベニズワイガニ料理推進協議会
	img: 'img_gotouchi/image_22.png',
	link: 'http://www.shingotochi.com/lineup/cat9/post_21.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=35.572449,133.236694&amp;spn=0.612119,0.826721&amp;z=9&amp;output=embed"></iframe>'
	},
    {//竹原タケノコ料理推進協議会
	img: 'img_gotouchi/image_23.png',
	link: 'http://www.shingotochi.com/lineup/cat9/post_22.html',
	map: '<iframe width="292" height="274" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.co.jp/maps/ms?ie=UTF8&amp;hl=ja&amp;brcurrent=3,0x34674e0fd77f192f:0xf54275d47c665244,0&amp;msa=0&amp;msid=216377582399368585809.000486db18bd16864b916&amp;ll=34.370645,132.901611&amp;spn=0.621166,0.826721&amp;z=9&amp;output=embed"></iframe>'
	}
];



$(document).ready(function(){
	//*********************************
	//ヘッドライン
	//*********************************
	var cnt = 0;
	var fadeTime = 400;
	var changeTime = 8000;
	var target = $("#top-news dd");
	var len = target.length;
	
	//初めのヘッドライン表示
	target.eq(cnt).fadeIn(fadeTime);
	
	//それ以降のヘッドライン表示
	target.eq(cnt).everyTime(changeTime, function(i) {
		target.eq(cnt).fadeOut(fadeTime,function(){
			cnt++;
			if(cnt > (len - 1)){
				cnt = 0;
			}
			target.eq(cnt).fadeIn(fadeTime);
		});
	});
	
	//*********************************
	//看板スライド＆画像と地図変換
	//*********************************
	//開始位置をランダムにする
	var startIndex = Math.floor(Math.random()*mycarousel_itemList.length);
	startIndex2 = startIndex;
	if(startIndex2 == 14){
		startIndex2 = -2;
	}
	if(startIndex2 == 15){
		startIndex2 = -1;
	}
	//初期表示
	$("#main-image-list img").attr("src",img_linkList[startIndex2 + 2].img);
	$(".btn-center a").attr("href",img_linkList[startIndex2 + 2].link);
	$("#main-image-right").html(img_linkList[startIndex2 + 2].map);
	//スライダー設置
	$("#menu-slide-list").jcarousel({
		start: (startIndex + 1),
		scroll: 1,
//		auto: 8,
		wrap: 'circular',
		animation: 500,
		initCallback: mycarousel_initCallback,
		
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},

		buttonNextHTML: null,
		buttonPrevHTML: null
	});
	
});

function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
	var idx = carousel.index(i, mycarousel_itemList.length);
	carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
	
	//デバッグ用
//	$("h1").next("p").text(carousel.first + "<<<>>>" + carousel.last);
};

function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
	carousel.remove(i);
		
//	$("#main-image-list img").attr("src",img_linkList[parseInt($('#menu-slide-list a').eq(2).find("img").attr("id")) - 1].img);
//	$(".btn-center a").attr("href",img_linkList[parseInt($('#menu-slide-list a').eq(2).find("img").attr("id")) - 1].link);
//	$("#main-image-right").html(img_linkList[parseInt($('#menu-slide-list a').eq(2).find("img").attr("id")) - 1].map);
};

function mycarousel_getItemHTML(item)
{
    return '<li><a href="#"><img src="' + item.url + '" alt="' + item.title + '" width="190" height="80" id="' + item.id + '" /></a></li>';
};

function mycarousel_initCallback(carousel) {
	$('.btn-right a').bind('click', function() {
//		carousel.stopAuto();
		carousel.next();
		return false;
	});
	$('.btn-left a').bind('click', function() {
//		carousel.stopAuto();
		carousel.prev();
		return false;
	});

	carousel.clip.hover(
		function() {
//			carousel.stopAuto();
		},
		function() {
//			carousel.startAuto();
		}
	);
	
	$("#main-image").hover(
		function () {
//			carousel.stopAuto();
		},
		function () {
//			carousel.startAuto();
		}
	);
	
//	$('#menu-slide-list a').live('click', function() {
////		carousel.stopAuto();
//		var move = $('#menu-slide-list a').index(this);
//		if(move > 2){
//			carousel.options.scroll = move - 2;
//			carousel.next();
//			carousel.options.scroll = 1;
//		}
//		if(move < 2){
//			if(move < 1){
//				carousel.options.scroll = 2;
//			}
//			carousel.prev();	
//			carousel.options.scroll = 1;
//		}
//		return false;
//	});
	$('#menu-slide-list a').live('click', function() {
		$("#main-image-list img").attr("src",img_linkList[parseInt($(this).find("img").attr("id")) - 1].img);
		$(".btn-center a").attr("href",img_linkList[parseInt($(this).find("img").attr("id")) - 1].link);
		$("#main-image-right").html(img_linkList[parseInt($(this).find("img").attr("id")) - 1].map);
		return false;
	});
	
	
};

