
var App;var PANEL_HEIGHT=120;var linePoints=null;var objLine=null;var G_busOrgid=-1;var G_busRailid=-1;var G_busRailNoid=-1;var G_pref="";var G_busOrgName="";var G_busRailName="";var G_busRailNoName="";var G_busDestination="";var List_BusOrg=null;var List_BusRail=null;var List_BusRailNo=null;var List_Color=null;var G_LineColor=G_busLineDefaultColor;var G_LineDrawing;var G_prefPoint=null;var G_copyRefBusRailNoid=-1;var G_highwayBus=false;var G_PageNo=2;var mapConfig={"id":"gmap2","defalutLat":35.674206,"defaultLng":139.755707,"defaultZoom":14}
var busLineColors=[{"value":"#FF0000"},{"value":"#66FF00"},{"value":"#00CC66"},{"value":"#FFFF00"},{"value":"#FF9999"},{"value":"#FFCC33"},{"value":"#0000FF"},{"value":"#00CCFF"},{"value":"#000000"},{"value":"#996600"},{"value":"#FF33FF"},{"value":"#999"},{"value":"#6633FF"},{"value":"#000066"}];var G_busLineDefaultColor="#6633FF";var im=null;function onLoad(){im=new IconManager();im.get("5,6,7,8",bybusInit);}
function bybusInit(){App=new ByBusWebApp2();Element.hide('railmap');Element.hide('buslines');Element.hide('busLinediv');Element.hide('busLineNodiv');$('busorg').value="";$('kno').value="";$('destination').value="";$('linename').value="";Element.hide('btnreg');Element.hide('btncopy');Element.hide('btncopy2');G_copyRefBusRailNoid=-1;var dlg=new WaitDialog();dlg.show("画面を初期化しています");var AjaxRequest=new Ajax.Request("/calta/servlet/CaltaSessionServlet?action=login&account=guest&password="+MD5_hexhash("mizube2006"),{method:'post',onComplete:function(request){dlg.close();},onTimeout:function(req,ajaxComponent){alert("タイムアウトが発生しました");dlg.close();}});}
function getGmap(){if(App.gmap!=null){return App.gmap.map;}
return null;}
var ByBusWebApp2=Class.create();ByBusWebApp2.prototype={initialize:function(){App=this;this.gmap=null;this.busStopInfoList=null;this.iconManager=im;this.cursor=null;inputInit();window.onunload=function(){var cookie=new Cookie();try{var point=getGmap().getCenter();cookie.set("BYBUS2_LAT",point.y,365);cookie.set("BYBUS2_LNG",point.x,365);cookie.set("BYBUS2_ZOOM",getGmap().getZoom(),365);}
catch(e){}};Element.hide('busOrgdiv');Element.hide('colorselect');}}
var beforeZoom=null;var beforePoint=null;var ByBusMap=Class.create();ByBusMap.prototype={initialize:function(){this.map=new GMap2($(mapConfig.id));App.gmap=this;var objtypes=new Array(5,6);this.pointMarker=null;this.landMarkManger=new LandMarkManager();this.map.enableDoubleClickZoom();this.map.enableContinuousZoom();this.map.contorol=new GSmallMapControl();this.map.addControl(this.map.contorol);this.map.addControl(new GScaleControl());this.map.addControl(new GMapTypeControl());this.map.addControl(new google.maps.LocalSearch());var options={resultList:google.maps.LocalSearch.RESULT_LIST_INLINE};this.map.addControl(new google.maps.LocalSearch(options));this.lineColor=null;this.lineArrays=new Array();this.drawLineListener=null;this.busStops=null;this.showStop=false;this.zoomendlistener=GEvent.addListener(this.map,'zoomend',function(){map.show();});var map=this;this.moveendlistener=GEvent.addListener(this.map,'moveend',function(){map.show();});var cookie=new Cookie();var lat=cookie.get("BYBUS2_LAT");var lng=cookie.get("BYBUS2_LNG");var zoom=cookie.get("BYBUS2_ZOOM");if(lat!=null&&lng!=null&&zoom!=null){}
else{lat=mapConfig.defalutLat;lng=mapConfig.defaultLng;zoom=mapConfig.defaultZoom;}
this.map.setCenter(new GLatLng(lat,lng),parseInt(zoom));},show:function(){if(this.showStop==true)return;var point;var zoom;try{point=this.map.getCenter();zoom=this.map.getZoom();if(beforePoint!=null){if(point.x==beforePoint.x&&point.y==beforePoint.y){if(zoom==beforeZoom){return;}}}}
catch(e){}
beforeZoom=zoom;beforePoint=point;if(zoom<13)return;var url='/calta/servlet/CaltaServlet?objtype=5&ver=2';var prm=this.getAreaRangeStr();var AjaxRequest=new Ajax.Request(url+prm,{method:'post',onComplete:function(request){var xml=request.responseXML;App.gmap.landMarkManger.overlay(xml);}});},getAreaRangeStr:function(){var cObj=this.map.getBounds();var NorthEast=cObj.getNorthEast();var SouthWest=cObj.getSouthWest();return"&NorthEast_lat="+NorthEast.lat()+"&NorthEast_lng="+NorthEast.lng()
+"&SouthWest_lat="+SouthWest.lat()+"&SouthWest_lng="+SouthWest.lng()
+"&zoom="+this.map.getZoom();},moveMap:function(keyword){var geocode=new GClientGeocoder();geocode.getLatLng(keyword,function(point){var map=getGmap();if(point!=null){map.panTo(new GLatLng(point.y,point.x));}});},startDrawLine:function(color){$('lineDrawMessage').innerHTML="地図上をクリックして路線図を引きます。路線図を引き終えたら「登録」をクリックします。";if(color==null||color==undefined){this.lineColor=G_LineColor;}
else{this.lineColor=color;}
var color=this.lineColor;if(linePoints==null){linePoints=new Array();}
var map=this;this.drawLineListener=GEvent.addListener(this.map,'click',function(objOverlay,objPoint){if(objPoint){if(objLine!=null){getGmap().removeOverlay(objLine);}
linePoints.length++;linePoints[linePoints.length-1]=new GPoint(objPoint.x,objPoint.y);objLine=new GPolyline(linePoints,color);getGmap().addOverlay(objLine);map.dispLineMarker(objPoint,true);map.dispDrawLineInfo();}});G_LineDrawing=true;$('btnDrawLine').value="終了";$('btnDrawLine').onclick=function(){App.gmap.endDrawLine();};$('gmap2').className='gmap_mode2';Element.show('btnDrawLine');Element.show('btnDrawUndo');Element.show('btnDrawRemove');Element.show('btnDrawRegist');var idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];this.dispLineMarker(new GLatLng(point.y,point.x),true);}
Element.show('EditDraw');this.dispDrawLineInfo();var p=linePoints[linePoints.length-1];getGmap().panTo(new GLatLng(p.y,p.x));},endDrawLine:function(force){if(!confirm("路線図を"+"登録せずに終了してよろしいですか？"+"登録したい場合は、キャンセルを選択してから、登録ボタンを押してください。")&&!force){return;}
if(this.drawLineListener!=null){GEvent.removeListener(this.drawLineListener);}
$('btnDrawLine').value="開始";$('btnDrawLine').onclick=function(){App.gmap.startDrawLine();};$('gmap2').className='gmap_mode1';G_LineDrawing=false;Element.show('btnDrawLine');Element.hide('btnDrawUndo');Element.hide('btnDrawRemove');Element.hide('btnDrawRegist');$('lineDrawMessage').innerHTML="再度路線図を引く場合は「開始」をクリックしてください。路線図を登録するには「登録」をクリックします。";this.removeLineMarker();Element.hide('EditDraw');},undoDrawLine:function(){if(linePoints==null)return;if(linePoints.length==0)return;linePoints.pop();getGmap().removeOverlay(objLine);objLine=new GPolyline(linePoints,this.lineColor);getGmap().addOverlay(objLine);this.dispDrawLineInfo();var idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];this.dispLineMarker(new GLatLng(point.y,point.x),true);}},removeDrawLine:function(){if(linePoints==null)return;if(linePoints.length==0)return;linePoints=new Array();getGmap().removeOverlay(objLine);objLine=null;this.dispDrawLineInfo();this.removeLineMarker();},formatPointNumber:function(num){if(num<10){num="00"+num;}
else if(num<100){num="0"+num;}
return num;},dispDrawLineInfo:function(){Element.show('EditDraw');var el=$('EditDraw');el.innerHTML="";var ul=document.createElement("ul");ul.id="EditDrawUl";for(var i=0;i<linePoints.length;i++){var li=document.createElement("li");var input=document.createElement("input");input.type="checkbox";input.value=i;li.appendChild(input);li.appendChild(document.createTextNode("　"));li.setAttribute("lat",linePoints[i].x);li.setAttribute("lng",linePoints[i].y);li.appendChild(document.createTextNode("座標:"+this.formatPointNumber(i)));li.appendChild(document.createTextNode("　"));a=document.createElement("a");a.appendChild(document.createTextNode("[位置]"));a.setAttribute("idx",i);a.href="#";a.onclick=function(){var idx=this.getAttribute("idx");App.gmap.dispLinePoint(idx);return false;}
li.appendChild(a);li.appendChild(document.createTextNode("　"));a=document.createElement("a");a.appendChild(document.createTextNode("[削除]"));a.setAttribute("idx",i);a.href="#";a.onclick=function(){var idx=this.getAttribute("idx");App.gmap.removeLinePoint(idx);return false;}
li.appendChild(a);li.appendChild(document.createTextNode("　"));a=document.createElement("a");a.appendChild(document.createTextNode("[位置移動]"));a.setAttribute("idx",i);a.href="#";a.onclick=function(){var idx=this.getAttribute("idx");App.gmap.moveLinePoint(idx);return false;}
li.appendChild(a);li.appendChild(document.createTextNode("　"));ul.appendChild(li);}
el.appendChild(ul);var map=this;var input=document.createElement("input");input.type="button";input.className="btn";input.value="選択を削除";input.id="btnselectdel";var map=this;input.onclick=function(){var checks=$('EditDraw').getElementsByTagName("input");for(var i=0;i<checks.length;i++){if(checks[i].type!="checkbox")continue;if(checks[i].checked){linePoints.splice(checks[i].value,1);}}
if(objLine!=null){map.map.removeOverlay(objLine);objLine=new GPolyline(linePoints,G_LineColor);map.map.addOverlay(objLine);}
map.dispDrawLineInfo();map.removeLineMarker();var idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];map.dispLineMarker(new GLatLng(point.y,point.x),true);}}
el.appendChild(input);$("btnselectdel").focus();},sortLines:function(){LinePoints=new Array();var li=$('EditDrawUl').getElementsByTagName("li");for(var i=0;i<li.length;li++){var lat=li[i].getAttribute("lat");var lng=li[i].getAttribute("lng");linePoints.length++;linePoints[linePoints.length-1]=new GPoint(lat,lng);}
this.removeLineMarker();if(objLine!=null){this.map.removeOverlay(objLine);objLine=new GPolyline(linePoints,G_LineColor);this.map.addOverlay(objLine);}
var idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];this.dispLineMarker(new GLatLng(point.y,point.x),true);}},dispLinePoint:function(idx){var point=new GLatLng(linePoints[idx].y,linePoints[idx].x);this.dispLineMarker(point,false);this.map.panTo(point);return false;},removeLinePoint:function(idx){var point=new GLatLng(linePoints[idx].y,linePoints[idx].x);this.dispLineMarker(point,false);this.map.panTo(point);if(confirm("この座標を削除します。よろしいですか？")==false){var idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];this.dispLineMarker(new GLatLng(point.y,point.x),true);}
return;}
linePoints.splice(idx,1);if(objLine!=null){this.map.removeOverlay(objLine);objLine=new GPolyline(linePoints,G_LineColor);this.map.addOverlay(objLine);}
this.dispDrawLineInfo();this.removeLineMarker();var idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];this.dispLineMarker(new GLatLng(point.y,point.x),false);}},moveLinePoint:function(idx){var point=new GLatLng(linePoints[idx].y,linePoints[idx].x);this.map.panTo(point);this.dispLineMarker(point,true);var marker=this.pointMarker;var map=this;var dragendHandle=GEvent.addListener(marker,'dragend',function(){var point=marker.getPoint();linePoints[idx]=new GPoint(point.x,point.y);map.dispDrawLineInfo();map.removeLineMarker();if(objLine!=null){map.map.removeOverlay(objLine);objLine=new GPolyline(linePoints,G_LineColor);map.map.addOverlay(objLine);}
idx=linePoints.length-1;if(idx>=0){var point=linePoints[idx];map.dispLineMarker(new GLatLng(point.y,point.x),false);}});this.map.panTo(point);},registDrawLine:function(){var url="/calta/servlet/RailLine?method=update&";var prm='railid='+G_busRailNoid;for(var i=0;i<linePoints.length;i++){prm+='&point='+linePoints[i].y+","+linePoints[i].x;}
var dlg=new WaitDialog();dlg.show("路線図情報を更新しています。");var AjaxRequest=new Ajax.Request(url,{method:'post',parameters:prm,onComplete:function(request){dlg.close();var points=eval('('+request.responseText+')');linePoints=new Array();for(i=0;i<points.points.length;i++){gp=new GPoint(points.points[i].lng,points.points[i].lat);linePoints.length+=1;linePoints[linePoints.length-1]=gp;}
if(objLine!=null){getGmap().removeOverlay(objLine);}
objLine=new GPolyline(linePoints,G_LineColor);getGmap().addOverlay(objLine);alert("路線図の登録が完了しました。");App.gmap.endDrawLine(true);},onTimeout:function(req,ajaxComponent){dlg.close();alert("タイムアウトが発生しました");}});},dispLineMarker:function(point,bDraggable){if(this.pointMarker!=null){this.map.removeOverlay(this.pointMarker);}
this.pointMarker=new GMarker(point,{draggable:bDraggable,title:point,clickable:true,bouncy:bDraggable});this.map.addOverlay(this.pointMarker);},removeLineMarker:function(){if(this.pointMarker!=null){this.map.removeOverlay(this.pointMarker);}
this.pointMarker=null;}}
function lineRegist(){var busstops=$('busstopList');var li=busstops.getElementsByTagName('li');for(var i=0;i<li.length;i++){var busstop=li[i].getElementsByTagName('span');alert(busstop[0].innerHTML);}}
var BusStopInfo=Class.create();BusStopInfo.prototype={initialize:function(idx,marker){this.iconid=null;this.marker=marker;this.isnew=false;if(marker!=null){this.ldmkid=marker.ldmkid;this.name=marker.name;this.iconid=marker.iconid;}
else{this.ldmkid=-1;this.name="";if(G_highwayBus==false){this.iconid=21;}
else{this.iconid=22;}
this.isnew=true;}
this.idx=idx;},getElement:function(){var idx=this.idx;var ldmkid=this.ldmkid;if(this.list!=null){this.list.innerHTNL="";}
this.list=null;this.li=document.createElement('li');this.li.setAttribute("ldmkid",this.ldmkid);this.li.setAttribute("idx",idx);this.li.setAttribute("id","busli_"+idx);this.div=document.createElement('div');this.div.className="busstop1";this.div2=null;this.div2=document.createElement('div');this.div2.className="busregistButtonts";var div2=this.div2;var div=this.div;var li=this.li;if(this.isnew==false){this.div.onmouseover=function(){try{$('updown').parentNode.removeChild($('updown'));}catch(e){}
this.className="busstop2";var p=document.createElement("p");p.align="right";p.id="updown";li.appendChild(p);var more=document.createElement("input");more.type="button";more.value="詳細";more.className="btn";more.id="moreinfo";more.setAttribute("idx",idx);more.setAttribute("ldmkid",ldmkid);more.onclick=function(){var idx=this.getAttribute("idx");var ldmkid=this.getAttribute("ldmkid");try{$('businfomore').parentNode.removeChild($('businfomore'));}
catch(e){}
var url="/calta/servlet/BusStopInfo?ldmkid="+ldmkid;var ajax=new Ajax.Request(url,{method:"post",onComplete:function(request){var bus=eval("("+request.responseText+")");var marker=App.busStopInfoList.busStopArray[idx].marker;var div=document.createElement("div");div.className="businfomore";div.setAttribute("idx",idx);div.id="businfomore";var input1=document.createElement("input");input1.type="checkbox";input1.id=idx+"_more1";div.appendChild(input1);div.appendChild(document.createTextNode("駐車場あり"));var input2=document.createElement("input");input2.type="checkbox";input2.id=idx+"_more2";div.appendChild(input2);div.appendChild(document.createTextNode("駐輪場あり"));div.appendChild(document.createElement("br"));var input3=document.createElement("input");input3.type="checkbox";input3.id=idx+"_more3";div.appendChild(input3);div.appendChild(document.createTextNode("屋根あり"));var input4=document.createElement("input");input4.type="checkbox";input4.id=idx+"_more4";div.appendChild(input4);div.appendChild(document.createTextNode("ベンチあり"));div.appendChild(document.createElement("br"));div.appendChild(document.createTextNode("備考"));div.appendChild(document.createElement("br"));var textarea=document.createElement("textarea");textarea.rows=4;textarea.cols=20;textarea.id=idx+"_description";textarea.style.cssText="font-size:10pt";div.appendChild(textarea);var p=document.createElement("p");var input=document.createElement("input");input.type="button";input.id=idx+"_moresubmit";input.value="登録";input.className="btn";input.setAttribute("idx",idx);input.onclick=function(){var idx=this.getAttribute("idx");var ldmkid=App.busStopInfoList.busStopArray[idx].ldmkid;var busUpdater=new BusStopUpdater([{"param":"parking","value":$(idx+"_more1").checked},{"param":"bicycle","value":$(idx+"_more2").checked},{"param":"roof","value":$(idx+"_more3").checked},{"param":"bench","value":$(idx+"_more4").checked},{"param":"description","value":$(idx+"_description").value},{"param":"ldmkid","value":ldmkid}]);busUpdater.update(function(marker){$('updown').removeChild(div);});};p.appendChild(input);input=document.createElement("input");input.type="button";input.className="btn";input.id=idx+"_morecancel";input.value="取消";input.onclick=function(){$('updown').removeChild(div);};p.appendChild(input);div.appendChild(p);$('updown').appendChild(div);if(bus.parking=="true"){$(idx+"_more1").checked=true;}
if(bus.bicycle=="true"){$(idx+"_more2").checked=true;}
if(bus.roof=="true"){$(idx+"_more3").checked=true;}
if(bus.bench=="true"){$(idx+"_more4").checked=true;}
$(idx+"_description").value=bus.description==null?"":bus.description;$(idx+"_moresubmit").focus();}});}
p.appendChild(more);var up=document.createElement("input");up.type="button";up.value="↑";up.id="up";up.className="btn";up.setAttribute("idx",idx);up.onclick=function(){var idx=this.getAttribute("idx");App.busStopInfoList.exchange(0,idx);}
var down=document.createElement("input");down.type="button";down.value="↓";down.id="down";down.className="btn";down.setAttribute("idx",idx);down.onclick=function(){var idx=this.getAttribute("idx");App.busStopInfoList.exchange(1,idx);}
if(idx!=0){p.appendChild(up);}
if(idx!=$('busstopList').getElementsByTagName('li').length-1){p.appendChild(down);}};this.div.onmouseout=function(){this.className="busstop1";};}
var img=document.createElement('img');var cicon=App.iconManager.getAt(this.iconid);img.src=cicon.icon.image;img.setAttribute('width','10');img.setAttribute('height','17');var span=document.createElement('span');span.innerHTML='  '+(this.idx+1)+" "+this.name;var bs=this;span.ondblclick=function(){bs.inplace(this);};span.className="busstopName";this.a1=document.createElement('a');this.a1.href='#';this.a1.setAttribute("ldmkid",this.ldmkid);this.a1.setAttribute("idx",idx);this.a2=null;if(this.marker==null||this.marker.point==null||this.marker.point.x==-81){this.a1.onclick=function(){bs.registBusStop(this.getAttribute('idx'));return false;};this.a1.innerHTML='地図登録';}
else{this.a1.onclick=function(){bs.panTo(this.getAttribute('idx'));return false;};this.a1.innerHTML='地図表示';this.a2=document.createElement('a');this.a2.setAttribute("ldmkid",this.ldmkid);this.a2.setAttribute("idx",idx);this.a2.setAttribute("title","路線から除外します");this.a2.href='#';this.a2.onclick=function(){bs.dropout(this.getAttribute('idx'));return false;};this.a2.innerHTML='路線から除外';}
this.div.appendChild(img);this.div.appendChild(span);this.a3=null;if(this.marker!=null&&this.marker.point!=null&&this.marker.point.x!=-81){this.a3=document.createElement('a');this.a3.setAttribute("ldmkid",this.ldmkid);this.a3.setAttribute("idx",idx);this.a3.href='#';this.a3.onclick=function(){bs.move(this.getAttribute('idx'));return false;};this.a3.innerHTML='位置移動';}
this.a4=null;this.div.appendChild(img);this.div.appendChild(span);if(this.isnew==true){this.inplace(span);}
if(this.a1!=null&&this.isnew==false){this.div2.appendChild(document.createTextNode("[ "));this.div2.appendChild(this.a1);this.div2.appendChild(document.createTextNode("] "));if(this.marker==null||this.marker.point==null||this.marker.point.x==-81){var img=document.createElement("img");img.src="/bybus/images/icon_busstop_s_nomap.gif"
this.div2.appendChild(img);}}
if(this.a2!=null&&this.isnew==false){this.div2.appendChild(document.createTextNode("[ "));this.div2.appendChild(this.a2);this.div2.appendChild(document.createTextNode("] "));}
if(this.a3!=null&&this.isnew==false){this.div2.appendChild(document.createTextNode("[ "));this.div2.appendChild(this.a3);this.div2.appendChild(document.createTextNode("] "));}
if(this.a4!=null&&this.isnew==false){this.div2.appendChild(document.createTextNode("[ "));this.div2.appendChild(this.a4);this.div2.appendChild(document.createTextNode("] "));}
this.div.appendChild(this.div2);this.li.appendChild(this.div);return this.li;},getIconPath:function(iconid){for(var i=0;i<icons.length;i++){if(iconid==icons[i].iconid){return icons[i].image;}}
return"";},inplace:function(obj){obj.ondblclick=null;var txt=obj.innerHTML;txt=this.name;if(txt!=null){txt=Trim(txt);}
else{txt='';}
obj.innerHTML='';var input=document.createElement('input');input.setAttribute('type','text');input.setAttribute('value',txt);input.setAttribute('orgvalue',txt);var id="busname_"+this.idx;input.id=id;input.name=id;input.className="mminput";input.onfocus=function(){this.className="mminput_active";};input.onblur=function(){this.className="mminput";};obj.appendChild(input);var btn=document.createElement('input');btn.setAttribute('type','button');btn.setAttribute('value','保存');btn.className="btn";var bs=this;btn.onclick=function(){bs.outplace(this);};var btn2=document.createElement('input');btn2.setAttribute('type','button');btn2.setAttribute('value','取消');btn2.className="btn";btn2.onclick=function(){bs.outplaceCancel(this);};obj.appendChild(btn);obj.appendChild(btn2);if(this.isnew==true){$('btlistend').focus();}},outplace:function(obj){var span=obj.parentNode;var bs=this;var input=span.getElementsByTagName('input');if(input[0].value.length==0){return;}
span.ondblclick=function(){bs.inplace(this);};this.name=input[0].value;span.innerHTML=(parseInt(this.idx)+1)+" "+input[0].value;if(this.isnew==true){this.div2.appendChild(document.createTextNode("[ "));this.div2.appendChild(this.a1);this.div2.appendChild(document.createTextNode(" ]"));if(this.a2!=null){this.div2.appendChild(this.a2);}
if(this.a3!=null){this.div2.appendChild(this.a3);}
if(this.a4!=null){this.div2.appendChild(this.a4);}
this.isnew=false;}
var busUpdater=new BusStopUpdater([{"param":"name","value":this.name},{"param":"ldmkid","value":this.ldmkid},{"param":"description","value":' '}]);var bus=this;busUpdater.update(function(marker){Element.show('btnBusStopNew');var array=App.gmap.landMarkManger.landmarkArray;if(bus.ldmkid==-1){bus.ldmkid=marker.ldmkid;var li=$('busstopList').getElementsByTagName('li');for(var i=0;i<li.length;i++){if(li[i].getAttribute('ldmkid')==-1){li[i].setAttribute('ldmkid',bus.ldmkid);}}}
else{bus.ldmkid=marker.ldmkid;for(var i=0;i<array.length;i++){if(array[i].ldmkid==bus.ldmkid){array[i].removeOverlay();array[i]=marker;array[i].addOverlay(false);return;}}}});},outplaceCancel:function(obj){Element.show('btnBusStopNew');var span=obj.parentNode;var bs=this;span.ondblclick=function(){bs.inplace(this);};var input=span.getElementsByTagName('input');span.innerHTML=input[0].getAttribute('orgvalue');if(this.isnew==true){this.dropout(this.idx);}
Element.show("btnBusStopNew");},dropout:function(idx){var busstops=$('busstopList');var li=busstops.getElementsByTagName('li');for(var i=0;i<li.length;i++){if(li[i].getAttribute('idx')==idx){busstops.removeChild(li[i]);break;}}
App.busStopInfoList.remove(this);App.busStopInfoList.renumber(this);},getLdmkid:function(idx){var busstops=$('busstopList');var li=busstops.getElementsByTagName('li');for(var i=0;i<li.length;i++){if(li[i].getAttribute('idx')==idx){return li[i].getAttribute('ldmkid');}}
return-1;},getMarker:function(idx){var ldmkid=getLdmkid(idx);},remove:function(idx){App.gmap.showStop=true;if(this.marker!=null){getGmap().setCenter(this.marker.point);}
var ldmkid=this.getLdmkid(idx);App.gmap.landMarkManger.singleDisp(ldmkid);if(confirm('バス停「'+this.name+'」を削除します。よろしいですか？')==false){App.gmap.landMarkManger.allDisp();App.gmap.showStop=true;return;}
this.dropout(idx);App.gmap.showStop=true;App.gmap.landMarkManger.allDisp();if(this.marker!=null){getGmap().removeOverlay(this.marker.marker);}},move:function(idx){App.gmap.showStop=true;if(this.marker!=null){getGmap().setCenter(this.marker.point);}
var ldmkid=this.getLdmkid(idx);App.gmap.landMarkManger.singleDisp(ldmkid);App.gmap.landMarkManger.enableDragging(ldmkid);App.cursor=new IconCursor("RegistCursor");App.cursor.show("バス停をドラッグして移動します。","/calta/icons/ico_bustop_r.gif");},registBusStop:function(idx){App.gmap.showStop=true;if(this.marker!=null){if(this.marker.point.x!=-81){getGmap().setCenter(this.marker.point);}}
var ldmkid=this.getLdmkid(idx);App.gmap.landMarkManger.singleDisp(ldmkid);App.gmap.landMarkManger.enableRegistNewPoint(ldmkid);App.cursor=new IconCursor("RegistCursor");App.cursor.show("バス停の位置を地図上でクリックします。","/calta/icons/ico_bustop_r.gif");},panTo:function(ldmkid){getGmap().panTo(this.marker.point);}}
var BusStopInfoList=Class.create();BusStopInfoList.prototype={initialize:function(element){element.innerHTML='';this.busStopArray=new Array();var ul=document.createElement('ul');ul.setAttribute('id','busstopList');element.appendChild(ul);try{Sortable.destroy($('busstopList'));}
catch(e){}
var ul=$('busstopList');ul.innerHTML="";this.ullist=null;},add:function(marker){if(G_LineDrawing==true)return;try{Sortable.destroy($('busstopList'));}
catch(e){}
var ul=$('busstopList');for(var i=0;i<App.gmap.landMarkManger.getLength();i++){var ldmk=App.gmap.landMarkManger.getAt(i);if(marker==ldmk.marker){for(var j=0;j<this.busStopArray.length;j++){if(ldmk.ldmkid==this.busStopArray[j].ldmkid){busListSortable();return 0;}}
var bus=new BusStopInfo(this.busStopArray.length,ldmk);bus.list=this;this.busStopArray.push(bus);ul.appendChild(bus.getElement());}}
busListSortable();$("btlistend").focus();return 1;},remove:function(businfo){for(var i=0;i<this.busStopArray.length;i++){if(businfo==this.busStopArray[i]){this.busStopArray.splice(i,1);break;}}},dispAll:function(lst){try{Sortable.destroy($('busstopList'));}
catch(e){}
var ul=$('busstopList');for(var i=0;i<list.length;i++){var marker=new CaltaLandMark(list[i].ldmkid,list[i].objtype,list[i].iconid,list[i].name,null,null);marker.zoommin=list[i].zoommin;marker.zoommax=list[i].zoommax;try{marker.parking=list[i].parking;marker.bicycle=list[i].bicycle;marker.roof=list[i].roof;marker.bench=llist[i].bench;}
catch(e){}
var bus=new BusStopInfo(i,marker);bus.list=this;this.busStopArray.push(bus);ul.appendChild(bus.getElement());}
busListSortable();},addArea:function(){if(G_LineDrawing==true)return;try{Sortable.destroy($('busstopList'));}
catch(e){}
for(i=0;i<App.gmap.landMarkManger.getLength();i++){var marker=App.gmap.landMarkManger.getAt(i);var bus=new BusStopInfo(this.busStopArray.length,marker);for(var j=0;j<this.busStopArray.length;j++){var bus2=this.busStopArray[j];if(marker.ldmkid==bus2.ldmkid){bus=null;break;}}
if(bus==null)continue;bus.list=this;this.busStopArray.push(bus);$('busstopList').appendChild(bus.getElement());}
this.renumber();$("btlistend").focus();},allClear:function(){$('busstopList').innerHTML="";this.busStopArray=new Array();},addNew:function(){Element.hide('btnBusStopNew');try{Sortable.destroy($('busstopList'));}
catch(e){}
var ul=$('busstopList');var bus=new BusStopInfo(this.busStopArray.length,null);bus.list=this;this.busStopArray.push(bus);ul.appendChild(bus.getElement());busListSortable();$("btlistend").focus();},renumber:function(){var ul=$('busstopList');var li=ul.getElementsByTagName('li');for(var i=0;i<li.length;i++){var ldmkid=li[i].getAttribute("ldmkid");for(var j=0;j<this.busStopArray.length;j++){if(ldmkid==this.busStopArray[j].ldmkid){this.busStopArray[j].idx=i;break;}}}
this.busStopArray.sort(compBusInfo);ul.innerHTML="";for(i=0;i<this.busStopArray.length;i++){ul.appendChild(this.busStopArray[i].getElement());}
busListSortable();},reverse:function(){wdlg=new WaitDialog();wdlg.show("しばらくお待ちください");this.busStopArray.reverse();for(var i=0;i<this.busStopArray.length;i++){this.busStopArray[i].idx=i;}
$('busstopList').innerHTML="";for(i=0;i<this.busStopArray.length;i++){$('busstopList').appendChild(this.busStopArray[i].getElement());}
busListSortable();wdlg.close();},exchange:function(updown,idx){var idx=parseInt(idx);var ul=$('busstopList');var li=ul.getElementsByTagName('li');var s;var d;if(updown==0){s=li[idx];d=li[idx-1];}
else{s=li[idx];if(idx+2>=li.length){ul.removeChild(s);ul.appendChild(s);this.renumber();return;}
else{d=li[idx+2];}}
ul.removeChild(s);ul.insertBefore(s,d);this.renumber();},listUpdate:function(){var list="method=updatelist&list=";for(var i=0;i<this.busStopArray.length;i++){list+=this.busStopArray[i].ldmkid;if(i+1!=this.busStopArray.length){list+=","}}
list+="&railid="+G_busRailNoid;dlg=new WaitDialog();dlg.show("路線のバス停情報を更新しています。");var url="/calta/servlet/BusRailInfo?"+list;var AjaxRequest=new Ajax.Request(url,{method:'post',onComplete:function(request){dlg.close();var res=eval('('+request.responseText+')');updated=false;alert("バス停リストの登録が完了しました。");},onTimeout:function(req,ajaxComponent){dlg.close();alert("タイムアウトが発生しました");}});}}
function compBusInfo(bus1,bus2){return(bus1.idx-bus2.idx);}
var listEndbutton=null;function busListSortable(){var idx=App.busStopInfoList.busStopArray.length;idx-=1;if(isIE()==true){}
listEndbutton=document.getElementById("btlistend");if(listEndbutton){$("busstopList").removeChild(listEndbutton);}
listEndbutton=document.createElement("input");listEndbutton.type="button";listEndbutton.id="btlistend";$("busstopList").appendChild(listEndbutton);}
function chengeRegOption(op){Element.show('railmap');$('buslines').visualEffect("Appear");$('lineinfoheader').innerHTML="";var head=document.createElement("div");head.id="lineinfoheaderdiv";head.innerHTML='<font color="'+G_LineColor+'">■</font>'
+G_busRailName+":"+G_busRailNoName+":"
+G_busDestination+"<br/>&nbsp;&nbsp;"+G_busOrgName+"&nbsp;&nbsp;"
head.style.border="solid 2px "+G_LineColor;$('lineinfoheader').appendChild(head);var el=document.createElement("input");el.type="button";el.value="路線基本情報変更";el.onclick=function(){$('editrailname').value=G_busRailName;$('editrailno').value=G_busRailNoName;$('editdesitination').value=G_busDestination;$('editcolor').value=G_LineColor;Element.show("editrailinfodiv");}
head.appendChild(el);App.busStopInfoList=new BusStopInfoList($('busstopsDiv'));Element.show('btnDrawLine');Element.hide('btnDrawUndo');Element.hide('btnDrawRemove');Element.hide('btnDrawRegist');updated=true;$('lineDrawMessage').innerHTML="路線図を引く場合は「開始」をクリックしてください。路線図を引かなくても路線登録は可能です。";if(op==1){}
else{Element.hide('btnBusStopNew');$('busstopsDiv').innerHTML='';var txt=document.createElement('textarea');txt.setAttribute('id','textBusstops');txt.setAttribute('rows','20');txt.setAttribute('cols','30');var btn=document.createElement('input');btn.setAttribute('type','button');btn.setAttribute('value','確定');btn.setAttribute('id','butonbusLineReg');btn.onclick=function(){busLineReg();}
var btn2=document.createElement('input');btn2.setAttribute('type','button');btn2.setAttribute('value','取消');btn2.setAttribute('id','butonbusLineCencel');btn2.onclick=function(){busLineRegCancel();}
$('busstopsDiv').appendChild(txt);$('busstopsDiv').appendChild(document.createElement('br'));$('busstopsDiv').appendChild(btn);$('busstopsDiv').appendChild(btn2);}}
function busLineRegCancel(){$('busstopsDiv').innerHTML='';Element.show('btnBusStopNew');}
function busLineReg(){var str=$F('textBusstops')
var busstop;if(str.length==0){return;}
var url='/bybus/servlet/GetBusStop';var prm='method=regist';prm=prm+'&busorg='+G_busOrgid;prm=prm+'&buslineid='+G_busRailid;prm=prm+'&data='+str;prm=encodeURI(prm);var callback='App.busStopInfoList.dispAll';App.busStopInfoList=new BusStopInfoList($('busstopsDiv'));getJSONP(url,prm,callback);Element.show('btnBusStopNew');}
function regLineData(){if(G_copyRefBusRailNoid>=0){G_busRailNoName=$('kno').value;G_busDestination=$('destination').value;if(G_busRailNoName.length==0&&G_busDestination.length==0){alert("系統と行先のどちらかは必ず入力してください。");return;}}
chengeRegOption(1);Element.show('btnBusStopNew');Element.hide('lineInfoDiv');App.gmap=new ByBusMap();var url="/calta/servlet/BusRailInfo";var prm='&orgid='+G_busOrgid;prm+='&orgname='+G_busOrgName;prm+='&railid='+G_busRailNoid;prm+='&railno='+G_busRailNoName;prm+='&railname='+G_busRailName;prm+='&destination='+G_busDestination;prm+='&color='+G_LineColor.substring(1);prm+='&lat='+G_prefPoint.y;prm+='&lng='+G_prefPoint.x;prm+='&refrailid='+G_copyRefBusRailNoid;prm+='&method=update';G_pref=$('todouhuken').value;prm+='&pref='+G_pref;url=url+"?"+encodeURI(prm);dlg=new WaitDialog();dlg.show("路線のバス停情報を取得しています。");var AjaxRequest=new Ajax.Request(url,{method:'post',onTimeout:function(req,ajaxComponent){dlg.close();alert("タイムアウトが発生しました");},onComplete:function(request){dlg.close();var res=eval('('+request.responseText+')');try{Sortable.destroy($('busstopList'));}
catch(e){}
G_busRailNoid=res.railid;$('busstopList').innerHTML="";App.busStopInfoList.busStopArray=new Array();for(i=0;i<res.busstops.length;i++){var latlng=new GLatLng(res.busstops[i].lat,res.busstops[i].lng);if(i==0){getGmap().setCenter(latlng);}
var marker=new CaltaLandMark(res.busstops[i].ldmkid,res.busstops[i].objtype,res.busstops[i].iconid,res.busstops[i].name,latlng,null);marker.zoommin=res.busstops[i].zoommin;marker.zoommax=res.busstops[i].zoommax;try{marker.parking=res.busstops[i].parking;marker.bicycle=res.busstops[i].bicycle;marker.bench=res.busstops[i].bench;marker.roof=res.busstops[i].roof;}
catch(e){}
var bus=new BusStopInfo(i,marker);bus.list=App.busStopInfoList;App.busStopInfoList.busStopArray.push(bus);$('busstopList').appendChild(bus.getElement());}
busListSortable();App.busStopInfoList.renumber();}});url="/calta/servlet/RailLine?method=select&";if(G_copyRefBusRailNoid>0){prm='railid='+G_copyRefBusRailNoid;}
else{prm='railid='+G_busRailNoid;}
AjaxRequest=new Ajax.Request(url,{method:'post',parameters:prm,onComplete:function(request){var points=eval('('+request.responseText+')');linePoints=new Array();for(i=0;i<points.points.length;i++){gp=new GPoint(points.points[i].lng,points.points[i].lat);linePoints.length+=1;linePoints[linePoints.length-1]=gp;}
if(objLine!=null){getGmap().removeOverlay(objLine);}
objLine=new GPolyline(linePoints,G_LineColor);getGmap().addOverlay(objLine);}});}
function IsRegNew(){if(G_copyRefBusRailNoid!=-1){Element.hide('btncopy');Element.hide('btncopy2');return;}
if(G_busOrgid==-1||G_busRailid==-1||G_busRailNoid==-1){$('btnreg').value="路線情報の登録";return true;}
else{$('btnreg').value="登録バス停の参照・修正";return false;}}
var wdlg=null;var BusOrgList=Class.create();BusOrgList.prototype={initialize:function(element,pref){this.element=element;this.getList(pref);this.selectId=-1;this.dlg=null;},getList:function(pref){if(pref.length==0)return;Element.hide(this.element);var geocode=new GClientGeocoder();wdlg=new WaitDialog();wdlg.show("路線情報を取得しています。");var lst=this;geocode.getLatLng(pref,function(point){if(point!=null){var url='/calta/servlet/GetBusOrgInfo?mode=pref&';var prm='lat='+point.y+'&lng='+point.x;G_prefPoint=point;var ajax=new Ajax.Request(url+prm,{method:"post",onComplete:function(request){wdlg.close();var res=request.responseXML;var org=res.getElementsByTagName("org");lst.dispList(org);},onTimeout:function(req,ajaxComponent){wdlg.close();alert("タイムアウトが発生しました");}});}});},dispList:function(org){var ul=document.createElement("div");$(this.element).innerHTML="";var form=document.createElement('form');form.name="busorgform";form.id="busorgform";$(this.element).appendChild(form);var i=0;for(i=0;i<org.length;i++){var name=org[i].getAttribute("name");var id=org[i].getAttribute("buscompanyid");var li=document.createElement('p');if(i==0||G_busOrgid==org[i].buscompanyid){li.innerHTML='<input checked="true" type="radio" name="busorgradio" txt="'+name+'" value="'+id+'">';}
else{li.innerHTML='<input type="radio" name="busorgradio" txt="'+name+'" value="'+id+'">';}
var nm=document.createTextNode('　'+name);li.appendChild(nm);var url=org[i].getAttribute("url");if(url>0){li.appendChild(document.createTextNode('　'));var a=document.createElement('a');a.href=url;a.target='_blank';var nm=document.createTextNode('[WEB]');a.appendChild(nm);li.appendChild(a);}
ul.appendChild(li);}
var li=document.createElement('p');li.innerHTML='<input type="radio" name="busorgradio" size="32" txt="" value="-1">';var nm=document.createTextNode("　その他　");li.appendChild(nm);ul.appendChild(li);txt=document.createElement('input');txt.type="text";txt.id="busorgnm";li.appendChild(txt);ul.appendChild(li);if(G_busOrgid==-1){txt.value=G_busOrgName;}
form.appendChild(ul);form.appendChild(document.createElement('br'));var p=document.createElement('p');p.align="right";var lst=this;input=document.createElement('input');input.type="button";input.value="　　OK　　";input.id="btnbusorg";input.className="btn";input.onclick=function(){lst.submit();};p.appendChild(input);input=document.createElement('input');input.type="button";input.value="取消";input.id="btnbusorgCancel";input.className="btn";input.onclick=function(){lst.cancel();};p.appendChild(input);form.appendChild(p);$(this.element).appendChild(form);$('kouho1').value="確定";$('kouho1').onclick=function(){List_BusOrg.submit();}
Element.show(this.element);},submit:function(){var radios=$('busorgform').getElementsByTagName("input");for(var i=0;radios.length;i++){if(radios[i].type!="radio")continue;if(radios[i].checked){var txt;if(radios[i].value!=-1){txt=radios[i].getAttribute('txt');}
else{txt=$('busorgnm').value;}
if(txt.length==0)return;G_busOrgid=radios[i].value;G_busOrgName=txt;$('busorg').value=txt;break;}
showRegButton();}
$(this.element).visualEffect("BlindUp");$('kouho1').value="候補";$('kouho1').onclick=function(){dispBusOrgList($('todouhuken').value);}
IsRegNew();},cancel:function(){$(this.element).visualEffect("BlindUp");$('kouho1').value="候補";$('kouho1').onclick=function(){dispBusOrgList($('todouhuken').value);}}}
var BusLineList=Class.create();BusLineList.prototype={initialize:function(element,orgid){this.element=element;this.getList(orgid);},getList:function(orgid){Element.hide(this.element);var url='/calta/servlet/BusRailInfo';var prm='method=select&orgid='+orgid;url=url+"?"+prm;var callback='List_BusLine.dispList';var lst=this;dlg=new WaitDialog();dlg.show("路線情報を取得しています。");var ajax=new Ajax.Request(url,{method:"post",onComplete:function(request){dlg.close();var res=eval("("+request.responseText+")");lst.dispList(res);},onTimeout:function(req,ajaxComponent){dlg.close();alert("タイムアウトが発生しました");}});},dispList:function(res){busLines=res;var ul=document.createElement("div");$(this.element).innerHTML="";var form=document.createElement('form');form.name="busLineform";form.id="busLineform";$(this.element).appendChild(form);var i=0;for(i=0;i<busLines.count;i++){var lines=busLines.railnames;var li=document.createElement('p');if(G_busRailid==lines[i].id){li.innerHTML='<input checked="true" type="radio" name="busLineradio" txt="'+lines[i].name+'" value="'+lines[i].id+'">';}
else{li.innerHTML='<input type="radio" name="busLineradio" txt="'+lines[i].name+'" value="'+lines[i].id+'">';}
var nm=document.createTextNode('　'+lines[i].name);li.appendChild(nm);ul.appendChild(li);}
var li=document.createElement('p');if(G_busRailid!=-1){li.innerHTML='<input type="radio" name="busLineradio" size="32" txt="" value="-1">';}
else{li.innerHTML='<input checked="true" type="radio" name="busLineradio" size="32" txt="" value="-1">';}
var nm=document.createTextNode("　新規追加　");li.appendChild(nm);ul.appendChild(li);txt=document.createElement('input');txt.type="text";txt.id="busLinenm";li.appendChild(txt);ul.appendChild(li);if(G_busRailid==-1){txt.value=G_busRailName;}
form.appendChild(ul);var lst=this;form.appendChild(document.createElement('br'));var p=document.createElement('p');p.align="right";input=document.createElement('input');input.type="button";input.value="　　OK　　";input.id="btnbusLine";input.className="btn";p.appendChild(input);input.onclick=function(){lst.submit();};form.appendChild(p);input=document.createElement('input');input.type="button";input.value="取消";input.className="btn";input.id="btnbusLinceCancel";input.onclick=function(){lst.cancel();};p.appendChild(input);$(this.element).appendChild(form);Element.show(this.element);$('kouho2').value="確定";$('kouho2').onclick=function(){List_BusRail.submit();}},submit:function(){var radios=$('busLineform').getElementsByTagName("input");for(var i=0;radios.length;i++){if(radios[i].type!="radio")continue;if(radios[i].checked){var txt;if(radios[i].value!=-1){txt=radios[i].getAttribute('txt');}
else{txt=$('busLinenm').value;}
if(txt.length==0)return;G_busRailid=radios[i].value;G_busRailName=txt;$('linename').value=txt;break;}}
$(this.element).visualEffect("BlindUp");showRegButton();IsRegNew();$('kouho2').value="候補";$('kouho2').onclick=function(){dispBusLineList();}},cancel:function(){$(this.element).visualEffect("BlindUp");$('kouho2').value="候補";$('kouho2').onclick=function(){dispBusLineList();}}}
var BusLineNoList=Class.create();BusLineNoList.prototype={initialize:function(element,orgid,lineName){this.element=element;this.getList(orgid,lineName);this.lineNumers=null;},getList:function(orgid,lineName){Element.hide(this.element);var url='/calta/servlet/BusRailInfo';var prm='method=select&orgid='+orgid;prm+="&railname="+lineName;url=url+"?"+prm;url=encodeURI(url);this.lineNumbers="";var callback='List_BusLine.dispList';var lst=this;dlg=new WaitDialog();dlg.show("路線情報を取得しています。");var ajax=new Ajax.Request(url,{method:"post",onComplete:function(request){dlg.close();var res=eval("("+request.responseText+")");lst.dispList(res);},onTimeout:function(req,ajaxComponent){dlg.close();alert("タイムアウトが発生しました");}});},dispList:function(res){var ul=document.createElement("div");$(this.element).innerHTML="";var form=document.createElement('form');form.name="busLineNoform";form.id="busLineNoform";$(this.element).appendChild(form);var i=0;for(i=0;i<res.count;i++){this.lineNumbers=res.rails;if(G_copyRefBusRailNoid==res.rails[i].railid)continue;var li=document.createElement('p');if(G_busRailNoid==res.rails[i].railid){li.innerHTML='<input color="'+res.rails[i].color+'" no="'+res.rails[i].railno+'" dist="'+res.rails[i].destination+'" checked="true" type="radio" name="busLineNoradio" value="'+res.rails[i].railid+'">';}
else{li.innerHTML='<input color="'+res.rails[i].color+'" no="'+res.rails[i].railno+'" dist="'+res.rails[i].destination+'" type="radio" name="busLineNoradio" value="'+res.rails[i].railid+'">';}
var color=document.createElement('input');color.type='button';color.value=' ';color.style.background=res.rails[i].color;color.style.width='15px';color.style.height='15px';color.style.border='none 0px #fff';color.style.margin='2px';li.appendChild(color);var nm=document.createTextNode('系統：'+res.rails[i].railno+"："+res.rails[i].destination);li.appendChild(nm);ul.appendChild(li);}
var li=document.createElement('p');if(G_busRailNoid==-1){if(G_LineColor==null)G_LineColor=G_busLineDefaultColor;li.innerHTML='<input color="'+G_LineColor+'" checked="true" type="radio" name="busLineNoradio" size="32" txt="" value="-1">';}
else{li.innerHTML='<input color="'+G_LineColor+'" type="radio" name="busLineNoradio" size="32" txt="" value="-1">';}
var color=document.createElement('input');color.type='button';color.value=' ';if(G_busRailNoid==-1){if(G_LineColor==null)G_LineColor=G_busLineDefaultColor;color.style.background=G_LineColor;}
else{color.style.background=G_busLineDefaultColor;}
color.style.width='15px';color.style.height='15px';color.style.border='none 0px #fff';color.style.margin='2px';li.appendChild(color);var nm=document.createTextNode("新規追加");li.appendChild(nm);ul.appendChild(li);form.appendChild(ul);form.appendChild(document.createElement('br'));var p=document.createElement('p');p.appendChild(document.createTextNode('系統　'));txt=document.createElement('input');txt.type="text";txt.id="busLineNonm";txt.style.left='10px';p.appendChild(txt);form.appendChild(p);if(G_busRailNoid==-1){txt.value=G_busRailNoName;}
p=document.createElement('p');p.appendChild(document.createTextNode('行先　'));txt=document.createElement('input');txt.type="text";txt.id="busLineDist";p.appendChild(txt);form.appendChild(p);if(G_busRailNoid==-1){txt.value=G_busDestination;}
form.appendChild(document.createElement('br'));p=document.createElement('p');p.align="right";var lst=this;input=document.createElement('input');input.type="button";input.value="　　OK　　";input.id="btnbusLineNo";input.className="btn";input.onclick=function(){lst.submit();};p.appendChild(input);input=document.createElement('input');input.type="button";input.value="取消";input.className="btn";input.id="btnbuLineNoCancel";input.onclick=function(){lst.cancel();};p.appendChild(input);form.appendChild(p);$(this.element).appendChild(form);Element.show(this.element);$('kouho3').value="確定";$('kouho3').onclick=function(){List_BusRailNo.submit();}},submit:function(){var radios=$('busLineNoform').getElementsByTagName("input");for(var i=0;i<radios.length;i++){if(radios[i].type!="radio")continue;if(radios[i].checked){var txt1;var txt2;if(radios[i].value!=-1){txt1=radios[i].getAttribute('no');txt2=radios[i].getAttribute('dist');}
else{txt1=$('busLineNonm').value;txt2=$('busLineDist').value;}
if(txt1.length==0&&txt2.length==0){alert("系統と行先のどちらかは必ず入力してください。");return;}
var color=radios[i].getAttribute('color');$('knocolor').style.background=color;$('keidiv').style.border="solid 1px "+color;G_LineColor=color;G_busRailNoid=radios[i].value;G_busRailNoName=txt1;G_busDestination=txt2;$(this.element).visualEffect("BlindUp");$('kno').value=txt1;$('destination').value=txt2;break;}}
IsRegNew();showRegButton();$('kouho3').value="候補";$('kouho3').onclick=function(){dispBusLineNoList();}},cancel:function(){$(this.element).visualEffect("BlindUp");$('kouho3').value="候補";$('kouho3').onclick=function(){dispBusLineNoList();}}}
var ColorSelector=Class.create();ColorSelector.prototype={initialize:function(element){this.busLineColors=busLineColors;this.element=element;Element.hide(this.element);this.element.innerHTML="";var ul=document.createElement("ul");var li;var i;for(i=0;i<this.busLineColors.length;i++){if(i%2==0){li=document.createElement("li");}
var btn=document.createElement("input");btn.type="button";btn.style.background=this.busLineColors[i].value;var lst=this;btn.onclick=function(){lst.submit(this)};btn.style.width="95px";btn.style.height="15px";btn.setAttribute("color",this.busLineColors[i].value);li.appendChild(btn);li.appendChild(document.createTextNode("　"));if(i%2==0){ul.appendChild(li);}}
this.element.appendChild(ul);var p=document.createElement('p');p.appendChild(document.createTextNode('選択したい色をクリックしてください。'));p.appendChild(document.createElement('br'));var btn=document.createElement('input');btn.setAttribute('type','button');btn.setAttribute('value','取消');btn.className="btn";btn.setAttribute('id','colorSelectCancel');var cs=this;btn.onclick=function(){cs.cancel();}
p.style.margin='10px 10px 2px 10px';p.align='right';p.appendChild(btn);this.element.appendChild(p);this.element.visualEffect('Appear');},submit:function(btn){this.element.visualEffect("Fade");this.color=btn.getAttribute("color");$('knocolor').style.background=this.color;$('keidiv').style.border="solid 1px "+this.color;G_LineColor=this.color;var p=$('busLineNoform').getElementsByTagName("p");for(var i=0;i<p.length;i++){var inp=p[i].getElementsByTagName("input");if(inp[0].checked==true){inp[1].style.background=this.color;inp[0].setAttribute('color',this.color);break;}}},cancel:function(){this.element.visualEffect("Fade");},getColor:function(){return this.color;}}
function prefChange(pref){$('busorg').value="";G_busOrgid=-1;G_pref=pref;dispBusOrgList(pref);}
function dispBusOrgList(pref){if(List_BusRail!=null){List_BusRail.cancel();List_BusRail=null;}
if(List_BusRailNo!=null){List_BusRailNo.cancel();List_BusRailNo=null;}
if(List_Color!=null){List_Color.cancel();List_Color=null;}
$('linename').value="";$('kno').value="";$('destination').value="";initLineInfo();List_BusOrg=new BusOrgList($('busOrgdiv'),pref);}
function dispBusLineList(){if(List_BusOrg!=null){List_BusOrg.cancel();List_BusOrg=null;}
if(List_BusRailNo!=null){List_BusRailNo.cancel();List_BusRailNo=null;}
if(List_Color!=null){List_Color.cancel();List_Color=null;}
G_busRailNoid==-1;G_busRailNoName==-1;G_copyRefBusRailNoid=-1;G_busDestination="";$('kno').value="";$('destination').value="";List_BusRail=new BusLineList($('busLinediv'),G_busOrgid);}
function dispColorSelector(){if(List_BusRailNo!=null){List_BusRailNo.submit();List_BusRailNo=null;}
List_Color=new ColorSelector($('colorselect'));}
function dispBusLineNoList(){var orgid=G_busOrgid;var lineName=G_busRailName;G_copyRefBusRailNoid=-1;if(List_BusOrg!=null){List_BusOrg.cancel();List_BusOrg=null;}
if(List_BusRail!=null){List_BusRail.cancel();List_BusRail=null;}
if(List_Color!=null){List_Color.cancel();List_Color=null;}
Element.hide('btnreg');Element.hide('btncopy');Element.hide('btncopy2');List_BusRailNo=new BusLineNoList($('busLineNodiv'),orgid,lineName);}
function bacthRegist(){}
function drawLine(){}
var updated=true;function backMain(){if(updated&&!confirm("路線情報の登録をせずにバス路線選択画面に戻ってよろしいですか？"+"登録したい場合は、キャンセルを選択してから、「路線情報の保存」をクリックしてください。")){return;}
try{App.gmap.endDrawLine(force);}
catch(e){}
initMain();}
function initMain(){G_copyRefBusRailNoid=-1;linePoints=new Array();if(objLine!=null){getGmap().removeOverlay(objLine);objLine=null;}
$('railmap').visualEffect("Fade");$('buslines').visualEffect("Fade");$('lineInfoDiv').visualEffect("Appear");$('busorg').value="";$('kno').value="";$('destination').value="";$('linename').value="";Element.hide('btnreg');initLineInfo();$('copyref').style.padding="0px 0px 0px 0px";Element.show('todouhuken');$('prefName').innerHTML="";$('copyref').innerHTML="";Element.hide('btncopy');Element.hide('btncopy2');}
function initLineInfo(){if(G_copyRefBusRailNoid!=-1){Element.hide('btncopy');Element.hide('btncopy2');return;}
G_busOrgid==-1;G_busRailid==-1;G_busRailNoid==-1;G_busOrgName="";G_busRailName="";G_busDestination="";G_copyRefBusRailNoid=-1;G_LineColor=G_busLineDefaultColor;IsRegNew();var p=$('kno').parentNode;p.removeChild($('kno'));text=document.createElement("input");text.type="text";text.size="32";text.setAttribute("readonly",true);text.id='kno';p.insertBefore(text,p.firstChild);p=$('destination').parentNode;p.removeChild($('destination'));text=document.createElement("input");text.type="text";text.size="32";text.setAttribute("readonly",true);text.id='destination';p.insertBefore(text,p.firstChild);inputInit();Element.show('kouho1');Element.show('kouho2');Element.show('kouho3');}
function regLineCopy(){$('copyref').style.padding="10px 0px 10px 0px";$('copyref').innerHTML='<h3>複写元路線</h3>'+'<p><font color="'+G_LineColor+'">■</font>バス会社　'+G_busOrgName+'　'+G_busRailName+' 系統'+G_busRailNoName+" "+G_busDestination+'</p>';G_copyRefBusRailNoid=G_busRailNoid;G_busRailNoid=-1;G_busRailNoName="";G_busDestination="";Element.hide('btncopy');Element.hide('btncopy2');Element.hide('todouhuken');$('prefName').innerHTML=$('todouhuken').value;var p=$('kno').parentNode;p.removeChild($('kno'));text=document.createElement("input");text.type="text";text.size="32";text.id='kno';p.insertBefore(text,p.firstChild);List_BusRailNo=null;p=$('destination').parentNode;p.removeChild($('destination'));text=document.createElement("input");text.type="text";text.size="32";text.id='destination';p.insertBefore(text,p.firstChild);$('btnreg').value　="路線情報の複写";Element.hide('kouho3');Element.show('btncopy2');inputInit();}
function showRegButton(){if(G_busOrgName.length>0&&G_busRailName.length>0&&(G_busRailNoName.length>0||G_busDestination.length>0)){Element.show('btnreg');if(G_busOrgid==-1||G_busRailid==-1||G_busRailNoid==-1){}
else{Element.show('btncopy');}}
else{Element.hide('btnreg');Element.hide('btncopy');Element.hide('btncopy2');}}
function mapResize(){if($('left').style.width==''||$('left').style.width=='480px'){$('left').style.width='600px';$('gmapdiv2').style.height='400px';$('gmap2').style.height='400px';$('mapResizeButton').value="<< 地図縮小";}
else{$('left').style.width='480px';$('gmapdiv2').style.height='320px';$('gmap2').style.height='320px';$('mapResizeButton').value="地図拡大 >>";}}
function updateRailInfo(){var url="/calta/servlet/BusRailInfo";var prm="";prm+='&railid='+G_busRailNoid;if($('editrailno').value.length==0||$('editdesitination').value.length==0)return;if($('editrailname').value.length==0)return;if($('editcolor').value.length==0)return;if($('editcolor').value[0]!="#"){$('editcolor').value="#"+$('editcolor').value;}
prm+='&railno='+$('editrailno').value;prm+='&railname='+$('editrailname').value;prm+='&destination='+$('editdesitination').value;prm+='&color='+$('editcolor').value.substring(1);prm+='&orgid='+G_busOrgid;prm+='&method=update';url=url+"?"+encodeURI(prm);var dlg1=new WaitDialog();dlg1.show("路線の基本情報を更新しています。");var AjaxRequest=new Ajax.Request(url,{method:'post',onTimeout:function(req,ajaxComponent){dlg1.close();alert("タイムアウトが発生しました。");},onComplete:function(req){dlg1.close();Element.hide('editrailinfodiv');G_busRailName=$('editrailname').value;G_busRailNoName=$('editrailno').value;G_busDestination=$('editdesitination').value;G_LineColor=$('editcolor').value;try{if(linePoints.length>0){if(objLine!=null){getGmap().removeOverlay(objLine);}
objLine=new GPolyline(linePoints,G_LineColor);getGmap().addOverlay(objLine);}}
catch(e){}
$('lineinfoheaderdiv').innerHTML='<font color="'+G_LineColor+'">■</font>'
+G_busRailName+":"+G_busRailNoName+":"
+G_busDestination+"<br/>&nbsp;&nbsp;"+G_busOrgName+"&nbsp;&nbsp;"
$('lineinfoheaderdiv').style.border="solid 2px "+G_LineColor;var el=document.createElement("input");el.type="button";el.value="路線基本情報変更";el.onclick=function(){$('editrailname').value=G_busRailName;$('editrailno').value=G_busRailNoName;$('editdesitination').value=G_busDestination;$('editcolor').value=G_LineColor;Element.show("editrailinfodiv");}
$('lineinfoheaderdiv').appendChild(el);}});}