$(document).ready(function(){

	//ボックスリンク
	$(".bl").css("cursor","pointer");
	$(".bl").hover(
			function () { $(this).addClass("alphabox");	},
			function () { $(this).removeClass("alphabox");	}
	);
	$(".bl").click(function(e){
		$(this).removeClass("alphabox");
		var shiftKey = e.shiftKey;
		var url = $(this).find("a").attr("href");
		var tgt = $(this).find("a").attr("target");
		if(tgt == "_blank" || shiftKey){
			window.open(url);
		}else{
			window.location=url;
		}
		return false;
	});
	
	//非同期タブ
	$("#tab02,#tab03,#tab04").hide();
	$(".asynctab a").click(function(){
		$(".active").removeClass("active");
		$(".section").hide();
		var tgt = $(this).attr('href');
		$(this).parent("li").addClass("active");
		$(tgt).css("display","block");
		return false;
	});

	/*アクセスマップ*/
	$("#gmap,#gmaplink").hide();
	$("#mapswitch a").toggle(
	function () {
		$("#map").hide();
		$("#gmap").show(); 
		$("#gmaplink").show();
		var type = $(this).attr("title");
		switch(type){
			case "walk": //徒歩
			 $("#gmap").googlemap(37.397274,140.385500,17,37.397274,140.383904,"/common/img/gmap_icon.png");
			break;
			case "car": //車
			 $("#gmap").googlemap(37.397274,140.383904,16,37.397274,140.383904,"/common/img/gmap_icon.png");
			break;
			case "eap_walk": //EAP徒歩
			 $("#gmap").googlemap(37.397274,140.385500,17,37.397274,140.383904,"/common/img/eap_gmap_icon.png");
			break;
			case "eap_car": //EAP車
			 $("#gmap").googlemap(37.397274,140.383904,16,37.397274,140.383904,"/common/img/eap_gmap_icon.png");
			break;
		}
		$(this).text('Mapをもどす');
		return false;
	},
	function () {
		$("#gmap,#gmaplink").hide();
		$("#map").show();
		$(this).text('GoogleMapで見る');
		return false;
	}
	);
	//ポップアップ
	$(".maparea area").hover(function(){
		var tgt = $(this).attr('href');
		$(".mappoint li").hide();
		$(tgt).fadeIn("fast");
	},function(){
		$(".mappoint li").hide();
	});
	//リンクキャンセル
	$(".maparea area").click(function(){ return false; });

	//高さ調整 実行の順番に注意
	$(".inner").each(function(){
		var h = $(this).height();
		var d = h%4;
		if( d != 0 ){
			var fix = 4 - d;
			$(this).height( h + fix );
		}
	});

});

/*グーグルマップ表示*/
$.fn.googlemap = function(lat,lng,set,mlat,mlng,micon) {
	var target = $(this).get(0);
	var myOptions = {
			zoom: set,
			center: new google.maps.LatLng(lat,lng),
			mapTypeId: google.maps.MapTypeId.ROADMAP,
			mapTypeControl: false,
			scaleControl: true,
			scrollwheel : false
	};
	var map = new google.maps.Map(target,myOptions);
	
	new google.maps.Marker({
	map: map,
	position: new google.maps.LatLng(mlat,mlng),
	icon:micon
	});
		return false;
};

