function OnloadAns(strget){
	onLoadTL('ans_timeline',strget)
	OnLoadGM('ans_map');
}
function OnloadNoAns(){
	document.getElementById('ans_timeline').innerHTML="該当データは見つかりませんでした。";
	document.getElementById('ans_map').innerHTML="該当データは見つかりませんでした。";
}
/* ----------------------------------------------------- */
/* Functions for Google Map */
/* ----------------------------------------------------- */
function OnLoadGM(divid){
	if (GBrowserIsCompatible()) {
		map2 = new GMap2(document.getElementById(divid));
		map2.addControl(new GLargeMapControl());
		map2.addControl(new GMapTypeControl());
 		map2.setCenter(center2, 11);
	}
	gmapmark(ll);
}

function gmapmark(ress){
	var latmax = 0;
	var latmin = 0;
	var lonmax = 0;
	var lonmin = 0;
	var resslen=ress.length;
	if (resslen > 0) {
		for (i = 0; i < resslen; i++) {
			var num = i + 1;
			var res = ress[i].split("::llnc::");
			if (res[0] != "" | res[1] != "") {
				res[0]=parseFloat(res[0]);
				res[1]=parseFloat(res[1]);
				var point = new GLatLng(res[0], res[1]);
				var name = res[2];
				var wininfo = res[3];
				var resicon = new GIcon(baseicon);
				resicon.image = 'http://www.seunze.com/pictures/marker' + num + '.png';
				createMarker(point, name, wininfo, resicon);
					
				if (latmax < res[0] | latmax == 0) {
					latmax = res[0];
				}
				if (latmin > res[0] | latmin == 0) {
					latmin = res[0];
				}
				if (lonmax < res[1] | lonmax == 0) {
					lonmax = res[1];
				}
				if (lonmin > res[1] | lonmin == 0) {
					lonmin = res[1];
				}
			}
		}
		var latcent = (parseFloat(latmax) + parseFloat(latmin)) / 2;
		var loncent = (parseFloat(lonmax) + parseFloat(lonmin)) / 2;
		if(!isNaN(latcent) | !isNaN(loncent)){
			center2 = new GLatLng(latcent, loncent);
			map2.setCenter(center2, 11);
			restshowmap(latmax, latmin, lonmax, lonmin);
		}
	}	
}

function createMarker(point, name, conts, icon){
	var marker = new GMarker(point, {
		title: name,icon: icon
	});
	GEvent.addListener(marker, "click", function(){
		marker.openInfoWindowHtml(conts);
	});
	map2.addOverlay(marker);
}

function restshowmap(latmax, latmin, lonmax, lonmin){
	map2.setCenter(center2, 15);
	check = false;
	while (!check) {
		check = true;
		map2.zoomOut();
		center2 = map2.getCenter();
		bounds = map2.getBounds();
		southWest = bounds.getSouthWest();
		northEast = bounds.getNorthEast();
		if (northEast.lat() < latmax) {
			check = false;
		}
		if (southWest.lat() > latmin) {
			check = false;
		}
		if (northEast.lng() < lonmax) {
			check = false;
		}
		if (southWest.lng() > lonmin) {
			check = false;
		}
	}
}
