function load(pos)
{
    if (document.all && !window.opera) {
        document.getElementById(pos).style.width=document.documentElement.clientWidth-250;
		document.getElementById(pos).style.height=document.documentElement.clientHeight-30;
    }
    else{
        document.getElementById(pos).style.width=(window.innerWidth-250)+'px';
		document.getElementById(pos).style.height=(window.innerHeight-30)+'px';
    }

	if(pos=="neyamap"){
		var map1=new setdraw("neyamap", 34.76278411, 135.6227338, 17, "/ecip/access/neya.xml");
		neyagawapoints(map1);
	}
	else if(pos=="nawamap"){
		var map2=new setdraw("nawamap",34.744398, 135.651412,15, "/ecip/access/nawate4.xml");
		nawatepoints(map2);
	}
}

function setdraw(id, lat, lng, zoom, filename)
{
	var map;

	if(typeof(GMap2) == 'undefined'){
		alert("GoogleMapが利用できません。ブラウザのキャッシュを削除すると解決する可能性があります。");
		return;
	}

	map = new GMap2(document.getElementById( id ));

	map.addControl(new GMapTypeControl());
	map.addControl(new GLargeMapControl());
	map.setCenter(new GLatLng( lat, lng ), zoom);

	var request = GXmlHttp.create();
	request.open("GET", filename, 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++) {
				var point = new GLatLng(
						parseFloat(markers[i].getAttribute("lat")),
						parseFloat(markers[i].getAttribute("lng")));
				if(markers[i].getAttribute("pop") == "1"){
					var html = "<b>" + markers[i].getAttribute("title") + "</b><br />" +
							markers[i].getAttribute("description");
					map.openInfoWindowHtml(point, html);
				}
				else{
					var marker = createMarker(
							point,
							markers[i].getAttribute("title"),
							markers[i].getAttribute("link"),
							markers[i].getAttribute("description"),
							markers[i].getAttribute("place"));
					map.addOverlay(marker);
				}
			}
		}
	}
	request.send(null);

	return map;
}

function neyagawapoints(map)
{
	var points =[];

	//YuukiMurakami edit start
	points.push(new GLatLng(34.76361482922189,135.62062829732895));
	points.push(new GLatLng(34.763368040720245,135.62052369117737));
	points.push(new GLatLng(34.76300446703,135.62036007642746));
	points.push(new GLatLng(34.76276649065661,135.62095820903778));
	points.push(new GLatLng(34.76257258347476,135.62144100666046));
	points.push(new GLatLng(34.762541734562916,135.6219720840454));
	points.push(new GLatLng(34.76277971158422,135.6227472424507));
	points.push(new GLatLng(34.76288988589882,135.62319785356522));
	points.push(new GLatLng(34.762876664988816,135.6237155199051));
	points.push(new GLatLng(34.76280615343314,135.62423586845398));
	points.push(new GLatLng(34.762817170867685,135.6248500943184));
	points.push(new GLatLng(34.762825984814256,135.62513172626495));
	points.push(new GLatLng(34.762634281263836,135.6249949336052));
	points.push(new GLatLng(34.76227731484575,135.62495738267899));
	points.push(new GLatLng(34.76182779938283,135.62493860721588));
	//YuukiMurakami edit end

	map.addOverlay(new GPolyline(points, '#ff0000',5,0.6));
}

