function Ftext() {

	Ftext.classname = "Ftext";
	Ftext.property  = "id,タイトル";
	Ftext.layers    = "掲示板テキスト.テキスト";
	Ftext.dom       = "";
	Ftext.current   = null;
	Ftext.mode      = "0";

	Ftext.layer = function() {
		this.name           = "掲示板テキスト.テキスト";
		this.level          = "0.5,25,50";
		this.type           = "text";
		this.font           = "ゴシック";
		this.fontstyle      = "太字";
		this.fontsize       = "14";
		this.fontrgb        = "0,153,0";
		this.back_rgb       = "255,255,255"
		this.paint          = true;
		this.visible        = false;
		newLayer(this);
	}

	Ftext.symbol = function() {	}

	Ftext.onCreate = function() { }

	Ftext.createObject = function(title,data,xy) {
		var classname = "Ftext";
		var layername = "掲示板テキスト.テキスト";
		top.map.tcl("createText",classname,layername,title,data,xy);
		top.redrawCanvas();
	}

}
new Ftext();

function Forum() {

	Forum.classname = "Forum";
	Forum.property  = "id,種別,タイトル,記事,時間,投稿者,削除パスワード";
	Forum.layers    = "掲示板.口コミ情報,掲示板.名所旧跡,掲示板.温泉銭湯,掲示板.病院,掲示板.お店,掲示板.レストラン,掲示板.喫茶店,掲示板.バー,掲示板.スポーツ施設,掲示板.サッカー場,掲示板.野球場,掲示板.プール,掲示板.駐車場,掲示板.駐輪場,掲示板.バス停,掲示板.タクシー乗り場,掲示板.ガソリンスタンド,掲示板.公衆トイレ,掲示板.喫煙所,掲示板.薬局,掲示板.丸（赤）,掲示板.四角（赤）,掲示板.三角（赤）,掲示板.丸（青）,掲示板.四角（青）,掲示板.三角（青）,掲示板.丸（緑）,掲示板.四角（緑）,掲示板.三角（緑）,掲示板.丸（黄）,掲示板.四角（黄）,掲示板.三角（黄）";
	Forum.dom       = "";
	Forum.current   = null;
	Forum.mode      = "0";
	Forum.id        = 0;

	Forum.layer = function() {
		this.name           = "掲示板.口コミ情報";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "info";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.名所旧跡";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "showplace";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.温泉銭湯";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "spa";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.病院";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "hospital";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.お店";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "shop";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.レストラン";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "restaurant";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.喫茶店";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "coffee";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.バー";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "bar";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.スポーツ施設";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "sports";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.サッカー場";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "soccer";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.野球場";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "baseball";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.プール";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "swiming";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.駐車場";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "park";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.駐輪場";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "bicycle";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.バス停";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "bus";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.タクシー乗り場";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "taxi";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.ガソリンスタンド";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "stand";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.公衆トイレ";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "toilet";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.喫煙所";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "cigarette";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.薬局";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "drug";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.丸（赤）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "circle_r";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.四角（赤）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "square_r";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.三角（赤）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "triangle_r";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.丸（青）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "circle_b";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.四角（青）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "square_b";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.三角（青）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "triangle_b";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.丸（緑）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "circle_g";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.四角（緑）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "square_g";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.三角（緑）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "triangle_g";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.丸（黄）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "circle_y";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.四角（黄）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "square_y";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);

		this.name           = "掲示板.三角（黄）";
		this.level          = "0.5,25,50";
		this.type           = "symbol";
		this.symbolname     = "triangle_y";
		this.symbolsize     = 20;
		this.transparency   = false;
		this.visible        = false;
		newLayer(this);
	}

	Forum.symbol = function(){
		this.name           = "info";
		this.type           = "raster";
		this.url            = "icon/symbol_info.bmp";
		newSymbol(this);

		this.name           = "showplace";
		this.type           = "raster";
		this.url            = "icon/symbol_showplace.bmp";
		newSymbol(this);

		this.name           = "spa";
		this.type           = "raster";
		this.url            = "icon/symbol_spa.bmp";
		newSymbol(this);

		this.name           = "hospital";
		this.type           = "raster";
		this.url            = "icon/symbol_hospital.bmp";
		newSymbol(this);

		this.name           = "shop";
		this.type           = "raster";
		this.url            = "icon/symbol_shop.bmp";
		newSymbol(this);

		this.name           = "restaurant";
		this.type           = "raster";
		this.url            = "icon/symbol_restaurant.bmp";
		newSymbol(this);

		this.name           = "coffee";
		this.type           = "raster";
		this.url            = "icon/symbol_coffee.bmp";
		newSymbol(this);

		this.name           = "bar";
		this.type           = "raster";
		this.url            = "icon/symbol_bar.bmp";
		newSymbol(this);

		this.name           = "sports";
		this.type           = "raster";
		this.url            = "icon/symbol_sports.bmp";
		newSymbol(this);

		this.name           = "baseball";
		this.type           = "raster";
		this.url            = "icon/symbol_baseball.bmp";
		newSymbol(this);

		this.name           = "soccer";
		this.type           = "raster";
		this.url            = "icon/symbol_soccer.bmp";
		newSymbol(this);

		this.name           = "swiming";
		this.type           = "raster";
		this.url            = "icon/symbol_swiming.bmp";
		newSymbol(this);

		this.name           = "park";
		this.type           = "raster";
		this.url            = "icon/symbol_park.bmp";
		newSymbol(this);

		this.name           = "bicycle";
		this.type           = "raster";
		this.url            = "icon/symbol_bicycle.bmp";
		newSymbol(this);

		this.name           = "bus";
		this.type           = "raster";
		this.url            = "icon/symbol_bus.bmp";
		newSymbol(this);

		this.name           = "taxi";
		this.type           = "raster";
		this.url            = "icon/symbol_taxi.bmp";
		newSymbol(this);

		this.name           = "stand";
		this.type           = "raster";
		this.url            = "icon/symbol_stand.bmp";
		newSymbol(this);

		this.name           = "toilet";
		this.type           = "raster";
		this.url            = "icon/symbol_toilet.bmp";
		newSymbol(this);

		this.name           = "cigarette";
		this.type           = "raster";
		this.url            = "icon/symbol_cigarette.bmp";
		newSymbol(this);

		this.name           = "drug";
		this.type           = "raster";
		this.url            = "icon/symbol_drug.bmp";
		newSymbol(this);

		this.name           = "circle_r";
		this.type           = "raster";
		this.url            = "icon/symbol_circle_r.bmp";
		newSymbol(this);

		this.name           = "square_r";
		this.type           = "raster";
		this.url            = "icon/symbol_square_r.bmp";
		newSymbol(this);

		this.name           = "triangle_r";
		this.type           = "raster";
		this.url            = "icon/symbol_triangle_r.bmp";
		newSymbol(this);

		this.name           = "circle_b";
		this.type           = "raster";
		this.url            = "icon/symbol_circle_b.bmp";
		newSymbol(this);

		this.name           = "square_b";
		this.type           = "raster";
		this.url            = "icon/symbol_square_b.bmp";
		newSymbol(this);

		this.name           = "triangle_b";
		this.type           = "raster";
		this.url            = "icon/symbol_triangle_b.bmp";
		newSymbol(this);

		this.name           = "circle_g";
		this.type           = "raster";
		this.url            = "icon/symbol_circle_g.bmp";
		newSymbol(this);

		this.name           = "square_g";
		this.type           = "raster";
		this.url            = "icon/symbol_square_g.bmp";
		newSymbol(this);

		this.name           = "triangle_g";
		this.type           = "raster";
		this.url            = "icon/symbol_triangle_g.bmp";
		newSymbol(this);

		this.name           = "circle_y";
		this.type           = "raster";
		this.url            = "icon/symbol_circle_y.bmp";
		newSymbol(this);

		this.name           = "square_y";
		this.type           = "raster";
		this.url            = "icon/symbol_square_y.bmp";
		newSymbol(this);

		this.name           = "triangle_y";
		this.type           = "raster";
		this.url            = "icon/symbol_triangle_y.bmp";
		newSymbol(this);
	}

	Forum.onSelect = function(mapobj) {
		var classname = top.getClassNameO(mapobj);

		if(classname == "Forum"){
			Forum.current = mapobj;
			Forum.showProperty();
		}
	}

	Forum.onCreate = function(mapobj) {
		Forum.current = mapobj;

		var layername = top.map.objLayer(mapobj);
		var temp = new Array();
		temp = top.map.objGeometry(mapobj);
		var xy = temp[0] + "," + temp[1];

		var classname = top.getClassNameO(mapobj);
		var data = "&flag=0&layername="+layername+"&xy="+xy;
		top.sendRequest(Forum.setID,data,"POST","script/setForumData.php",false,false,"","");

		var id = Forum.id;
		setFieldVal(mapobj,"id",id);

		var att = Forum.dom;
		att.id.value = id;
		att.xy.value = xy;

		top.stopDraw();
		Forum.mode = "0";
	}

	Forum.setID = function(aobj) {
		var data = decodeURIComponent(aobj.responseText);
		if(data == "" || data == undefined || data == -1){
			alert("データの登録が失敗しました。");
			exit;
		}else{
			Forum.id = Number(data);
		}
	}

	Forum.setProperty = function() {
		var mapobj = Forum.current;
		if(mapobj == null) return;

		var att = Forum.dom;

		var kind     = att.kind.value;
		var title    = att.title.value;
		var memo     = att.memo.value;
		var time     = att.time.value;
		var username = att.username.value;
		var password = att.password.value;
		var id       = att.id.value;
		var xy       = att.xy.value;

		setFieldVal(mapobj,"種別",kind);
		setFieldVal(mapobj,"タイトル",title);
		setFieldVal(mapobj,"記事",memo);
		setFieldVal(mapobj,"時間",time);
		setFieldVal(mapobj,"投稿者",username);
		setFieldVal(mapobj,"削除パスワード",password);

		var classname = top.getClassNameO(mapobj);
		var data = "&flag=1&kind="+kind+"&title="+title+"&memo="+memo+"&time="+time+"&username="+username+"&password="+password+"&xy="+xy+"&id="+id;
		top.sendRequest(blank,data,"POST","script/setForumData.php",false,false,"","");

		var data = id + "," + title;
		Ftext.createObject(title,data,xy);
	}

	Forum.showProperty = function() {
		var mapobj = Forum.current;
		if(mapobj == null) return;

		var att = Forum.dom;

		att.kind.value      = getFieldVal(mapobj,"種別");
		att.title.value     = getFieldVal(mapobj,"タイトル");
		att.memo.value      = getFieldVal(mapobj,"記事");
		att.time.value      = getFieldVal(mapobj,"時間");
		att.username.value  = getFieldVal(mapobj,"投稿者");
		att.password.value  = getFieldVal(mapobj,"削除パスワード");
		att.id.value        = getFieldVal(mapobj,"id");

		var temp = new Array();
		temp = top.map.objGeometry(mapobj);
		att.xy.value = temp[0] + "," + temp[1];
	}

	Forum.remove = function() {
		var mapobj = Forum.current;
		if(mapobj == null) return;

		//var tobj = top.getObject("Ftext",id);
		//top.removeObj(tobj);

		var id = getFieldVal(mapobj,"id");
		var classname = top.getClassNameO(mapobj);
		var data = "&flag=2&id="+id;
		top.sendRequest(blank,data,"POST","script/setForumData.php",false,false,"","");

		top.removeObj(mapobj);

		Forum.current = null;
	}

	Forum.clearProperty = function() {
		var att = Forum.dom;

		att.kind.value      = "";
		att.title.value     = "";
		att.memo.value      = "";
		att.time.value      = "";
		att.username.value  = "";
		att.password.value  = "";
		att.id.value        = "";
		att.xy.value        = "";

		Forum.current = null;
	}

}
new Forum();

