var __CTN_SHOPS = new Array(
	new Array('ガレージエム', '大阪府東大阪市菱江３丁目16-18', '072-960-5555', 135.615894, 34.678847, 'garage_em.html'),
	new Array('パラゴン株式会社', '大阪府堺市堺区向陵東町1-5-3', '072-240-4000', 135.497332, 34.565813, 'paragon.html'),
	new Array('マイカーギャラリー', '大阪府松原市立部3-455', '072-337-9100', 135.565267, 34.56692, 'mycargallery.html'),
	new Array('有限会社オートパドック', '大阪府門真市南野口町4-6', '072-884-7665', 135.607058, 34.736865, 'autopadock.html'),
	new Array('TAX 堺I.C　有限会社メイト', '大阪府堺市中区平井736-1', '072-276-7733', 135.489523, 34.517824, 'mate.html'),
	new Array('カーライフ関西　伊丹支店', '兵庫県伊丹市瑞穂町1-11', '072-772-5575', 135.405406, 34.789458, 'carlife_itami.html'),
	new Array('くるま工房Touch', '大阪府岸和田市下池田2-9-22', '0724-44-3988', 135.40307, 34.47012, 'touch.html'),
	new Array('ハナテン高知　株式会社イーダッシュ', '高知県高知市南久保6-1', '088-884-8710', 133.56655, 33.565115, 'e-dash.html'),
	new Array('D.A Factory', '大阪府泉北郡忠岡町忠岡北3-10-28', '0725-20-6780', 135.386842, 34.498891, 'd_a_factory.html'),
	new Array('インサイドベイビー', '大阪市平野区長吉川辺3-8-47', '06-6705-1300', 135.575225, 34.597255, 'inside.html'),
	new Array('株式会社クロスロード', '大阪府枚方市北中振3-11-15', '072-834-3300', 135.630544, 34.800586, 'crossroad.html'),
	new Array('有限会社ケイツーオート', '愛媛県西条市喜多川640-4', '0897-58-2101', 133.170159, 33.92326, 'k2auto.html'),
	new Array('有限会社ゴーイング', '高知県高知市大津乙1059-1', '088-878-3788', 133.599416, 33.574401, 'going.html'),
	new Array('D-WORLD International', '福岡県大川市中木室826-4', '', 130.415668, 33.210109),
	new Array('カーライフ関西', '大阪府摂津市鳥飼町本町5-16-30', '072-653-2223', 135.577979, 34.773391),
	new Array('有限会社インサイド奈良店', '奈良県北葛城郡王寺町本町2-34-35', '0745-73-6969', 135.706018, 34.58494, 'inside.html'),
	new Array('インサイドファクトリー', '大阪市平野区長吉川辺3-8-49', '06-6705-5511', 135.575165, 34.597456, 'inside.html'),
	new Array('ハナテン高知　高知インター店', '高知県高知市杉井流31-8', '088-861-8710', 133.555359, 33.569134, 'e-dash.html'),
	new Array('TAX狭山　有限会社メイト', '大阪府大阪狭山市池之原2-1024-1', '072-368-0011', 135.54553, 34.504168, 'mate.html'),
	new Array('浜田オート', '兵庫県尼崎市崇徳院2-144', '06-6418-5474', 135.397443, 34.723523, 'hamadaauto.html')
);