function nawatepoints(map)
{
	var points = [];
	points.push(new GLatLng(34.745914697498826,135.64555406570435));
	points.push(new GLatLng(34.745599533788116,135.64580082893372));
	points.push(new GLatLng(34.74494055123472,135.64763814210892));
	points.push(new GLatLng(34.74480170139742,135.648375749588));
	points.push(new GLatLng(34.74458571229773,135.64870297908783));
	points.push(new GLatLng(34.744336662940974,135.64944595098495));
	points.push(new GLatLng(34.744268339534884,135.6501218676567));
	points.push(new GLatLng(34.74442923004622,135.65096139907837));
	points.push(new GLatLng(34.744625383807346,135.6514737010002));
	points.push(new GLatLng(34.74471795058907,135.6529140472412));
	points.push(new GLatLng(34.744821537102744,135.65325736999512));
	points.push(new GLatLng(34.74455926461407,135.6538125872612));
	points.push(new GLatLng(34.744393966399294,135.65412640571594));
	points.push(new GLatLng(34.744270543516585,135.6545850634575));
	points.push(new GLatLng(34.74438735446383,135.65473526716232));
	points.push(new GLatLng(34.744402782312434,135.65482646226883));
	points.push(new GLatLng(34.744111856682146,135.65516710281372));
	points.push(new GLatLng(34.74368207830814,135.65560966730118));
	points.push(new GLatLng(34.74320160547887,135.65607637166977));
	points.push(new GLatLng(34.74354983835863,135.65639287233353));
	points.push(new GLatLng(34.74299002022745,135.65719217061996));
	points.push(new GLatLng(34.742818106811654,135.65706342458725));
	points.push(new GLatLng(34.7427938625832,135.65703123807907));
	points.push(new GLatLng(34.742723333878175,135.65706610679626));
	points.push(new GLatLng(34.742626356810426,135.65672010183334));
	points.push(new GLatLng(34.74252937962887,135.65634459257126));
	points.push(new GLatLng(34.7420731445426,135.65650552511215));
	points.push(new GLatLng(34.74015781130399,135.6577742099762));
	points.push(new GLatLng(34.7389058778953,135.6577742099762));
	points.push(new GLatLng(34.73900726757446,135.65802097320557));
	points.push(new GLatLng(34.73900065520787,135.65827041864395));
	points.push(new GLatLng(34.738980818104935,135.65860837697983));
	points.push(new GLatLng(34.73926514945861,135.6586915254593));
	points.push(new GLatLng(34.73948556068749,135.65870225429535));
	points.push(new GLatLng(34.73996605512834,135.65893292427063));
	points.push(new GLatLng(34.74102842282601,135.6588390469551));

  	map.addOverlay(new GPolyline(points,'#ff0000',5,0.6));

	var points = [];
	points.push(new GLatLng(34.74272994594681,135.65707951784134));
	points.push(new GLatLng(34.7427189258321,135.65722972154617));
	points.push(new GLatLng(34.74244783054716,135.65732091665268));
	points.push(new GLatLng(34.742302364417775,135.65740406513214));
	points.push(new GLatLng(34.74204890009553,135.65760791301727));
	points.push(new GLatLng(34.74199820713776,135.65768837928772));
	points.push(new GLatLng(34.742013635432556,135.6578278541565));
	points.push(new GLatLng(34.74234424105705,135.65799683332443));
	points.push(new GLatLng(34.742390525738905,135.65807193517685));
	points.push(new GLatLng(34.74236628138496,135.6581550836563));
	points.push(new GLatLng(34.74231118055411,135.6582060456276));
	points.push(new GLatLng(34.74185053617047,135.6582409143448));
	points.push(new GLatLng(34.74169404873799,135.65843135118484));
	points.push(new GLatLng(34.741387685159836,135.65852254629135));
	points.push(new GLatLng(34.74102842282601,135.6588390469551));
	map.addOverlay(new GPolyline(points,'#0000ff',5,0.6));

	var points = [];
	points.push(new GLatLng(34.74220538685589,135.6573075056076));
	points.push(new GLatLng(34.742302364417775,135.65740406513214));
	points.push(new GLatLng(34.74204890009553,135.65760791301727));
	points.push(new GLatLng(34.74199820713776,135.65768837928772));
	points.push(new GLatLng(34.742013635432556,135.6578278541565));
	points.push(new GLatLng(34.74234424105705,135.65799683332443));
	points.push(new GLatLng(34.742390525738905,135.65807193517685));
	points.push(new GLatLng(34.74236628138496,135.6581550836563));
	points.push(new GLatLng(34.74231118055411,135.6582060456276));
	points.push(new GLatLng(34.74185053617047,135.6582409143448));
	points.push(new GLatLng(34.74169404873799,135.65843135118484));
	points.push(new GLatLng(34.741387685159836,135.65852254629135));
	points.push(new GLatLng(34.741204748093026,135.65872371196747));
	map.addOverlay(new GPolyline(points,'#0000ff',5,0.6));

	var points = [];
	points.push(new GLatLng(34.74198277884011,135.65629094839096));
	points.push(new GLatLng(34.742134857648495,135.65648943185806));
	points.push(new GLatLng(34.74226269179259,135.6571063399315));
	points.push(new GLatLng(34.7422142030026,135.65729409456253));
	map.addOverlay(new GPolyline(points,'#ff0000',5,0.6));

	var points = [];
	points.push(new GLatLng(34.731501890959684,135.63945472240448));
	points.push(new GLatLng(34.732383615177525,135.63947081565857));
	points.push(new GLatLng(34.732275604466416,135.64099162817));
	points.push(new GLatLng(34.73223372272411,135.64176946878433));
	points.push(new GLatLng(34.73347032733437,135.64182311296463));
	points.push(new GLatLng(34.73359156208452,135.64183920621872));
	points.push(new GLatLng(34.73434982630513,135.64186334609985));
	points.push(new GLatLng(34.73475761087246,135.64185798168182));
	points.push(new GLatLng(34.735555540258794,135.6419089436531));
	points.push(new GLatLng(34.736307173876604,135.64238369464874));
	points.push(new GLatLng(34.73898963459572,135.64418613910675));
	points.push(new GLatLng(34.738769222043906,135.64562916755676));
	points.push(new GLatLng(34.73862154530526,135.64674496650696));
	points.push(new GLatLng(34.73851795101765,135.64725190401077));
	points.push(new GLatLng(34.7384430103882,135.64745038747787));
	points.push(new GLatLng(34.738374682108,135.64825236797333));
	points.push(new GLatLng(34.7384187648759,135.64921259880066));
	points.push(new GLatLng(34.73848268484755,135.6499394774437));
	points.push(new GLatLng(34.738476072439,135.65045177936554));
	points.push(new GLatLng(34.7385554213069,135.6510391831398));
	points.push(new GLatLng(34.73818071764988,135.65111428499222));
	points.push(new GLatLng(34.7381035725684,135.6512001156807));
	points.push(new GLatLng(34.73804406059916,135.6514146924019));
	points.push(new GLatLng(34.73805067304229,135.65155416727066));
	points.push(new GLatLng(34.738290924784216,135.65201550722122));
	points.push(new GLatLng(34.73854440063536,135.65210670232773));
	points.push(new GLatLng(34.73854660476978,135.65328150987625));
	points.push(new GLatLng(34.73877142617234,135.65563648939133));
	points.push(new GLatLng(34.73875158901438,135.655936896801));
	points.push(new GLatLng(34.73844080625101,135.6570366024971));
	points.push(new GLatLng(34.73848929725559,135.65733969211578));
	points.push(new GLatLng(34.738932327388795,135.6579029560089));
	points.push(new GLatLng(34.73898963459572,135.65826505422592));
	points.push(new GLatLng(34.73894775625612,135.6586030125618));
	points.push(new GLatLng(34.73931143586545,135.65869957208633));
	points.push(new GLatLng(34.73948996890605,135.65869957208633));
	points.push(new GLatLng(34.73997487151399,135.65893828868866));
	points.push(new GLatLng(34.740984341450456,135.65883368253708));
	map.addOverlay(new GPolyline(points,'#00ff00',5,0.6));
}

function createMarker(point, title, link, description, place)
{
	var icon = new GIcon();
	var opts = new Object();

	if(place=="neyagawa"){
		icon.image = "http://www.osakac.ac.jp/ecip/access/neya.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize   = new GSize(50, 50);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(25, 25);
    	icon.infoWindowAnchor = new GPoint(25, 25);
	}
	else if(place=="nawate"){
		icon.image = "http://www.osakac.ac.jp/ecip/access/nawate.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize   = new GSize(50, 50);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(25, 25);
    	icon.infoWindowAnchor = new GPoint(25, 25);
	}
	else if(place=="nawaten"){
		icon.image = "http://www.osakac.ac.jp/ecip/access/nawaten.gif";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize   = new GSize(100, 40);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(50, 20);
    	icon.infoWindowAnchor = new GPoint(50, 20);
	}
	else{
		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(5, 1);
	}
	opts.icon=icon;
	var marker = new GMarker(point, opts);
	var html = "<b>" + title + "</b><br />" + description + "";
	GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml(html);});

	return marker;
}

