var map;
function load(){
	if (GBrowserIsCompatible()) {
	var physWithLabels = [ G_PHYSICAL_MAP.getTileLayers()[0], G_HYBRID_MAP.getTileLayers()[1] ];
var physWithLabelsMap = new GMapType(physWithLabels, G_PHYSICAL_MAP.getProjection(), "Hybrid Terrain");
map = new GMap2(document.getElementById("map"));
map.addMapType(G_PHYSICAL_MAP);
map.addMapType(physWithLabelsMap);
map.setCenter(new GLatLng(48.20860215896063, 16.372504234313965), 14, G_SATELLITE_MAP);
var mapControl = new GHierarchicalMapTypeControl();
mapControl.clearRelationships();
mapControl.addRelationship(G_SATELLITE_MAP, G_HYBRID_MAP, "Labels", false);
mapControl.addRelationship(G_PHYSICAL_MAP, physWithLabelsMap, "Labels", false);
map.addControl(mapControl);
map.addControl(new GScaleControl());
map.addControl(new GLargeMapControl());
loadMap2('./xml/wieninfo.xml');
	}
}

var resultText = "";
var markers = new Array();
var htmls = new Array();
var end;
var i=1;
function createMarker(point, title, html){
	var myIcon;
	myIcon = new GIcon();
	myIcon.image = "http://www.travelplatz.com/js/icony/icony"+ i + ".png";
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadow = "http://www.travelplatz.com/js/shadow50.png";
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GLatLng(34, 10);
	myIcon.infoWindowAnchor = new GPoint(5, 5);
	var marker = new GMarker(point,{"icon":myIcon, "clickable":true, "title":title});
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
		map.removeOverlay(marker);
		markers[i] = marker;
		htmls[i] = html;
		resultText =  resultText + "<a href=javascript:changePlace("+ i +")>"+ i + " " + title +"</a><br />";
		i++;
		if(i >end){i=1}
		return marker;
}
function createMarker1(point, title, html){
	var myIcon;
	myIcon = new GIcon();
	myIcon.image = "http://www.travelplatz.com/js/icong/icong"+ i + ".png";
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadow = "http://www.travelplatz.com/js/shadow50.png";
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GLatLng(34, 10);
	myIcon.infoWindowAnchor = new GPoint(5, 5);
	var marker = new GMarker(point,{"icon":myIcon, "clickable":true, "title":title});
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
		map.removeOverlay(marker);
		markers[i] = marker;
		htmls[i] = html;
		resultText =  resultText + "<a href=javascript:changePlace("+ i +")>"+ i + " " + title +"</a><br />";
		i++;
		if(i >end){i=1}
		return marker;
}
function createMarker2(point, title, html){
	var myIcon;
	myIcon = new GIcon();
	myIcon.image = "http://www.travelplatz.com/js/iconr/iconr"+ i + ".png";
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadow = "http://www.travelplatz.com/js/shadow50.png";
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GLatLng(34, 10);
	myIcon.infoWindowAnchor = new GPoint(5, 5);
	var marker = new GMarker(point,{"icon":myIcon, "clickable":true, "title":title});
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
		map.removeOverlay(marker);
		markers[i] = marker;
		htmls[i] = html;
		resultText =  resultText + "<a href=javascript:changePlace("+ i +")>"+ i + " " + title +"</a><br />";
		i++;
		if(i >end){i=1}
		return marker;
}
function createMarker3(point, title, html){
	var myIcon;
	myIcon = new GIcon();
	myIcon.image = "http://www.travelplatz.com/js/iconb/iconb"+ i + ".png";
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadow = "http://www.travelplatz.com/js/shadow50.png";
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GLatLng(34, 10);
	myIcon.infoWindowAnchor = new GPoint(5, 5);
	var marker = new GMarker(point,{"icon":myIcon, "clickable":true, "title":title});
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
		map.removeOverlay(marker);
		markers[i] = marker;
		htmls[i] = html;
		resultText =  resultText + "<a href=javascript:changePlace("+ i +")>"+ i + " " + title +"</a><br />";
		i++;
		if(i >end){i=1}
		return marker;
}
function createMarker4(point, title, html){
	var myIcon;
	myIcon = new GIcon();
	myIcon.image = "http://www.travelplatz.com/js/iconrw/iconrw"+ i + ".png";
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadow = "http://www.travelplatz.com/js/shadow50.png";
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GLatLng(34, 10);
	myIcon.infoWindowAnchor = new GPoint(5, 5);
	var marker = new GMarker(point,{"icon":myIcon, "clickable":true, "title":title});
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
		map.removeOverlay(marker);
		markers[i] = marker;
		htmls[i] = html;
		resultText =  resultText + "<a href=javascript:changePlace("+ i +")>"+ i + " " + title +"</a><br />";
		i++;
		if(i >end){i=1}
		return marker;
}
function createMarker5(point, title, html){
	var myIcon;
	myIcon = new GIcon();
	myIcon.image = "http://www.travelplatz.com/js/iconw/iconw"+ i + ".png";
	myIcon.iconSize = new GSize(20, 34);
	myIcon.shadow = "http://www.travelplatz.com/js/shadow50.png";
	myIcon.shadowSize = new GSize(37, 34);
	myIcon.iconAnchor = new GLatLng(34, 10);
	myIcon.infoWindowAnchor = new GPoint(5, 5);
	var marker = new GMarker(point,{"icon":myIcon, "clickable":true, "title":title});
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});
		map.removeOverlay(marker);
		markers[i] = marker;
		htmls[i] = html;
		resultText =  resultText + "<a href=javascript:changePlace("+ i +")>"+ i + " " + title +"</a><br />";
		i++;
		if(i >end){i=1}
		return marker;
}
function clearMarker(){
	map.clearOverlays();
}
function changePlace(i) {
   markers[i].openInfoWindowHtml(htmls[i]);
}
function loadMap(url){
	var request = GXmlHttp.create();
	request.open("GET", url, true);
	var xmlUrl = url;
	request.onreadystatechange = function(){
		if(request.readyState==4){
			var xml = request.responseXML;
			var place = xml.documentElement.getElementsByTagName("items");
			end = place.length;
			resultText="";
			for(var i=0; i<place.length; i++){
				var lat = parseFloat(place[i].getElementsByTagName("lat")[0].firstChild.nodeValue);
				var lng = parseFloat(place[i].getElementsByTagName("lon")[0].firstChild.nodeValue);
				var classes = parseFloat(place[i].getElementsByTagName("class")[0].firstChild.nodeValue);
				var point = new GLatLng(lat, lng);
				var html = "<div style='width:250px'>";
				if(place[i].getElementsByTagName("name").length != 0){
					html += "<b style='color: navy; font-size: small; font-weight: 400; font-style: normal;'>";
					var name = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
					html += name + "</b>(";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("kana").length != 0){
					html += place[i].getElementsByTagName("kana")[0].firstChild.nodeValue;
					html += "</b>)<br />";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("add").length != 0){
					html += "<font size='-1'>";
					html += "住所：";
					html += place[i].getElementsByTagName("add")[0].firstChild.nodeValue;
					html += "<br />";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("class").length != 0){
					html += place[i].getElementsByTagName("class")[0].firstChild.nodeValue;
					html += "星クラス";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("type").length != 0){
					html += "(";
					html += place[i].getElementsByTagName("type")[0].firstChild.nodeValue;
					html += "タイプ)";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("rooms").length != 0){
					html += "(";
					html += place[i].getElementsByTagName("rooms")[0].firstChild.nodeValue;
					html += "室)<br />";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("info").length != 0){
					html += place[i].getElementsByTagName("info")[0].firstChild.nodeValue;
					html += "</font></div>";
				}else{
					html += "";
					html += "</font></div>";
				}
				var title = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				var title1 = place[i].getElementsByTagName("kana")[0].firstChild.nodeValue;
				if(classes ==5){var marker = createMarker(point, title, html);}
				else if(classes==4){var marker = createMarker1(point, title, html);}
				else if(classes==3){var marker = createMarker2(point, title, html);}
				else if(classes==2){var marker = createMarker3(point, title, html);}
				else {var marker = createMarker4(point, title, html);}
				map.addOverlay(marker);
				}
				document.getElementById("map_right").innerHTML = resultText;
		}
	}
request.send('');
}
function loadMap1(url){
	var request = GXmlHttp.create();
	request.open("GET", url, true);
	var xmlUrl = url;
	request.onreadystatechange = function(){
		if(request.readyState==4){
			var xml = request.responseXML;
			var place = xml.documentElement.getElementsByTagName("items");
			
			end = place.length;
			resultText="";
			for(var i=0; i<place.length; i++){
				var lat = parseFloat(place[i].getElementsByTagName("lat")[0].firstChild.nodeValue);
				var lng = parseFloat(place[i].getElementsByTagName("lon")[0].firstChild.nodeValue);
				var classes = parseFloat(place[i].getElementsByTagName("class")[0].firstChild.nodeValue);
				var point = new GLatLng(lat, lng);
				var html = "<div style='width:250px'>";
				if(place[i].getElementsByTagName("kana").length != 0){
					html += "<b style='color: navy; font-size: small; font-weight: 400; font-style: normal;'>";
					var kana = place[i].getElementsByTagName("kana")[0].firstChild.nodeValue;
					html += kana + "</b>(";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("name").length != 0){
					html += place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
					html += "</b>)<br />";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("add").length != 0){
					html += "<font size='-1'>";
					html += "住所：";
					html += place[i].getElementsByTagName("add")[0].firstChild.nodeValue;
					html += "<br />";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("class").length != 0){
					html += place[i].getElementsByTagName("class")[0].firstChild.nodeValue;
					html += "星クラス";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("type").length != 0){
					html += "(";
					html += place[i].getElementsByTagName("type")[0].firstChild.nodeValue;
					html += "タイプ)";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("rooms").length != 0){
					html += "(";
					html += place[i].getElementsByTagName("rooms")[0].firstChild.nodeValue;
					html += "室)<br />";
				}else{
					html += "";
				}
				if(place[i].getElementsByTagName("info").length != 0){
					html += place[i].getElementsByTagName("info")[0].firstChild.nodeValue;
					html += "</font></div>";
				}else{
					html += "";
					html += "</font></div>";
				}
				var title = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				var title1 = place[i].getElementsByTagName("kana")[0].firstChild.nodeValue;
				if(classes ==5){var marker = createMarker(point, title1, html);}
				else if(classes==4){var marker = createMarker1(point, title1, html);}
				else if(classes==3){var marker = createMarker2(point, title1, html);}
				else if(classes==2){var marker = createMarker3(point, title1, html);}
				else {var marker = createMarker4(point, title, html);}map.addOverlay(marker);
				}
				document.getElementById("map_right").innerHTML = resultText;
		 }
	}
request.send('');
}
function loadMap2(url){
	var request = GXmlHttp.create();
	request.open("GET", url, true);
	request.onreadystatechange = function(){
		if(request.readyState==4){
			var xml = request.responseXML;
			var place = xml.documentElement.getElementsByTagName("items");
			end = place.length;
			resultText="";
			for(var i=0; i<place.length; i++){
				var lat = parseFloat(place[i].getElementsByTagName("lat")[0].firstChild.nodeValue);
				var lng = parseFloat(place[i].getElementsByTagName("lon")[0].firstChild.nodeValue);
				var point = new GLatLng(lat, lng);
				var html = "<div style='width:200px'>";
				if(place[i].getElementsByTagName("name").length != 0){
					html += "<b style='color: red; font-size: small; font-weight: 400; font-style: normal;'>";
					var name = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				}
				if(place[i].getElementsByTagName("url").length != 0){
					var link = place[i].getElementsByTagName("url")[0].firstChild.nodeValue;
					html += "<a href='"+ link + "'target='_blank'>"+ name + "</a></b><br />";
				}else{
					html += name;
					html += "</b><br />";
				}
				if(place[i].getElementsByTagName("info").length != 0){
					html += "<font size='-1'>";
					html += place[i].getElementsByTagName("info")[0].firstChild.nodeValue;
					html += "</font><br />";
				}else{
					html += "";
					html += "</div>";
				}
				var title = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				var marker = createMarker4(point, title, html);
				map.addOverlay(marker);
				}
				document.getElementById("map_right").innerHTML = resultText;
		}
	}
request.send('');
}
function loadMap3(url){
	var request = GXmlHttp.create();
	request.open("GET", url, true);
	request.onreadystatechange = function(){
		if(request.readyState==4){
			var xml = request.responseXML;
			var place = xml.documentElement.getElementsByTagName("items");
			end = place.length;
			resultText="";
			for(var i=0; i<place.length; i++){
				var lat = parseFloat(place[i].getElementsByTagName("lat")[0].firstChild.nodeValue);
				var lng = parseFloat(place[i].getElementsByTagName("lon")[0].firstChild.nodeValue);
				var point = new GLatLng(lat, lng);
				var html = "<div style='width:200px'>";
				if(place[i].getElementsByTagName("name").length != 0){
					html += "<b style='color: red; font-size: small; font-weight: 400; font-style: normal;'>";
					var name = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				}
				if(place[i].getElementsByTagName("url").length != 0){
					var link = place[i].getElementsByTagName("url")[0].firstChild.nodeValue;
					html += "<a href='"+ link + "'target='_blank'>"+ name + "</a></b><br />";
				}else{
					html += name;
					html += "</b><br />";
				}
				if(place[i].getElementsByTagName("info").length != 0){
					html += "<font size='-1'>";
					html += place[i].getElementsByTagName("info")[0].firstChild.nodeValue;
					html += "</font><br />";
				}else{
					html += "";
					html += "</div>";
				}
				var title = place[i].getElementsByTagName("name")[0].firstChild.nodeValue;
				var marker = createMarker5(point, title, html);
				map.addOverlay(marker);
				}
				document.getElementById("map_right").innerHTML = resultText;
		}
	}
request.send('');
}

function ring(){
	var ring =[new GLatLng(48.211347653385154, 16.38288974761963), new GLatLng(48.20880235623749, 16.382160186767578), new GLatLng(48.20182358935748, 16.375036239624023), new GLatLng(48.2013945357784, 16.37362003326416), new GLatLng(48.20348256271771, 16.364049911499023), new GLatLng(48.20705775366278, 16.359543800354004), new GLatLng(48.213521065416565, 16.361560821533203), new GLatLng(48.21766745089618, 16.370744705200195), new GLatLng(48.2159803414607, 16.37289047241211), new GLatLng(48.21409300061887, 16.37409210205078), new GLatLng(48.21263455322783, 16.375722885131836), new GLatLng(48.21163363392294, 16.378684043884277), new GLatLng(48.211347653385154, 16.38288974761963)];
	var polygon1 = new GPolygon(ring, "#FF0000", 3, 1, "#FF0000", 0.3);
	map.addOverlay(polygon1);
}

onload = load;
onunload = GUnload;