/**
 * FileName:map.js
 * @author uniteair.co.jp
 */

var ZENKOKU;

/**
 * @constructor
 * @description クラスの宣言
 */
var Map = function(){
}


Map.prototype = {
/**
 * @class initialize
 */
 	initialize:function(){
		//$("map[name=MAP1]").remove();
		$("body").append(MAP_DATA_COORD);
		map.click();
	},
	
/**
 * @class click
 * @description クリックイベント取得
 */
	click:function(){
		$("area").live("click", function(){
			var id = $(this).attr("id");
			var cls = $(this).attr("class");
			
			if(!(id)) id = "ZENKOKU";

			if(cls == "js-back"){
				map.back();
				return false;
			}else{
				var name = $(this).parent().attr("name");
				if(id != "HOKKAIDO" && name == "MAP1"){
					map.display(id);
					return false;
				}
			}
		});
	},
	
/**
 * @class display
 * @description 地図表示処理
 */
	display:function(id){
		var html;

		$(MAP_DATA).each(function(i){
			if(MAP_DATA[i].name == id){
				html = MAP_DATA[i].data;
			}
		});
		
		this.animate(html);
	},
	
/**
 * @class back
 * @description 全国地図に戻る処理
 */
	back:function(){
		this.display("ZENKOKU");
		return false;
	},
	
/**
 * @class animate
 * @description 地図表示時のアニメーション処理
 */
	animate:function(html){
		$(".js-map").css("opacity", "0");
		$(".js-map").html(html);
		$(".js-map").animate({opacity:'1'},800);
	}
}

var map = new Map();

$(document).ready(function(){
	//map.initialize();
	  if ($("*[name=Map9]").length == 0) {
  		map.initialize();
  	}
});
map.initialize();