function gmap_load(id, lat, lng, scale, shopkey, showall) {
	if (! GBrowserIsCompatible()) return;
	
	var map    = new GMap2(document.getElementById(id));
	
	map.setCenter(new GLatLng(lat, lng), scale);
	map.addControl(new GLargeMapControl());
	map.addControl(new GScaleControl());
	map.addControl(new GMapTypeControl());
	
	
	var icon = new GIcon();
	icon.image            = "http://www.ctn-net.com/profile/image/gmap_marker.png";
	icon.iconSize         = new GSize(18, 43);
	icon.iconAnchor       = new GPoint(0, 43);
	icon.infoWindowAnchor = new GPoint(20, 12);
	
	var marker = new Array();
	
	for (i=0; i<__CTN_SHOPS.length; i++) {
		if (__CTN_SHOPS[i]) {
			if (showall) {
				marker[i] = new GMarker(new GPoint(__CTN_SHOPS[i][3], __CTN_SHOPS[i][4]), icon);
				map.addOverlay(marker[i]);
			}
			else {
				if (i == shopkey) {
					marker[0] = new GMarker(new GPoint(__CTN_SHOPS[i][3], __CTN_SHOPS[i][4]), icon);
					map.addOverlay(marker[0]);
					
					var note = get_shopnote(i, true);
					
					marker[0].openInfoWindowHtml(note);
					GEvent.addListener(marker[0], "click", function() { this.openInfoWindowHtml(note); });
				}
			}
		}
	}
	
	
	// 説明文を付ける（不細工だけど上の方法がうまくいかないので、とりあえず。
	if (showall) {
		var note0 = get_shopnote(0);
		GEvent.addListener(marker[0], "click", function() { this.openInfoWindowHtml(note0); });
		
		var note1 = get_shopnote(1);
		GEvent.addListener(marker[1], "click", function() { this.openInfoWindowHtml(note1); });
		
		var note2 = get_shopnote(2);
		GEvent.addListener(marker[2], "click", function() { this.openInfoWindowHtml(note2); });
		
		var note3 = get_shopnote(3);
		GEvent.addListener(marker[3], "click", function() { this.openInfoWindowHtml(note3); });
		
		var note4 = get_shopnote(4);
		GEvent.addListener(marker[4], "click", function() { this.openInfoWindowHtml(note4); });
		
		var note5 = get_shopnote(5);
		GEvent.addListener(marker[5], "click", function() { this.openInfoWindowHtml(note5); });
		
		var note6 = get_shopnote(6);
		GEvent.addListener(marker[6], "click", function() { this.openInfoWindowHtml(note6); });
		
		var note7 = get_shopnote(7);
		GEvent.addListener(marker[7], "click", function() { this.openInfoWindowHtml(note7); });
		
		var note8 = get_shopnote(8);
		GEvent.addListener(marker[8], "click", function() { this.openInfoWindowHtml(note8); });
		
		var note9 = get_shopnote(9);
		GEvent.addListener(marker[9], "click", function() { this.openInfoWindowHtml(note9); });
		
		var note10 = get_shopnote(10);
		GEvent.addListener(marker[10], "click", function() { this.openInfoWindowHtml(note10); });
		
		var note11 = get_shopnote(11);
		GEvent.addListener(marker[11], "click", function() { this.openInfoWindowHtml(note11); });
		
		var note12 = get_shopnote(12);
		GEvent.addListener(marker[12], "click", function() { this.openInfoWindowHtml(note12); });
		
		var note13 = get_shopnote(13);
		GEvent.addListener(marker[13], "click", function() { this.openInfoWindowHtml(note13); });
		
		var note14 = get_shopnote(14);
		GEvent.addListener(marker[14], "click", function() { this.openInfoWindowHtml(note14); });
	}
}


function get_shopnote(key, iscurrent)
{
	var str = str = '<strong>' + __CTN_SHOPS[key][0] + '</strong><br />' +
		__CTN_SHOPS[key][1] + '<br />';
	
	if (!iscurrent && __CTN_SHOPS[key][5]) {
		str = '<strong><a href="/test/profile/' + __CTN_SHOPS[key][5] + '">' +
			__CTN_SHOPS[key][0] + '</a></strong><br />' +
			__CTN_SHOPS[key][1] + '<br />';
	}
	
	if (__CTN_SHOPS[key][2] != "") {
		str += 'TEL:' + __CTN_SHOPS[key][2];
	}
	
	return str;
}


function load_ctn_map(key, scale, showall)
{
	var shop = __CTN_SHOPS[key];
	
	if (!shop) {
		return;
	}
	
	if (!scale) {
		scale = 16;
	}
	
	gmap_load('gmap', shop[4], shop[3], scale, key, showall);
}

function load_ctn_map2(key, scale, id)
{
	var shop = __CTN_SHOPS[key];
	
	if (!shop) {
		return;
	}
	
	if (!scale) {
		scale = 16;
	}
	
	if (!id) {
		id = 'gmap';
	}
	
	gmap_load(id, shop[4], shop[3], scale, key);
}

window.onunload = function(e){
	GUnload();
}