// ロケーション(都道府県)毎の画像とエリアコードの設定
var LOC = new Array();
// LOC.push({name: '日本',       area_id: 0,     zoom:3,  center:'38.200000,138.700000'});
LOC.push({name: '北海道',     area_id: 11,    zoom:5,  center:'43.516680,142.602539'});
LOC.push({name: '青森県',     area_id: 12,    zoom:6,  center:'40.824527,140.739992'});
LOC.push({name: '岩手県',     area_id: 13,    zoom:6,  center:'39.483777,141.130714'});
LOC.push({name: '宮城県',     area_id: 14,    zoom:6,  center:'38.269050,140.872107'});
LOC.push({name: '秋田県',     area_id: 15,    zoom:6,  center:'39.718824,140.102355'});
LOC.push({name: '山形県',     area_id: 16,    zoom:7,  center:'38.240658,140.363624'});
LOC.push({name: '福島県',     area_id: 17,    zoom:6,  center:'37.332392,140.291762'});
LOC.push({name: '東京都',     area_id: 18,    zoom:7,  center:'35.689718,139.691699'});
LOC.push({name: '神奈川県',   area_id: 19,    zoom:7,  center:'35.447736,139.642346'});
LOC.push({name: '埼玉県',     area_id: 20,    zoom:7,  center:'36.000000,139.048848'});
LOC.push({name: '千葉県',     area_id: 21,    zoom:7,  center:'35.605289,140.123298'});
LOC.push({name: '栃木県',     area_id: 22,    zoom:7,  center:'36.563065,139.883423'});
LOC.push({name: '群馬県',     area_id: 23,    zoom:7,  center:'36.390888,139.060414'});
LOC.push({name: '茨城県',     area_id: 24,    zoom:7,  center:'36.342041,140.446794'});
LOC.push({name: '山梨県',     area_id: 25,    zoom:7,  center:'35.664392,138.568454'});
LOC.push({name: '新潟県',     area_id: 26,    zoom:6,  center:'37.485500,138.298001'});
LOC.push({name: '長野県',     area_id: 27,    zoom:7,  center:'36.651516,138.180950'});
LOC.push({name: '富山県',     area_id: 28,    zoom:7,  center:'36.695522,137.211342'});
LOC.push({name: '石川県',     area_id: 29,    zoom:7,  center:'36.594909,136.625569'});
LOC.push({name: '福井県',     area_id: 30,    zoom:7,  center:'36.065405,136.221521'});
LOC.push({name: '静岡県',     area_id: 31,    zoom:7,  center:'34.977355,138.383081'});
LOC.push({name: '愛知県',     area_id: 32,    zoom:7,  center:'35.180421,136.906557'});
LOC.push({name: '岐阜県',     area_id: 33,    zoom:7,  center:'35.391446,136.722300'});
LOC.push({name: '三重県',     area_id: 34,    zoom:7,  center:'34.730521,136.508582'});
LOC.push({name: '滋賀県',     area_id: 35,    zoom:7,  center:'35.113168,135.940704'});
LOC.push({name: '京都府',     area_id: 36,    zoom:7,  center:'35.021474,135.755589'});
LOC.push({name: '和歌山県',   area_id: 37,    zoom:7,  center:'34.226742,135.167327'});
LOC.push({name: '奈良県',     area_id: 38,    zoom:7,  center:'34.685558,135.832751'});
LOC.push({name: '大阪府',     area_id: 39,    zoom:7,  center:'34.686528,135.519662'});
LOC.push({name: '兵庫県',     area_id: 40,    zoom:7,  center:'34.691504,135.183077'});
LOC.push({name: '鳥取県',     area_id: 41,    zoom:6,  center:'35.504125,134.237738'});
LOC.push({name: '島根県',     area_id: 42,    zoom:6,  center:'35.023916,132.083709'});
LOC.push({name: '岡山県',     area_id: 43,    zoom:7,  center:'34.661981,133.934412'});
LOC.push({name: '広島県',     area_id: 44,    zoom:7,  center:'34.396783,132.459626'});
LOC.push({name: '山口県',     area_id: 45,    zoom:6,  center:'34.186193,131.470642'});
LOC.push({name: '香川県',     area_id: 46,    zoom:7,  center:'34.340371,134.043438'});
LOC.push({name: '徳島県',     area_id: 47,    zoom:7,  center:'34.065956,134.559367'});
LOC.push({name: '愛媛県',     area_id: 48,    zoom:7,  center:'33.841851,132.765677'});
LOC.push({name: '高知県',     area_id: 49,    zoom:7,  center:'33.559939,133.531072'});
LOC.push({name: '福岡県',     area_id: 50,    zoom:7,  center:'33.606810,130.418293'});
LOC.push({name: '佐賀県',     area_id: 51,    zoom:7,  center:'33.249670,130.299804'});
LOC.push({name: '長崎県',     area_id: 52,    zoom:7,  center:'32.925600,129.873762'});
LOC.push({name: '大分県',     area_id: 53,    zoom:7,  center:'33.238400,131.612628'});
LOC.push({name: '熊本県',     area_id: 54,    zoom:7,  center:'32.790053,130.741661'});
LOC.push({name: '宮崎県',     area_id: 55,    zoom:6,  center:'32.091803,131.379940'});
LOC.push({name: '鹿児島県',   area_id: 56,    zoom:6,  center:'31.560400,130.557983'});
LOC.push({name: '沖縄県',     area_id: 57,    zoom:6,  center:'26.212647,127.680938'});


// 遷移先のURL
var SHOP_SEARCH_URL = '/shop/';

// 表示画像の格納ディレクトリ
var LOC_IMAGE_DIR = '/resources_shared/images/client_location/';

// アンマッチ時のロケーション
var DEFAULT_LOC = '東京都';

// 強制的に都道府県を指定する場合
var REGION = '';

// クライアント側のロケーション情報の確定
function getLocation(){
	if(REGION !== ''){
		var region = REGION;
	}else{
		var region = google.loader.ClientLocation.address.region;
	}
	
	for (var i = 0; i < LOC.length; i++) {
		if(LOC[i].name == region){
			return LOC[i];
		}
	}
	for (var i = 0; i < LOC.length; i++) {
		if(LOC[i].name == DEFAULT_LOC){
			return LOC[i];
		}
	}
}

// 指定されたエレメントにロケーション情報を描画
function renderLocation(elmID, linkID){
	jQuery(document).ready( function() {
		var loc = getLocation();
		var link_href = SHOP_SEARCH_URL;
		if(loc.area_id > 0){
			link_href += '?area_id=' + loc.area_id;
		}
		if(elmID){
			var elm = jQuery('#' + elmID);
			if(elm) {
				var html = '<a href="'+ link_href +'"><img src="'+ getStaticMapURL(loc.zoom, loc.center) +'" border="0" /></a>';
				elm.html(html);
			}
		}
		
		if(linkID){
			jQuery('#' + linkID).attr({href: link_href});
		}
	});
}
//GoogleStaticMapのURL＋パラメータの生成
function getStaticMapURL(zoom, center){
	var url = '	http://maps.google.com/staticmap?';
	url += 'size=180x90';
	url += '&key=' + MAPKEY;
	url += '&zoom=' + zoom;
	url += '&center=' + center;
	url += '&format=png32';
	return url;
}


// ランディングページ用のiframe出力
function renderLP(){
	var loc = getLocation();
	var html = '<iframe src="/shop/index_lp.html?area_id='+loc.area_id+'" name="lp_frame" width="1050" height="2000" scrolling="no" frameborder="0" marginheight="0"></iframe>';
	document.write(html);
}