function Address() {

	Address.classname = "Address";
	Address.dom       = "";
	Address.symbol    = top.servername+"/lifemap/icon/symbol_sp.bmp";

	Address.setVlayerGroup = function(groupname) {
		top.map.draw_group(groupname);
		top.map.draw_xyunit("deg");
		top.map.draw_level('all');
	}

	Address.plotPoint = function(x,y) {
		top.map.draw_group('search');
		top.map.draw_remove('search');
		top.map.draw_symbol(Address.symbol,20,x,y);
	}

	Address.removePoint = function(groupname) {
		top.map.draw_remove(groupname);
	}

	Address.inputPoint = function(x,y){
		var att = Address.dom;
		att.keido.value = x;
		att.ido.value   = y;
		att.keiido.value = x + "," + y;
		Address.plotPoint(x,y);
	}

	Address.viewPoint = function(x,y) {
		Address.plotPoint(x,y);
		top.map.setMapCenter(x,y);
		top.map.openMap();
	}

	Address.viewAddress = function() {
		var att = Address.dom;
		var townid  = att.town[att.town.selectedIndex].value.split(',')[0];
		var address = att.address.value;
		var data = "&townid="+townid+"&address="+address;
		top.sendRequest(Address.call_viewAddress,data,"POST","script/getAddressData.php",false,false,"","");
	}

	Address.call_viewAddress = function(ajaxobj) {
		var att = Address.dom;
		var field = ajaxobj.responseText.split(",");
		if(field[0] == "" || field[0] == undefined || field[1] == undefined || field[0] == -1){
			alert("入力された住所は存在しないか、入力文字列が正しくありません。\r\n丁目-番地-号は半角で入力してください。");
		}else{
			Address.viewPoint(field[0],field[1]);
		}
	}

	Address.showTownList = function(callback) {
		top.sendRequest(eval("Address.call_showTownList_"+callback),"","POST","script/getTownList.php",false,false,"","");
	}

	Address.call_showTownList_view = function(ajaxobj) {
		var att = Address.dom;
		var record = ajaxobj.responseText.split("\r\n");

		var option = "<select name='town' style='width:180px' onchange='selectTown(this)' size='10'>";
		if(record[1] == "" || record[0] == "-1"){
			option += "<option value=''>登録データ件数:0件</option>";
		}else{
			var num = record.length - 1;
			for(var i = 0; i < num; i++){
				var field = record[i].split(",");
				if(field[0] == "161") field[3] = "島町";
				option += "<option value='"+field[0]+","+field[1]+","+field[2]+"'>"+field[3]+"</option>";
			}
		}
		option += "</select>";
		att.town.outerHTML = option;
		att.town[0].selected = true;
	}
	Address.call_showTownList_input = function(ajaxobj) {
		var att = Address.dom;
		var record = ajaxobj.responseText.split("\r\n");

		var option = "<select name='town' style='width:180px' size='9' ondblclick='clickTown(this)' onchange='selectTown(this)'>";
		if(record[1] == "" || record[0] == "-1"){
			option += "<option value=''>登録データ件数:0件</option>";
		}else{
			var num = record.length - 1;
			for(var i = 0; i < num; i++){
				var field = record[i].split(",");
				if(field[0] == "161") field[3] = "島町";
				option += "<option value='"+field[0]+","+field[1]+","+field[2]+"'>"+field[3]+"</option>";
			}
		}
		option += "</select>";
		att.town.outerHTML = option;
		att.town[0].selected = true;
	}

	Address.checkAddressData = function(townid,address) {
		var data = "script/checkAddressData.php?townid="+townid+"&address="+address;
		return top.map.tcl("checkAddressData",data);
	}

	Address.setAddressData = function() {
		var att = Address.dom;
		var townid  = att.town[att.town.selectedIndex].value.split(",")[0];
		var town    = att.town[att.town.selectedIndex].text;
		var address = att.address.value;
		var keido   = att.keido.value;
		var ido     = att.ido.value;

		var result = Address.checkAddressData(townid,address).split(",");
		if(result[0] == "0"){
			var data = "&flag=0&townid="+townid+"&town="+town+"&address="+address+"&longitude="+keido+"&latitude="+ido;
			top.sendRequest(Address.call_setAddressData_in,data,"POST","script/setAddressData.php",false,false,"","");
		}else if(result[0] == "1"){
			if(confirm("既に住所位置データが存在します。\n更新しますか？")){
				var data = "&flag=1&id="+result[1]+"&longitude="+keido+"&latitude="+ido;
				top.sendRequest(Address.call_setAddressData_up,data,"POST","script/setAddressData.php",false,false,"","");
			}
		}else{
			alert(result);
		}
	}

	Address.call_setAddressData_in = function(ajaxobj) {
		alert("住所位置データを登録しました。");
	}

	Address.call_setAddressData_up = function(ajaxobj) {
		alert("住所位置データを更新しました。");
	}

	Address.deleteAddressData = function() {
		var att = Address.dom;
		var townid  = att.town[att.town.selectedIndex].value.split(",")[0];
		var town    = att.town[att.town.selectedIndex].text;
		var address = att.address.value;

		var result = Address.checkAddressData(townid,address).split(",");
		if(result[0] == "0"){
			alert("住所位置データが存在しません。\n正しい丁目番号を入力してください。");
		}else if(result[0] == "1"){
			if(confirm("登録してある住所位置データを削除します。\nよろしいですか？")){
				var data = "&flag=2&id="+result[1];
				top.sendRequest(Address.call_deleteAddressData,data,"POST","script/setAddressData.php",false,false,"","");
			}
		}else{
			alert(result);
			return
		}
	}

	Address.call_deleteAddressData = function(ajaxobj) {
		alert("住所位置データを削除しました。");
	}

	Address.clearForm = function() {
		var att = Address.dom;

		att.text.value    = "";
		att.address.value = "";
		att.keido.value   = "";
		att.ido.value     = "";
		att.town.selectedIndex = 0;

		Address.removePoint("search");
	}
}
new Address();

