var map="";
var markers="";

jQuery(document).ready(function(){

	jQuery.ajax({
		url:"map/location.xml",
		type:"GET",
		error: function(){
			alert("xmlファイルの読み込みに失敗しました");
		},
		dataType:"xml",
		success:function(xml){
			parseXml(xml);
		}
	});

	map = new GMap2(document.getElementById("gmap"),{size:new GSize(296,296)});
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GOverviewMapControl());
	map.enableScrollWheelZoom();
});
function centerize(lat,lng){
	map.setCenter(new GLatLng(lat,lng), 16);
}


function parseXml(xml)
{
	jQuery(xml).find("location").each(function(){
		if(jQuery(this).children("id").text()==id){
			new icons(jQuery(this));
		}
	});
}


function icons(xml){

	this.xml=xml;
	this.id=xml.children("id").text();
	centerize(xml.children("lat").text(),xml.children("lng").text());
	this.htmlbody;
	this.markerIcon;
	this.opt;
	this.marker;

	this.markerIcon=new GIcon();
	if(xml.children("type").text()=="office"){
		this.markerIcon.image="map/office.png";
	}else if(xml.children("type").text()=="rapport"){
		this.markerIcon.image="map/rapport.png";
	}else if(xml.children("type").text()=="pitland"){
		this.markerIcon.image="map/pitland.png";
	}else if(xml.children("type").text()=="echo"){
		this.markerIcon.image="map/echo.png";
	}else if(xml.children("type").text()=="other"){
		this.markerIcon.image="map/other.png";
	}
	this.markerIcon.iconSize=new GSize(34,36);
	this.markerIcon.iconAnchor=new GPoint(17, 36);
	this.markerIcon.infoWindowAnchor=new GPoint(17, 2)

	this.opt={icon:this.markerIcon};

	this.marker=new GMarker(new GPoint(xml.children("lng").text(),xml.children("lat").text()),this.opt);
	this.marker.name=this.xml.children("name").text();
	map.addOverlay(this.marker);


}




