﻿$(function() {
	$("#loading").bind("ajaxSend", function() {
		$(this).show();
	}).bind("ajaxComplete", function() {
		$(this).fadeOut("fast", function() {
			$("div#shopList").slideDown();
		});
	});
	if($.cookie('mapCookie')) {
		if($.cookie('mapCookie').match("off")) {
			$("div#map>img").hide();
			$("div#map>span#mapToggle").html("表示");
		} else {
			$("div#map>img").show();
			$("div#map>span#mapToggle").html("隠す");
		}
	}
	$("div#map>span#mapToggle").click(function() {
		if($(this).html().match("表示")) {
			$(this).next("img").slideDown("fast");
			$.cookie('mapCookie', 'on', {expires: 7});
			$(this).html("隠す");
		} else {
			$(this).next("img").slideUp("fast");
			$.cookie('mapCookie', 'off', {expires: 7});
			$(this).html("表示");
		}
	});
	
	loadList(window.document.title);
	onMouse();
});

function onMouse() {$("div#shopList>dl>dt").hover(function() {
		$(this).css('color', '#66f');
	}, function() {
		$(this).css('color', '#333');
	});
}

function hideInfo() {
	$("div#shopList>dl>dd").hide();
}

function showInfo() {
	var tag = $(this);
	var info = $(this).next("dd").html();	
	$("div#shopInfo").html(info);
	$("div#shopList>dl>dt").removeClass("current");
	$(this).addClass("current");
}

function loadList(listFile) {
	$("div#shopList").load(listFile+".html", function() {
		$("div#shopList>dl>dt").click(showInfo);
		onMouse();
		hideInfo();
		var val = location.search.split('=');
		if(val[1]) {
			var a = "#"+val[1];	//get shopdetail
			var b = a+"Title";	//get shoptitle
			var info = $(a).html();	
			$("div#shopInfo").html(info);
			$("div#shopList>dl>dt").removeClass("current");
			$(b).addClass("current");
		}	
	});
};