function Landmark() {

	Landmark.classname = "Landmark";
	Landmark.dom       = "";
	Landmark.symbol    = top.servername+"/lifemap/icon/symbol_sp.bmp";

	Landmark.setVlayerGroup = function(groupname) {
		top.map.draw_group(groupname);
		top.map.draw_xyunit("deg");
		top.map.draw_level('all');
	}

	Landmark.removePoint = function(groupname) {
		top.map.draw_remove(groupname);
	}

}
new Landmark();

function Shortcut() {

	Shortcut.classname = "Shortcut";
	Shortcut.dom       = "";
	Shortcut.symbol_s  = top.servername+"/lifemap/icon/symbol_start.bmp";
	Shortcut.symbol_g  = top.servername+"/lifemap/icon/symbol_gorl.bmp";
	Shortcut.num       = 0;

	Shortcut.setVlayerGroup = function(groupname) {
		top.map.draw_group(groupname);
		top.map.draw_xyunit("deg");
		top.map.draw_level('all');
		top.map.draw_width(3);
		top.map.draw_color(153,0,204);
	}

	Shortcut.removeVlayer = function(groupname) {
		Shortcut.num = 0;
		top.map.draw_remove(groupname);
	}

	Shortcut.inputRoot = function(x,y) {
		var att = Shortcut.dom;

		top.map.draw_group('shortcut1');
		if(Shortcut.num == 2){
			att.keido1.value = ""; att.ido1.value   = "";
			att.keido2.value = ""; att.ido2.value   = "";
			top.map.draw_remove('shortcut1');
			Shortcut.num = 0;
		}
		if(Shortcut.num == 1){
			att.keido2.value = x; att.ido2.value   = y;
			top.map.draw_symbol(Shortcut.symbol_g,20,x,y);
			Shortcut.num++;
		}
		if(Shortcut.num == 0){
			att.keido1.value = x; att.ido1.value   = y;
			top.map.draw_symbol(Shortcut.symbol_s,20,x,y);
			Shortcut.num++;
		}
	}

	Shortcut.createRoot = function() {
		var att = Shortcut.dom;
		if(att.keido1.value != "" && att.ido1.value != "" && att.keido2.value != "" && att.ido2.value != ""){
			Shortcut.removeVlayer("shortcut1");
			var speed  = att.speed[att.speed.selectedIndex].value;
			var data = "&keido1="+att.keido1.value+"&ido1="+att.ido1.value+"&keido2="+att.keido2.value+"&ido2="+att.ido2.value+"&speed="+speed;
			top.sendRequest(Shortcut.call_createRoot,data,"POST","script/execRoot.php",false,false,"","");
		}else{
			alert("ルート検索を行う2点を\nマップ上で指定して下さい。");
		}
	}

	Shortcut.call_createRoot = function(ajaxobj) {
		var record = ajaxobj.responseText.split("\r\n");
		if(record[0] == "" || record[0] == undefined || record[1] == undefined){
			alert("入力した情報が正しくありません。\n始点終点を地図上で指定して下さい。");
		}else{
			var field = record[0].split(",");
			var text  = "　 距離：" + field[4] + "m 時間：" + Math.round(field[4] / field[5]) + "分";
			Shortcut.setVlayerGroup("shortcut2");
			top.map.draw_line(record[1].split(","));
			top.map.draw_symbol(Shortcut.symbol_s,20,field[0],field[1]);
			top.map.draw_symbol(Shortcut.symbol_g,20,field[2],field[3]);
			top.map.draw_color(255,0,0);
			top.map.draw_text("ゴシック","標準",12,"LC",text,field[2],field[3]);
			top.redrawCanvas();
		}
	}
}
new Shortcut();
