google.load('jquery','1');
google.load("maps","3.x", {"other_params":"sensor=false"});

google.setOnLoadCallback(function(){

// スライドショー
	setInterval( "slideSwitch()", 4500 );
	setInterval( "slideSwitch2()", 5000 );


// ポップアップメッセージ
	$('.reserve_1 p').hover(function(){
	  $(this).next().fadeIn('fast');
	},function(){
		$(this).next().fadeOut('fast');
	});


// 新規ユーザーへのメッセージ表示用クッキー
  if( !$.cookie('first_user') ){
    $('.attention').show();
  }


// テーブルしましま
  $('.timetable tr:nth-child(odd)').css('background-color','#f6f6f6');
  $('.pricetable tr:nth-child(odd)').css('background-color','#f6f6f6');
	

// テーブルのハイライト


// 徳島の集合場所の地図
  var point_tokushima = {
    'anan':{'name':'阿南（津乃峰営業所）', 'address':'<iframe src="http://kousokubus.jp/ride_tunomine.html"></iframe>', 'center':　new google.maps.LatLng(33.886971627535125, 134.6514994812145)},
    'nakagawa':{'name':'那賀川(北中島ローソン駐車場)', 'address':'<iframe src="http://kousokubus.jp/ride_nakagawa.html"></iframe>', 'center':　new google.maps.LatLng(33.94576270805392, 134.6724099826946)},
    'tokushima':{'name':'徳島(海部観光駅前営業所)', 'address':'<iframe src="http://kousokubus.jp/ride_tokusima.html"></iframe>', 'center':　new google.maps.LatLng(34.07250830966765, 134.55219404519937)},
    'matsushige':{'name':'松茂(専用駐車場)', 'address':'<iframe src="http://kousokubus.jp/ride_matusige.html"></iframe>', 'center': new google.maps.LatLng(34.14246458463894, 134.58182641984365)}
  };

  var options = {
    zoom: 11,
    center: point_tokushima['tokushima']['center'],
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
	
try {
  var map_tokushima = new google.maps.Map($("#map_tokushima")[0], options);
}catch(e){}

  $.each(point_tokushima,function(key,value){
    var marker_tokushima = new google.maps.Marker({
      position: value['center'],
      map: map_tokushima,
      icon: "http://code.prostaff1.com/sample/10_google-map/images/marker_bus_40.png",
      title: value['name']
    });
    var infowindow = new google.maps.InfoWindow({
      content: "<strong>" + value['name'] + "</strong><p>" + value['address'] + "</p>"
    });
    google.maps.event.addListener(marker_tokushima , 'click' , function(){
      infowindow.open(map_tokushima , marker_tokushima);
    });
  });
  
  $("#tokushima a").click(function(){
    if(!$(this).hasClass("selected")){
      $("a.selected").removeClass("selected");
      $(this).addClass("selected");
      map_tokushima.setCenter(point_tokushima[$(this).attr("id")].center);
    }
    return false;
  });
  
	
// 関西⇔徳島の集合場所の地図
  var point_kannsai = {
    'nannba':{'name':'【難波】「ビックカメラ千日前店様」前', 'address':'<iframe src="http://kousokubus.jp/ride_nanba.html"></iframe>', 'center':　new google.maps.LatLng(34.66692938140013, 135.50263011576078)},
    'umeda':{'name':'【梅田】四ツ橋筋LEI\'Sビル前', 'address':'<iframe src="http://kousokubus.jp/ride_0701umeda.html"></iframe>', 'center':　new google.maps.LatLng(34.699153401211056, 135.4954847109451)},
    'koube':{'name':'【神戸】国道２号線沿い「勤労会館」前', 'address':'<iframe src="http://kousokubus.jp/ride_kobe.html"></iframe>', 'center':　new google.maps.LatLng(34.694692192273166, 135.19749128939054)}
  };

  var options_kannsai = {
    zoom: 13,
    center: point_kannsai['umeda']['center'],
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
	
try {
  var map_kannsai = new google.maps.Map($("#map_kannsai")[0], options_kannsai);
}catch(e){}
 
  $.each(point_kannsai,function(key,value){
    var marker_kannsai = new google.maps.Marker({
      position: value['center'],
      map: map_kannsai,
      icon: "http://code.prostaff1.com/sample/10_google-map/images/marker_bus_40.png",
      title: value['name']
    });
    var infowindow = new google.maps.InfoWindow({
      content: "<strong>" + value['name'] + "</strong><p>" + value['address'] + "</p>"
    });
    google.maps.event.addListener(marker_kannsai , 'click' , function(){
      infowindow.open(map_kannsai , marker_kannsai);
    });
  });

  $("#kannsai a").click(function(){
    if(!$(this).hasClass("selected")){
      $("a.selected").removeClass("selected");
      $(this).addClass("selected");
      map_kannsai.setCenter(point_kannsai[$(this).attr("id")].center);
    }
    return false;
  });

// 関西⇔東京の集合場所の地図
  var point_kannsai2 = {
    'hal':{'name':'【梅田】大阪駅西側大阪モード学園前', 'address':'<iframe src="http://kousokubus.jp/ride_umeda_mode.html"></iframe>', 'center':　new google.maps.LatLng(34.69939597117431, 135.49322897316358)}
  };

  var options_kannsai2 = {
    zoom: 15,
    center: point_kannsai2['hal']['center'],
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };
	
try {
  var map_kannsai2 = new google.maps.Map($("#map_kannsai2")[0], options_kannsai2);
}catch(e){}
 
  $.each(point_kannsai2,function(key,value){
    var marker_kannsai2 = new google.maps.Marker({
      position: value['center'],
      map: map_kannsai2,
      icon: "http://code.prostaff1.com/sample/10_google-map/images/marker_bus_40.png",
      title: value['name']
    });
    var infowindow = new google.maps.InfoWindow({
      content: "<strong>" + value['name'] + "</strong><p>" + value['address'] + "</p>"
    });
    google.maps.event.addListener(marker_kannsai2 , 'click' , function(){
      infowindow.open(map_kannsai2 , marker_kannsai2);
    });
  });

  $("#kannsai2 a").click(function(){
    if(!$(this).hasClass("selected")){
      $("a.selected").removeClass("selected");
      $(this).addClass("selected");
      map_kannsai2.setCenter(point_kannsai2[$(this).attr("id")].center);
    }
    return false;
  });


// 東京の集合場所の地図
  var point_tokyo = {
    'yaesu':{'name':'東京駅八重洲口ヤンマーディーゼルビル前', 'address':'<iframe src="http://kousokubus.jp/ride_tokyo.html"></iframe>', 'center':　new google.maps.LatLng(35.67997856233541, 139.76955258966825)},
    'shinjuku':{'name':'新宿駅西口スバルビル前', 'address':'<iframe src="http://kousokubus.jp/ride_sinjyuku.html"></iframe>', 'center':　new google.maps.LatLng(35.691282618553714, 139.697647930397)}
  };

  var options_tokyo = {
    zoom: 12,
    center: point_tokyo['yaesu']['center'],
    mapTypeId: google.maps.MapTypeId.ROADMAP
  };

try {
  var map_tokyo = new google.maps.Map($("#map_tokyo")[0], options_tokyo);
}catch(e){}

  $.each(point_tokyo,function(key,value){
    var marker_tokyo = new google.maps.Marker({
      position: value['center'],
      map: map_tokyo,
      icon: "http://code.prostaff1.com/sample/10_google-map/images/marker_bus_40.png",
      title: value['name']
    });
    var infowindow = new google.maps.InfoWindow({
      content: "<strong>" + value['name'] + "</strong><p>" + value['address'] + "</p>"
    });
    google.maps.event.addListener(marker_tokyo , 'click' , function(){
      infowindow.open(map_tokyo , marker_tokyo);
    });
  });

  $("#tokyo a").click(function(){
    if(!$(this).hasClass("selected")){
      $("a.selected").removeClass("selected");
      $(this).addClass("selected");
      map_tokyo.setCenter(point_tokyo[$(this).attr("id")].center);
    }
    return false;
  });

// タブの指定
/*
  $('.tab li:first a').addClass('selected');
  $('.panel > li:not(:first)').hide();
  $('.tab a').click(function(){
    if(!$(this).hasClass('selected')){
      $('.tab a.selected').removeClass('selected');
      $(this).addClass('selected');
      $('.panel > li').hide().filter($(this).attr('href')).show();
    }
    google.maps.event.trigger(map_tokushima, 'resize');
    google.maps.event.trigger(map_tokyo, 'resize');
    google.maps.event.trigger(map_kannsai, 'resize');
    return false;
  });
*/
	
});//setOnLoadCallback


// スライドショー
/*function slideSwitch() {
	var $active = $('#slideshow img.active');
	if ( $active.length == 0 ) $active = $('#slideshow img:last');
	var $next =  $active.next().length ? $active.next() : $('#slideshow img:first');
	$active.addClass('last-active');
	$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
}*/
function slideSwitch() {
	var selector = ['#slideshow', '#slideshow3'];
	$.each(selector, function(i, v){
		var $active = $(v).find('img.active');
		if ( $active.length == 0 ) $active = $(v).find('img:last');
		var $next =  $active.next().length ? $active.next() : $(v).find('img:first');
		$active.addClass('last-active');
		$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
	});
}

function slideSwitch2() {
	var selector = ['#slideshow2', '#slideshow4'];
	$.each(selector, function(i, v){
		var $active = $(v).find('img.active');
		if ( $active.length == 0 ) $active = $(v).find('img:last');
		var $next =  $active.next().length ? $active.next() : $(v).find('img:first');
		$active.addClass('last-active');
		$next.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0}, 1000, function() {
			$active.removeClass('active last-active');
		});
	});
}
