//<![CDATA[
var map;
var gmarkers = [];
var arr_lat = new Array();
var arr_lng = new Array();
var arr_title = new Array();
var arr_zip = new Array();
var arr_add = new Array();
var arr_tel = new Array();
var arr_tel2 = new Array();
var arr_tel3 = new Array();
var arr_tel4 = new Array();
var arr_fax = new Array();
var arr_img = new Array();
var arr_link = new Array();
var arr_cat = new Array();
var arr_id = new Array();
var arr_html = new Array();
		
		
		
function onLoad(){
		map = new GMap2(document.getElementById("map_google"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GOverviewMapControl());
		map.enableScrollWheelZoom();
		map.setCenter(new GLatLng(34.437623, 135.358485), 15);
		var request = GXmlHttp.create();
		
		request.open("GET", "data.xml", true);
		request.onreadystatechange = function() {
			if (request.readyState == 4) {
				var xmlDoc = request.responseXML;
				var markers = xmlDoc.documentElement.getElementsByTagName("marker");
				for (var i = 0; i < markers.length; i++) {
					arr_lat[i] = parseFloat(markers[i].getAttribute("lat"));
					arr_lng[i] = parseFloat(markers[i].getAttribute("lng"));
					arr_title[i] = markers[i].getAttribute("title");
					arr_zip[i] = markers[i].getAttribute("zip");
					arr_add[i] = markers[i].getAttribute("add");
					arr_tel[i] = markers[i].getAttribute("tel");
					arr_tel2[i] = markers[i].getAttribute("tel2");
					arr_tel3[i] = markers[i].getAttribute("tel3");
					arr_tel4[i] = markers[i].getAttribute("tel4");
					arr_fax[i] = markers[i].getAttribute("fax");
					arr_img[i] = markers[i].getAttribute("img");
					arr_link[i] = markers[i].getAttribute("link");
					arr_cat[i] = markers[i].getAttribute("cat");
					arr_id[i] = markers[i].getAttribute("id"); 
					arr_html[i] = ""; 
					if ( arr_cat[i] == "s_01" ) {
						var point = new GLatLng(arr_lat[i],arr_lng[i]);
			            var marker = createMarker(point,arr_title[i],arr_html[i],arr_zip[i],arr_add[i],arr_tel[i],arr_tel2[i],arr_tel3[i],arr_tel4[i],arr_fax[i],arr_img[i],arr_id[i],i,arr_cat[i]);
				        gmarkers[i] = marker;
			        } else {
				        gmarkers[i] = null;
			        }
			        

				}
				var point = new GLatLng(34.437686,135.358434);
				map.setCenter(point, 15);
				document.getElementById('map_d_01').style.display = 'block'; 
			}
		}
		request.send(null);
}


function createMarker(point, name, html, zip, add, tel, tel2, tel3, tel4, fax, img, id, i, cat) {

		id_str = location.search; 
		id_str = id_str.substring(1,id_str.length);
		html = "<div style='font-size: 90%; white-space: nowrap;'><strong>" ;
		html = html + arr_title[i] +"</strong><br />";
		if ( arr_img[i] !="" ){
				html = html + "<img src='" + arr_img[i] + "' height='100' />"  + "<br />";
		}
		html = html + arr_zip[i] +"<br />"+ arr_add[i] +"<br />";
		html = html + arr_tel[i] +"<br />";
		if ( arr_tel2[i] !="" ){
				html = html + arr_tel2[i] +"<br />";
		}
		if ( arr_tel3[i] !="" ){
				html = html + arr_tel3[i] +"<br />";
		}
		if ( arr_tel4[i] !="" ){
				html = html + arr_tel4[i] +"<br />";
		}
		html = html + arr_fax[i] +"<br />";
		if ( arr_link[i] != "" ){
				html = html + "<a href=" + "'" + arr_link[i] + "'" + "target='_blank'>[詳細...]</a>";
		}
		html = html + "<\/div>";
		var icon = new GIcon();
		switch ( cat ) {
			case "s_01":
				icon.image = "img/icon_l_01.gif";
				break;
			case "s_02":
				icon.image = "img/icon_l_02.gif";
				break;
			case "s_03":
				icon.image = "img/icon_l_03.gif";
				break;
			case "s_04":
				icon.image = "img/icon_l_04.gif";
				break;
			case "s_05":
				icon.image = "img/icon_l_05.gif";
				break;
			case "s_06":
				icon.image = "img/icon_l_06.gif";
				break;
			case "s_07":
				icon.image = "img/icon_l_07.gif";
				break;
			case "s_08":
				icon.image = "img/icon_l_08.gif";
				break;
			case "s_09":
				icon.image = "img/icon_l_09.gif";
				break;
			case "s_10":
				icon.image = "img/icon_l_10.gif";
				break;
			default:
				icon.image = "img/icon_l_01.gif";
				break;
		}
		icon.iconSize = new GSize(25, 29);
		icon.iconAnchor = new GPoint(21, 17);
		icon.infoWindowAnchor = new GPoint(5, 1);
		var marker = new GMarker(point, icon);	
		GEvent.addListener(marker, "click", function() {  marker.openInfoWindowHtml(html);	});
        map.addOverlay(marker);		
		return marker;

}




function clickpoint(id){
	for (var i = 0; i < arr_id.length; i++) {
		if ( arr_id[i] == id ) {
			var click_point = new GLatLng(arr_lat[i],arr_lng[i]);
			map.setCenter(click_point, 15);
			arr_html[i] = "<div style='font-size: 90%; white-space: nowrap;'><strong>" ;
			arr_html[i] = arr_html[i] + arr_title[i] +"</strong><br />";
			if ( arr_img[i] !="" ){
				arr_html[i] = arr_html[i] + "<img src='" + arr_img[i] + "' height='100' />" + "<br />";
			}
			arr_html[i] = arr_html[i] + arr_zip[i] +"<br />"+ arr_add[i] +"<br />";
			arr_html[i] = arr_html[i] + arr_tel[i] +"<br />";
			if ( arr_tel2[i] != "" ){
				arr_html[i] = arr_html[i] + arr_tel2[i] +"<br />";
			}
			if ( arr_tel3[i] != "" ){
				arr_html[i] = arr_html[i] + arr_tel3[i] +"<br />";
			}
			if ( arr_tel4[i] != "" ){
				arr_html[i] = arr_html[i] + arr_tel4[i] +"<br />";
			}
			arr_html[i] = arr_html[i] + arr_fax[i] +"<br />";
			if ( arr_link[i] != "" ){
				arr_html[i] = arr_html[i] + "<a href=" + "'" + arr_link[i] + "'" + "target='_blank'>[詳細...]</a>";
			}
			arr_html[i] = arr_html[i] + "<\/div>";
			gmarkers[i].openInfoWindowHtml(arr_html[i]);
			break;
		}
	}
}

function cat_change(cat){
	switch ( cat ) {
		case "s_01":
			document.getElementById('map_d_01').style.display = 'block'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_02":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'block'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none'; 
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_03":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'block'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_04":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'block'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_05":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'block'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_06":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'block'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_07":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'block'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_08":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'block';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_09":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'block';
			document.getElementById('map_d_10').style.display = 'none';
			break;
		case "s_10":
			document.getElementById('map_d_01').style.display = 'none'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'block';
			break;
		default:
			document.getElementById('map_d_01').style.display = 'block'; 
			document.getElementById('map_d_02').style.display = 'none'; 
			document.getElementById('map_d_03').style.display = 'none'; 
			document.getElementById('map_d_04').style.display = 'none'; 
			document.getElementById('map_d_05').style.display = 'none'; 
			document.getElementById('map_d_06').style.display = 'none'; 
			document.getElementById('map_d_07').style.display = 'none'; 
			document.getElementById('map_d_08').style.display = 'none';
			document.getElementById('map_d_09').style.display = 'none';
			document.getElementById('map_d_10').style.display = 'none';
			break;
	}

    map.clearOverlays();
	for (var i = 0; i < arr_id.length; i++) {
		if ( arr_cat[i] == cat ) {
			var point = new GLatLng(arr_lat[i],arr_lng[i]);
            var marker = createMarker(point,arr_title[i],arr_html[i],arr_zip[i],arr_add[i],arr_tel[i],arr_tel2[i],arr_tel3[i],arr_tel4[i],arr_fax[i],arr_img[i],arr_id[i],i,arr_cat[i]);
	        gmarkers[i] = marker;
		}
	}


}
//]]>