
var App;var PANEL_HEIGHT=250;var G_PageNo=1;var def_lat=null;var def_lng=null;var def_zoom=null;var def_ldmkid=null;var def_objtype=null;var def_iconid=null;var im=null;function onLoad(){im=new IconManager();im.get("5,6,7,8,9,10,12,13,15",bybusInit);}
function bybusInit(){try{App=new ByBusWebApp();}
catch(e){alert(e);}}
function getGmap(){return App.gmap.map;}
var weatherParameter={"id":"weather","distance":100,"count":3}
var ByBusWebApp=Class.create();ByBusWebApp.prototype={initialize:function(){inputInit();App=this;this.iconManager=im;this.bsManager=new BusStopIconManager();this.bsViewer=new BusStopViewer('busstopview');this.busRail=new BusRail();this.busRailLine=new BusRailLine();if(def_ldmkid==null){getNewBusStops();}
initPlaceEngine();if(def_ldmkid){var cicon=App.iconManager.getAt(def_iconid);if(cicon!=null){var img=document.createElement("img");img.src=cicon.icon.image;img.align="bottom";$('spoticon').appendChild(img);}}
if(GBrowserIsCompatible()){this.gmap=new ByBusMap();}
window.onunload=function(){var cookie=new Cookie();var point=getGmap().getCenter();cookie.set("BYBUS_LAT",point.y,365);cookie.set("BYBUS_LNG",point.x,365);cookie.set("BYBUS_ZOOM",getGmap().getZoom(),365);};getNewSpot();},getWeather:function(){var id=weatherParameter.id;var distance=weatherParameter.distance;var count=weatherParameter.count;var point=getGmap().getCenter();var url='/calta/servlet/GetLandmark?objtype=11&lat='+point.y+'&lng='+point.x+'&distance='+distance+'&count='+count;var AjaxRequest=new Ajax.Request(url,{method:'post',onComplete:function(request){var res=request.responseText;$(id).innerHTML=res;var span=document.createElement("span");var a=document.createElement("a");a.href="http://weather.livedoor.com/weather_hacks/";a.target="_blank";a.appendChild(document.createTextNode('WeatherHacks@Livedoor Weather Web Service'));var body=$(id).getElementsByTagName("tbody");var trs=body[0].getElementsByTagName("tr");var tds=trs[1].getElementsByTagName("td");tds[0].appendChild(document.createElement("br"));span.appendChild(a);span.style.cssText="font-size:80%;margin-top:1px";tds[0].appendChild(span);}});}}
var mapConfig={"id":"map","defalutLat":35.702614,"defaultLng":139.742703,"defaultZoom":16}
var beforeZoom=null;var beforePoint=null;var ByBusMap=Class.create();ByBusMap.prototype={initialize:function(){this.map=new GMap2($(mapConfig.id));App.gmap=this;this.landMarkManger=new LandMarkManager();this.map.enableDoubleClickZoom();this.map.enableContinuousZoom();this.map.contorol=new GLargeMapControl();this.map.addControl(this.map.contorol);this.map.addControl(new GScaleControl());this.map.addControl(new GMapTypeControl());this.map.addControl(new BusButton());this.zoomendlistener=GEvent.addListener(this.map,'zoomend',function(){App.gmap.show();});this.moveendlistener=GEvent.addListener(this.map,'moveend',function(){App.getWeather();App.gmap.show();});var cookie=new Cookie();var lat=cookie.get("BYBUS_LAT");var lng=cookie.get("BYBUS_LNG");var zoom=cookie.get("BYBUS_ZOOM");if(def_lat!=null){lat=def_lat;}
if(def_lng!=null){lng=def_lng;}
if(def_zoom!=null){zoom=def_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));if(def_ldmkid){dispLandmarkInfo(def_ldmkid,def_objtype);}},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.setCenter(new GLatLng(point.y,point.x));}});},show:function(){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=6,8,9,10,12,13,15&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);}});}}
function inputInit(){var input=document.getElementsByTagName("input");if(input==null)return;for(var i=0;i<input.length;i++){try{if(input[i].type=="text"||input[i].type=="password"){input[i].className="mminput";input[i].onfocus=function(){this.className="mminput_active";};input[i].onblur=function(){this.className="mminput";};}}
catch(e){}}}
function BusButton(){}
BusButton.prototype=new GControl();BusButton.prototype.initialize=function(map){var container=document.createElement("div");var customPanel=document.createElement("div");container.appendChild(customPanel);var panelContent='<div id="busButtonDiv">'+'検索<input id="mapsearhtext" type="text"/>'+'<input id="searchButton" type="button" value="地図検索" onclick="mapSearch()"/>'+'<input id="busButton" type="button" value="バス停表示" onclick="bsOdekake()"/>'+'<div id="odkrailinfo"></div>'+'</div>';customPanel.innerHTML=panelContent;map.getContainer().appendChild(container);return container;}
BusButton.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(0,15));}
var wdlg=null;var BusStopViewer=Class.create();BusStopViewer.prototype={initialize:function(id){this.element=null;if(typeof id=="string"){this.element=$(id);}
else{this.element=id;}
this.mode=1;},dispNear:function(lat,lng,mode){this.mode=mode;this.element.innerHTML="";var url='/calta/servlet/BusStopInfo';var prm='type=JSON&lat='+lat+'&lng='+lng+'&distance='+'0.5'
var callback='App.busStopInfoList.dispAll';if(this.mode==1){wdlg=new WaitDialog();wdlg.show("バスでお出かけ情報取得中");}
else{this.element.innerHTML='<img src="/bybus/images/pleasewait.gif">';}
var me=this;var ajax=new Ajax.Request(url+"?"+prm,{method:"post",onComplete:function(request){var info=eval('('+request.responseText+')');me.dispNearBusStops(info);}});},dispNearBusStops:function(info){if(this.mode==1){wdlg.close();Element.show('nearbstable');}
else{this.element.innerHTML="";}
App.bsManager.removeIcon();var ul=document.createElement('div');if(info.busstops.length==0){if(this.mode==2){var div=document.createElement("div");div.style.cssText="padding:10px;background-color:#FFCCFF";div.appendChild(document.createTextNode("この付近に登録されたバス停が見つかりませんでした。"+"バスでのアクセスが便利になるよう付近のバス停の登録をお願いします。"));div.appendChild(document.createElement("br"));var a=document.createElement("a");a.href="/bybus/busrail01.jsp";a.target="_blank";a.appendChild(document.createTextNode("この付近のバス停を登録する"));div.appendChild(a);this.element.appendChild(div);return;}
else{$('busstopview').style.height="120px";var div=document.createElement("div");div.style.cssText="padding:10px;background-color:#FFCCFF";div.appendChild(document.createTextNode("この付近に登録されたバス停が見つかりませんでした。"+"バス停の登録をお願いします。"));div.appendChild(document.createElement("br"));var a=document.createElement("a");a.href="/bybus/busrail01.jsp";a.target="_blank";a.appendChild(document.createTextNode("この付近のバス停を登録する"));div.appendChild(a);this.element.appendChild(div);return;}}
for(var i=0;i<info.busstops.length;i++){var bs=info.busstops[i];var latlng;if(parseFloat(bs.lat)==9999.0&&parseFloat(bs.lng)==9999.0){latlng=null;}
else{latlng=new GLatLng(bs.lat,bs.lng);}
var marker=new CaltaLandMark(bs.ldmkid,bs.objtype,bs.iconid,bs.name,latlng,null);marker.zoommin=bs.zoommin;marker.zoommax=bs.zoommax;try{marker.parking=bs.parking;marker.bicycle=bs.bicycle;marker.roof=bs.roof;marker.bench=bs.bench;}
catch(e){}
App.bsManager.push(marker);var li=document.createElement('p');li.style.cssText="margin-top:5px";var img=document.createElement("img");var cicon=App.iconManager.getAt(marker.iconid);if(cicon!=null){img.src=cicon.icon.image;img.align="middle";if(this.mode==1){img.width="10";img.height="17";}
li.appendChild(img);}
var span=document.createElement('span');var a=document.createElement('a');a.href="#top1";a.setAttribute("lat",bs.lat);a.setAttribute("lng",bs.lng);a.onclick=function(){var lat=this.getAttribute("lat");var lng=this.getAttribute("lng");getGmap().panTo(new GLatLng(lat,lng));};a.appendChild(document.createTextNode(bs.name));span.appendChild(document.createTextNode("　"));span.appendChild(a);li.appendChild(span);if(this.mode==2){var img=this.getDirectionArrowIcon(bs.direction);span=document.createElement('span');var dis=parseInt(bs.distance);span.appendChild(document.createTextNode("　　"+dis+"m　　"));if(img){span.appendChild(img);}
span.appendChild(document.createTextNode("　"));li.appendChild(span);span=document.createElement('span');if(bs.parking=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_p.gif";icon.align="bottom";icon.alt="駐車場あり";icon.title="駐車場あり";span.appendChild(icon);}
if(bs.bicycle=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_bi.gif";icon.align="bottom";icon.alt="駐輪場あり";icon.title="駐輪場あり";span.appendChild(icon);}
if(bs.bench=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_bench.gif";icon.align="bottom";icon.alt="ベンチあり";icon.title="ベンチあり";span.appendChild(icon);}
if(bs.roof=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_yane.gif";icon.align="bottom";icon.alt="屋根あり";icon.title="屋根あり";span.appendChild(icon);}
li.appendChild(span);if(bs.description){var description=document.createElement('div');description.className="bsdescription";description.appendChild(document.createTextNode(bs.description));li.appendChild(description);}}
if(bs.busrails.length>0){var busraildiv=document.createElement('div');busraildiv.className="busrail_div";var railname="";for(var j=0;j<bs.busrails.length;j++){var rail=bs.busrails[j];var b=false;if(railname!=rail.railname){var p3=document.createElement('p');if(this.mode==2){p3.appendChild(document.createTextNode("■運行会社："));}
if(rail.orgurl){p3.className="busrail";var a3=document.createElement('a');a3.href=rail.orgurl;a3.target="_blank";a3.appendChild(document.createTextNode(rail.orgname));p3.appendChild(a3);busraildiv.appendChild(p3);}
else{p3.className="busrail";p3.appendChild(document.createTextNode(rail.orgname));busraildiv.appendChild(p3);}
var p2=document.createElement('p');p2.className="busrail";if(this.mode==2){p2.appendChild(document.createTextNode("■路線名称："));}
p2.appendChild(document.createTextNode(rail.railname));busraildiv.appendChild(p2);railname=rail.railname;b=true;}
p2=document.createElement('p');if(b){var hr=document.createElement("hr");hr.style.cssText="border-style:solid;border-color:#ccc;border-width:1px";p2.appendChild(hr);}
p2.className="busdist";p2.appendChild(document.createTextNode("行先："+rail.destination));var div2=document.createElement('div');div2.appendChild(document.createTextNode("系統："));for(var k=0;k<rail.rails.length;k++){var span2=document.createElement('span');var font=document.createElement('font');font.setAttribute("color",rail.rails[k].color);font.appendChild(document.createTextNode("■"));span2.className="dispRail";var a2=document.createElement('a');a2.href="#";a2.setAttribute("railid",rail.rails[k].railid);a2.onclick=function(){$('odkrailinfo').innerHTML="";var railid=this.getAttribute("railid");App.busRail.getRailInfo(railid);}
if(rail.rails[k].railno==null){a2.appendChild(document.createTextNode("(表示)"));}
else if(rail.rails[k].railno.length==0){a2.appendChild(document.createTextNode("(表示)"));}
else{a2.appendChild(document.createTextNode(rail.rails[k].railno));}
span2.appendChild(font);span2.appendChild(a2);if(k+1!=rail.rails.length){span2.appendChild(document.createTextNode(","));}
div2.appendChild(span2);if(this.mode==2){var a3=document.createElement("a");a3.appendChild(document.createTextNode("路線を表示"));a3.href="#top1";a3.setAttribute("railid",rail.rails[k].railid);a3.onclick=function(){$('odkrailinfo').innerHTML="";var railid=this.getAttribute("railid");App.busRail.getRailInfo(railid);}
span2.appendChild(document.createTextNode(" [ "));span2.appendChild(a3);span2.appendChild(document.createTextNode(" ] "));a3=document.createElement("a");a3.href="/calta/routetrace/"+rail.rails[k].railid+"/";a3.appendChild(document.createTextNode("路線情報詳細"));a3.target="_blank";span2.appendChild(document.createTextNode(" [ "));span2.appendChild(a3);span2.appendChild(document.createTextNode(" ] "));}}
p2.appendChild(div2);var hr=document.createElement("hr");hr.style.cssText="border-style:solid;border-color:#ccc;border-width:1px";p2.appendChild(hr);busraildiv.appendChild(p2);}
li.appendChild(busraildiv);}
ul.appendChild(li);}
this.element.appendChild(ul);App.bsManager.dispIcon();},getDirectionArrowIcon:function(direction){var url="/calta/images/arrow/arrow_";var alt="";if(direction>=357.5&&direction<=360.0||direction>=0&&direction<2.5){url+="n.gif";alt="北";}
else if(direction>=2.5&&direction<87.5){url+="ne.gif";alt="北東";}
else if(direction>=87.5&&direction<92.5){url+="e.gif";alt="東";}
else if(direction>=92.5&&direction<177.5){url+="es.gif";alt="東南";}
else if(direction>=177.5&&direction<182.5){url+="s.gif";alt="南";}
else if(direction>=182.5&&direction<267.5){url+="sw.gif";alt="南西";}
else if(direction>=267.5&&direction<272.5){url+="w.gif";alt="西";}
else if(direction>=272.5&&direction<357.5){url+="wn.gif";alt="西北";}
else{return null;}
var img=document.createElement("img");img.src=url;img.alt=alt;img.title=alt;return img;}}
function bsOdekake(){$('odkrailinfo').innerHTML="";Element.hide('odkrailinfo');var p=getGmap().getCenter();App.bsViewer.dispNear(p.y,p.x,1);}
var BusStopIconManager=Class.create();BusStopIconManager.prototype={initialize:function(id){this.id=id;this.markerArray=new Array();},dispIcon:function(){if(this.markerArray==null)return;for(var i=0;i<this.markerArray.length;i++){try{marker=this.markerArray[i];marker.addOverlay(false,i+1);}
catch(e){}}},removeIcon:function(){if(this.markerArray==null)return;for(var i=0;i<this.markerArray.length;i++){this.markerArray[i].removeOverlay();}
this.markerArray=new Array();},push:function(icon){this.markerArray.push(icon);}}
var BusRail=Class.create();BusRail.prototype={initialize:function(){},getRailInfo:function(railid){url="/calta/servlet/BusStopInfo?";prm='railid='+railid;ralline=this;wdlg=new WaitDialog();wdlg.show("路線情報取得中");Element.hide('odkrailinfo');AjaxRequest=new Ajax.Request(url,{method:'post',parameters:prm,onComplete:function(request){try{var rail=eval('('+request.responseText+')');wdlg.close();App.bsManager.removeIcon();$('odkrailinfo').appendChild(document.createTextNode(rail.railname+"　行先:"+rail.destination+'　'));var f=document.createElement("font");f.color='#'+rail.color;f.appendChild(document.createTextNode("■"));$('odkrailinfo').appendChild(f);$('odkrailinfo').appendChild(document.createTextNode(rail.railno));var a=document.createElement("a");a.href="#";a.onclick=function(){dispFirstBs();};a.appendChild(document.createTextNode("始点"));$('odkrailinfo').appendChild(document.createTextNode(" [ "));$('odkrailinfo').appendChild(a);$('odkrailinfo').appendChild(document.createTextNode(" ] "));a=document.createElement("a");a.href="#";a.onclick=function(){dispLastBs();};a.appendChild(document.createTextNode("終点"));$('odkrailinfo').appendChild(document.createTextNode(" [ "));$('odkrailinfo').appendChild(a);$('odkrailinfo').appendChild(document.createTextNode(" ] "));Element.show('odkrailinfo');for(var i=0;i<rail.busstops.length;i++){var bs=rail.busstops[i];var latlng;if(parseFloat(bs.lat)==9999.0&&parseFloat(bs.lng)==9999.0){latlng=null;}
else{latlng=new GLatLng(bs.lat,bs.lng);}
var marker=new CaltaLandMark(bs.ldmkid,bs.objtype,bs.iconid,bs.name,latlng,null);marker.zoommin=bs.zoommin;marker.zoommax=bs.zoommax;try{marker.parking=bs.parking;marker.bicycle=bs.bicycle;marker.roof=bs.roof;marker.bench=bs.bench;}
catch(e){}
App.bsManager.push(marker);}
App.bsManager.dispIcon();App.busRailLine.getRailLine(railid,"#"+rail.color);}
catch(e){alert(e);}},onTimeout:function(req,ajaxComponent){wdlg.close();alert("タイムアウトが発生しました");}});}}
var BusRailLine=Class.create();BusRailLine.prototype={initialize:function(){this.linePoints=null;this.objLine=null;},getRailLine:function(railid,color){url="/calta/servlet/RailLine?method=select&";prm='railid='+railid;ralline=this;AjaxRequest=new Ajax.Request(url,{method:'post',parameters:prm,onComplete:function(request){var points=eval('('+request.responseText+')');ralline.linePoints=new Array();for(i=0;i<points.points.length;i++){gp=new GPoint(points.points[i].lng,points.points[i].lat);ralline.linePoints.push(gp);}
if(ralline.objLine!=null){getGmap().removeOverlay(ralline.objLine);}
ralline.objLine=new GPolyline(ralline.linePoints,color);getGmap().addOverlay(ralline.objLine);},onTimeout:function(req,ajaxComponent){dlg.close();alert("タイムアウトが発生しました");}});}}
var OdekakeInfoLayer=Class.create();OdekakeInfoLayer.prototype={initialize:function(opt){this.div=null;this.opt=opt;$('ldmkcontents').innerHTML="";Element.hide("odekakeinfo");},show:function(msg){if(this.div!=null){this.close();}
Element.hide("contents");this.div=document.createElement("div");this.div.className="odekakediv";this.div.id="odekakediv";if(this.opt.id=="jalan"){$('ldmkcontentsTitle').className="bl";}
else if(this.opt.id=="school"){$('ldmkcontentsTitle').className="gr";}
else if(this.opt.id=="beauty"){$('ldmkcontentsTitle').className="pi";}
else if(this.opt.id=="hotpepper"){$('ldmkcontentsTitle').className="pi";}
else if(this.opt.id=="doodle"){$('ldmkcontentsTitle').className="gr";}
else{$('ldmkcontentsTitle').className="bl";}
var contentdiv=document.createElement("div");contentdiv.className="odekake";contentdiv.appendChild(this.getContents());this.div.appendChild(contentdiv);$('ldmkcontents').innerHTML="";$('ldmkcontents').appendChild(this.div)
Element.show("odekakeinfo");},close:function(){$('ldmkcontents').innerHTML="";Element.hide("odekakeinfo");},getContents:function(){var div=document.createElement("div");var h2=document.createElement("h2");var ico=null;try{ico=App.iconManager.getAt(this.opt.iconid);var iconimage=null;if(ico!=null){iconimage=document.createElement("img");iconimage.src=ico.icon.image;iconimage.align="middle";}}catch(e){}
$('ldmkcontentsTitle').innerHTML="";$('ldmkcontentsTitle').appendChild(document.createTextNode(this.opt.title));if(this.opt.image!=null){var table=document.createElement("table");var tbody=document.createElement("tbody");var tr=document.createElement("tr");var td=document.createElement("td");var framediv=document.createElement("div");framediv.style.cssText="padding:10px;margin-top:10px";var span=document.createElement("span");span.className="shadow";var img=document.createElement("img");img.src=this.opt.image;img.alt=this.opt.title;img.title=this.opt.title;img.border="0";span.appendChild(img);framediv.appendChild(span);td.appendChild(framediv);tr.appendChild(td);td=document.createElement("td");var dsc;if(this.opt.id=="doodle"){dsc=document.createElement("div");dsc.className="doodlediv";}
else{dsc=document.createElement("span");dsc.className="description";}
if(iconimage!=null){dsc.appendChild(iconimage);dsc.appendChild(document.createElement("br"));}
dsc.appendChild(document.createTextNode(this.opt.description));dsc.appendChild(document.createElement("br"));var copy="";var copyright=null;if(this.opt.id=="jalan"){copyright=document.createElement("p");copyright.align="right";var a1=document.createElement("a");a1.href="http://jws.jalan.net/";var img1=document.createElement("img");img1.src="http://jws.jalan.net/content/images/jws_88_50_blue.gif";img1.alt="じゃらん Web サービス";img1.border="0";img1.title="じゃらん Web サービス";a1.appendChild(img1);copyright.appendChild(a1);copy="写真提供：じゃらんWebサービス";}
else if(this.opt.id=="hotpepper"){copyright=document.createElement("p");copyright.align="right";var a1=document.createElement("a");a1.href="http://www.hotpepper.jp/";var img1=document.createElement("img");img1.src="http://api.hotpepper.jp/content/images/hp_api_s.gif";img1.alt="ホットペッパー Webサービス";img1.width="155";img1.height="20";img1.border="0";img1.title="ホットペッパー Webサービス";a1.appendChild(img1);copyright.appendChild(a1);copy="写真提供：ホットペッパー.jp";}
else if(this.opt.id=="beauty"){copyright=document.createElement("p");copyright.align="right";var a1=document.createElement("a");a1.href="http://webservice.recruit.co.jp/";var img1=document.createElement("img");img1.src="http://webservice.recruit.co.jp/banner/beauty-s.gif";img1.alt="ホットペッパーBeauty Webサービス";img1.border="0";img1.title="ホットペッパーBeauty Webサービス";img1.width="135";img1.height="17";a1.appendChild(img1);copyright.appendChild(a1);copy="【画像提供：ホットペッパーBeauty】";}
else if(this.opt.id=="calta_13"){if(this.opt.image){var p=document.createElement("p");p.align="right";var a=document.createElement("a");a.href="http://photozou.jp/";var img=document.createElement("img");img.src="http://photozou.jp/img/photozou_logo.gif";img.title="フォト蔵";img.alt="フォト蔵";a.appendChild(img);p.appendChild(a);dsc.appendChild(p);}}
else if(this.opt.id=="doodle"){if(this.opt.image){var p=document.createElement("p");p.align="right";var a=document.createElement("a");a.href="http://photozou.jp/";var img=document.createElement("img");img.src="http://photozou.jp/img/photozou_logo.gif";img.title="フォト蔵";img.alt="フォト蔵";a.appendChild(img);p.appendChild(a);dsc.appendChild(p);}}
if(copyright!=null){copyright.style.cssText="margin-top:5px";dsc.appendChild(copyright);}
if(copy.length>0){var p=document.createElement("p");p.align="right";p.style.cssText="font-size:80%";p.appendChild(document.createTextNode(copy));dsc.appendChild(p);}
td.appendChild(dsc);tr.appendChild(td);tbody.appendChild(tr);table.appendChild(tbody);div.appendChild(table);}
else{if(this.opt.description&&this.opt.description.length>0){var dsc;if(this.opt.id=="doodle"){dsc=document.createElement("div");dsc.className="doodlediv";dsc.appendChild(document.createTextNode(this.opt.description));var p=document.createElement("p");p.className="date";var dateStr=this.opt.comment;p.appendChild(document.createTextNode(dateStr));dsc.appendChild(p);p=document.createElement("p");p.align="right";p.style.cssText="margin:0px";var img=document.createElement("img");img.src="/bybus/images/kokuban6.gif";p.appendChild(img);img=document.createElement("img");img.src="/bybus/images/kokuban61.gif";p.appendChild(img);dsc.appendChild(p);div.appendChild(dsc);}
else{dsc=document.createElement("p");dsc.className="description";if(iconimage!=null){dsc.appendChild(iconimage);dsc.appendChild(document.createElement("br"));}
dsc.appendChild(document.createTextNode(this.opt.description));div.appendChild(dsc);}}}
if(this.opt.id!="doodle"){if(this.opt.comment&&this.opt.comment.length>0){var content=document.createElement("div");content.className="content";if(this.opt.id=="doodle"){content.style.cssText="text-align:right;clear:both;margin:5px 30px 5px 30px";}
content.appendChild(document.createTextNode(this.opt.comment));div.appendChild(content);}}
if(this.opt.id=="doodle"){var bbsdiv=document.createElement("div");bbsdiv.className="bbsdiv";if(isIE()==true){var obj=document.createElement("iframe");obj.src=this.opt.bbslink;obj.frameBorder=0;obj.setAttribute("border","0");obj.setAttribute("framespacing","0");obj.style.cssText="height:400px;width:100%;";bbsdiv.appendChild(obj);}
else{var obj=document.createElement("object");obj.type="text/html";obj.data=this.opt.bbslink;obj.style.cssText="height:400px;width:100%";bbsdiv.appendChild(obj);}
div.appendChild(bbsdiv);var fp=document.createElement("p");fp.align="right";fp.style.cssText="margin-right : 10px";var a=document.createElement("a");a.href=this.opt.url;a.target="_blank";var img=document.createElement("img");img.src="http://doodle.st/k/doodle_pc.gif";img.alt="doodle";img.border="0";img.title="doodle";img.width="120";img.height="34";a.appendChild(img);fp.appendChild(document.createTextNode("入力欄に何か入力してdoodleボタンを押すとこの掲示板に書き込みできます。"))
fp.appendChild(a);div.appendChild(fp);}
if(this.opt.id=="school"){var school=schoolData[this.opt.idx];if(school){var fdiv=document.createElement("div");fdiv.className="schoolfaculty";fdiv.style.cssText="padding:10px;"
var p=document.createElement("p");p.appendChild(document.createTextNode("■学科・コース情報"));fdiv.appendChild(p);for(var i=0;i<school.faculty.length;i++){var faculty=school.faculty[i];var p=document.createElement("p");p.style.cssText="padding-left:10px;"
p.appendChild(document.createTextNode(faculty.name+" "+faculty.department));fdiv.appendChild(p);}
div.appendChild(fdiv);}
var copyright=document.createElement("p");copyright.style.cssText="margin-right:20px";copyright.align="right";var a1=document.createElement("a");a1.href="http://webservice.recruit.co.jp/";var img1=document.createElement("img");img1.src="http://webservice.recruit.co.jp/banner/shingaku-s.gif";img1.alt="リクルート進学ネット Webサービス";img1.border="0";img1.title="リクルート進学ネット Webサービス";img1.width="135";img1.height="17";a1.appendChild(img1);copyright.appendChild(a1);div.appendChild(copyright);}
if(this.opt.addr&&this.opt.addr.length>0){content=document.createElement("div");content.className="content";content.appendChild(document.createTextNode(this.opt.addr));div.appendChild(content);}
if(this.opt.qrcode&&this.opt.qrcode.length>0){content=document.createElement("p");content.style.cssText="margin-right:10px";content.align="right";var img=document.createElement("img");img.src=this.opt.qrcode;if(this.opt.id=="hotpepper"){img.width=82;img.height=82;}
else if(this.opt.id=="school"){img.width=164;img.height=164;}
content.appendChild(img);div.appendChild(content);}
content=document.createElement("p");content.style.cssText="margin-right:10px";var linkspan=document.createElement("span");var a=document.createElement("a");a.href="#top1";a.setAttribute("lat",this.opt.lat);a.setAttribute("lng",this.opt.lng);a.setAttribute("iconid",this.opt.iconid);a.setAttribute("title",this.opt.title);a.setAttribute("idx",this.opt.idx);a.onclick=function(){var lat=this.getAttribute("lat");var lng=this.getAttribute("lng");getGmap().panTo(new GLatLng(lat,lng));}
content.align="right";a.appendChild(document.createTextNode("中心に表示"));linkspan.appendChild(document.createTextNode(" [ "));linkspan.appendChild(a);linkspan.appendChild(document.createTextNode(" ] "));content.appendChild(linkspan);if(this.opt.url&&this.opt.url.length>0){linkspan=document.createElement("span");var a=document.createElement("a");a.href=this.opt.url;a.target="_blank";var linkname="リンク";if(this.opt.id=="jalan"){linkname="予約・空室検索";}
else if(this.opt.id=="hotpepper"){linkname="予約・詳細";}
else if(this.opt.id=="beauty"){linkname="予約・詳細";}
else if(this.opt.id=="doodle"){linkname="doodleMapへ";}
a.appendChild(document.createTextNode(linkname));if(this.opt.id!="doodle"){linkspan.appendChild(document.createTextNode(" [ "));linkspan.appendChild(a);linkspan.appendChild(document.createTextNode(" ] "));}
content.appendChild(linkspan);if(this.opt.id=="doodle"){linkspan.appendChild(document.createElement("br"));var input=document.createElement("a");input.id="btnsharedoodle";input.href="#top1";input.setAttribute("idx",this.opt.idx);input.onclick=function(){var par=$('doodleregspan').parentNode;var label=document.createElement('span');label.id="labeldoodle";label.appendChild(document.createTextNode("スポット名："));par.insertBefore(label,$('doodleregspan'));var text=document.createElement("input");text.type="text";text.size="24";text.id="doodlespot";par.insertBefore(text,$('doodleregspan'));var idx=this.getAttribute("idx");var btn=document.createElement("input");btn.type="button";btn.value="登録";btn.id="regdoodle";btn.setAttribute("idx",idx);btn.onclick=function(){var idx=this.getAttribute("idx");if(doodleRegistAsSpot(idx,$F('doodlespot'))==false){return;}
par.removeChild($('regdoodle'));par.removeChild($('canceldoodle'));par.removeChild($('labeldoodle'));par.removeChild($('doodlespot'));}
par.insertBefore(btn,$('doodleregspan'));btn=document.createElement("input");btn.type="button";btn.value="キャンセル";btn.id="canceldoodle";btn.onclick=function(){par.removeChild($('regdoodle'));par.removeChild($('canceldoodle'));par.removeChild($('labeldoodle'));par.removeChild($('doodlespot'));Element.show("doodleregspan");}
par.insertBefore(btn,$('doodleregspan'));Element.hide("doodleregspan");$('doodlespot').focus();return false;}
if(!this.opt.ldmkid){var doodleregspan=document.createElement("span");doodleregspan.id="doodleregspan";input.appendChild(document.createTextNode("この落書きをみんなのスポットにする"));doodleregspan.appendChild(document.createTextNode(" [ "));doodleregspan.appendChild(input);doodleregspan.appendChild(document.createTextNode(" ] "));linkspan.appendChild(doodleregspan);}}}
div.appendChild(content);var sepadiv=document.createElement("div");sepadiv.className="sepadiv";div.appendChild(sepadiv);if(this.opt.id=="calta_13"||(this.opt.id=="doodle"&&this.opt.ldmkid)){content=document.createElement("p");var link=document.createElement("a");link.href="http://calta.jp/bybus/spot/"+this.opt.ldmkid+"-15.html";link.target="_blank";link.appendChild(document.createTextNode("http://calta.jp/bybus/spot/"+this.opt.ldmkid+"-15.html"));content.style.cssText="margin-right:10px";content.align="right";content.appendChild(document.createTextNode("お出かけURL : "));content.appendChild(link);div.appendChild(content);}
if(this.opt.id=="calta_5"){content=document.createElement("p");var link=document.createElement("a");link.href="http://calta.jp/bybus/busstop/"+this.opt.ldmkid+"-15.html";link.target="_blank";link.appendChild(document.createTextNode("http://calta.jp/bybus/busstop/"+this.opt.ldmkid+"-15.html"));content.style.cssText="margin-right:10px";content.align="right";content.appendChild(document.createTextNode("お出かけURL : "));content.appendChild(link);div.appendChild(content);}
sepadiv=document.createElement("div");sepadiv.className="sepadiv";div.appendChild(sepadiv);var infodiv=document.createElement("div");infodiv.className="infodiv";var h3=document.createElement("h3");h3.className="bl";h3.appendChild(document.createTextNode("バスでお出かけ情報"));infodiv.appendChild(h3);var info=this.getBusInfo();infodiv.appendChild(info);h3=document.createElement("h3");h3.className="bl";h3.appendChild(document.createTextNode("電車でお出かけ情報"));infodiv.appendChild(h3);info=this.getRailInfo();infodiv.appendChild(info);if(this.opt.id=="doodle"&&!this.opt.ldmkid){}
else{h3=document.createElement("h3");h3.className="bl";h3.appendChild(document.createTextNode("マイカーでお出かけ情報"));infodiv.appendChild(h3);info=this.getMyCarInfo();infodiv.appendChild(info);}
div.appendChild(infodiv);return div;},getRailInfo:function(){var div=document.createElement("div");var img=document.createElement("img");img.align="bottom";img.src="/bybus/images/register_rail_a.gif";div.appendChild(img);div.appendChild(document.createTextNode("　最寄駅"));div.className="railInfo";var mash=new MashUp();mash.request("dokoeki",[{param:"lat",value:this.opt.lat},{param:"lng",value:this.opt.lng},{param:"nodlg",value:true}],function(info){var ldmks=info.results.landmark;var div2=document.createElement("div");div2.className="railInfo";for(var i=0;i<ldmks.length;i++){var span=document.createElement("p");span.appendChild(document.createTextNode(ldmks[i].name));var lat=ldmks[i].lat_jgd;var lng=ldmks[i].lon_jgd;var a=document.createElement("a");a.href="#top1";a.setAttribute("lat",lat);a.setAttribute("lng",lng);a.onclick=function(){var lat=this.getAttribute("lat");var lng=this.getAttribute("lng");getGmap().panTo(new GLatLng(lat,lng));}
a.appendChild(span)
div2.appendChild(a);}
div.appendChild(div2);var credit=document.createElement("p");credit.align="right";credit.style.cssText="margin-right:10px";var str='<a href="http://www.doko.jp/"><img src="http://www.doko.jp/api/banner/dokoiku-135x17.gif" alt="ドコイク？Webサービス（β版）" width="135" height="17" border="0" title="ドコイク？Webサービス（β版）"></a>'
credit.innerHTML=str;div.appendChild(credit);});return div;},getMyCarInfo:function(){var div=document.createElement("div");var div2=document.createElement("div");var img=document.createElement("img");img.align="bottom";img.src="/bybus/images/register_car_a.gif";div.appendChild(img);div.appendChild(document.createTextNode("　駐車場情報"));var sc=new GSearchControl();sc.addSearcher(new GwebSearch());sc.draw(div2);var key=this.opt.title;if(this.opt.id=="school"){key=key.replace(":本部所在地","");}
sc.execute(key+" 駐車場");div.appendChild(div2);div2=document.createElement("div");div.appendChild(document.createTextNode('*表示された結果は必ずしも当該スポットの駐車場の情報とは限りません。'));div.appendChild(div2);div.className="mycarInfo";return div;},getBusInfo:function(){var div=document.createElement("div");div.className="busInfo";var img=document.createElement("img");img.src="/bybus/images/register_a.gif";img.align="middle";div.appendChild(img);div.appendChild(document.createTextNode("　近隣のバス停"));div2=document.createElement("div");div2.id="odekakebus";var view=new BusStopViewer(div2);view.dispNear(this.opt.lat,this.opt.lng,2);div.appendChild(div2);return div;}}
function dispOdkkInfo(){var dlg=new OdekakeInfoLayer({iconid:21,image:"http://art8.photozou.jp/pub/338/141338/photo/4152246_thumbnail.jpg",title:"バス停",description1:"日産のテレマティクスサービス『CARWINGS』の情報チャンネルに対して情報提供します。対応するカーナビで近隣のバス停情報を表示することができます。詳細はこちら",description:"日産のテレマティクスサービス『CARWINGS"});dlg.show();}
function showOdekakeInfo(idx){var ldmk=landmarkArray[idx];Element.hide("contents");var dlg=new OdekakeInfoLayer(ldmk);dlg.show();}
function mapSearch(){App.gmap.moveMap($('mapsearhtext').value);Element.hide('nearbstable');Element.hide('odkrailinfo');}
var ldmkMarkerArray=new Array();function dispLdmkIcon(ldmk){var ldmkIcon=App.iconManager.getAt(ldmk.iconid);var p=new GLatLng(ldmk.lat,ldmk.lng);var ldmkMarker;if(ldmkIcon){ldmkMarker=new GMarker(p,{draggable:false,title:ldmk.title,clickable:true,icon:ldmkIcon.icon});}
else{ldmkMarker=new GMarker(p,{draggable:false,title:ldmk.title,clickable:true});}
getGmap().addOverlay(ldmkMarker);ldmkMarkerArray.push(ldmkMarker);GEvent.addListener(ldmkMarker,'click',function(){var latlng=new GLatLng(ldmk.lat,ldmk.lng);showOdekakeInfo(ldmk.idx);});}
function clearLdmkIcon(){for(i=0;i<ldmkMarkerArray.length;i++){getGmap().removeOverlay(ldmkMarkerArray[i]);}
ldmkMarkerArray=new Array();}
function dispFirstBs(){var mk=App.bsManager.markerArray[0];getGmap().panTo(mk.point);}
function dispLastBs(){var mk=App.bsManager.markerArray[App.bsManager.markerArray.length-1];getGmap().panTo(mk.point);}
function dispLandmarkInfo(ldmkid,objtype){var url="/calta/servlet/CaltaServlet?ldmkid="+ldmkid+"&objtype="+objtype+"&contents=true";var ajax=new Ajax.Request(url,{method:"post",onComplete:function(request){var xml=request.responseXML;var markers=xml.getElementsByTagName("marker");if(markers.length==0)return;var marker=markers[0];var ldmk=new Landmark();ldmk.title=marker.getAttribute("name");ldmk.description=marker.getAttribute("description");ldmk.id="calta_"+marker.getAttribute("objtype");ldmk.idx=0;ldmk.addr="";ldmk.lat=marker.getAttribute("lat");ldmk.lng=marker.getAttribute("lng");;ldmk.image=marker.getAttribute("imageurl");ldmk.url=marker.getAttribute("url");ldmk.tel=marker.getAttribute("tel");ldmk.comment="";ldmk.qrcode="";ldmk.iconid=marker.getAttribute("iconid");ldmk.ldmkid=marker.getAttribute("ldmkid");ldmk.doodleno=marker.getAttribute("category");if(ldmk.doodleno){if(ldmk.doodleno.indexOf("doodle")==0){ldmk.id="doodle";ldmk.bbslink=ldmk.url;ldmk.bbslink=ldmk.bbslink.replace(/＆/g,'&');}}
var dlg=new OdekakeInfoLayer(ldmk);dlg.show();getGmap().panTo(new GLatLng(ldmk.lat,ldmk.lng));}});}
function getNewSpot(){var url="/calta/servlet/BybusMap?mode=getnewspot";var ajax=new Ajax.Request(url,{method:"post",onComplete:function(request){var xml=request.responseXML;var spot=xml.getElementsByTagName("spot");if(spot==null)return;for(var i=0;i<spot.length;i++){var ldmkid=spot[i].getElementsByTagName("ldmkid")[0].firstChild.nodeValue;var iconid=spot[i].getElementsByTagName("iconid")[0].firstChild.nodeValue;var name=spot[i].getElementsByTagName("name")[0].firstChild.nodeValue;var objtype=spot[i].getElementsByTagName("objtype")[0].firstChild.nodeValue;var a=document.createElement("a");a.href="#top1";a.setAttribute("ldmkid",ldmkid);a.setAttribute("objtype",objtype);a.onclick=function(){var ldmkid=this.getAttribute("ldmkid");var objtype=this.getAttribute("objtype");dispLandmarkInfo(ldmkid,objtype);}
var p=document.createElement("p");p.style.cssText="margin-left:10px";var img=document.createElement("img");img.setAttribute("align","bottom",0);var ico=App.iconManager.getAt(iconid);img.src=ico.icon.image;p.appendChild(img);a.appendChild(document.createTextNode(name));p.appendChild(document.createTextNode("　"));p.appendChild(a);$('landmarklist2').appendChild(p);}}});}
function getNewBusStops(){var url="/calta/servlet/BusStopInfo?mode=newlist";var ajax=new Ajax.Request(url,{method:"post",onComplete:function(request){var info=request.responseText;info=eval('('+info+')');var busstops=info.busstops;var tbl=document.createElement("table");tbl.style.cssText="width:90%";var tbody=document.createElement("tbody");tbl.appendChild(tbody);for(var i=0;i<busstops.length;i++){var tr=document.createElement("tr");var td=document.createElement("td");var ldmkid=busstops[i].ldmkid;var iconid=busstops[i].iconid;var name=busstops[i].name;var objtype=busstops[i].objtype;var a=document.createElement("a");a.href="#top1";a.setAttribute("ldmkid",ldmkid);a.setAttribute("lat",busstops[i].lat);a.setAttribute("lng",busstops[i].lng);a.onclick=function(){var ldmkid=this.getAttribute("ldmkid");var objtype=this.getAttribute("objtype");var lat=this.getAttribute("lat");var lng=this.getAttribute("lng");getGmap().panTo(new GLatLng(lat,lng));$('odkrailinfo').innerHTML="";Element.hide('odkrailinfo');App.bsViewer.dispNear(lat,lng,1);}
var img=document.createElement("img");img.setAttribute("align","bottom",0);var ico=App.iconManager.getAt(iconid);img.src=ico.icon.image;td.appendChild(img);tr.appendChild(td);td=document.createElement("td");td.style.cssText="padding:5px";var p=document.createElement("p");a.appendChild(document.createTextNode(name));p.appendChild(a);td.appendChild(p);tr.appendChild(td);td=document.createElement("td");td.style.cssText="padding:5px";p=document.createElement("p");if(busstops[i].cityname){var cityname=busstops[i].cityname.replace(/\//g,"");p.appendChild(document.createTextNode(cityname));}
td.appendChild(p);tr.appendChild(td);td=document.createElement("td");td.style.cssText="padding:5px;width:90px";p=document.createElement("p");if(busstops[i].parking=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_p.gif";icon.align="bottom";icon.alt="駐車場あり";icon.title="駐車場あり";p.appendChild(icon);}
if(busstops[i].bicycle=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_bi.gif";icon.align="bottom";icon.alt="駐輪場あり";icon.title="駐輪場あり";p.appendChild(icon);}
if(busstops[i].bench=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_bench.gif";icon.align="bottom";icon.alt="ベンチあり";icon.title="ベンチあり";p.appendChild(icon);}
if(busstops[i].roof=="true"){var icon=document.createElement("img");icon.src="/bybus/images/icon_busstop_s_yane.gif";icon.align="bottom";icon.alt="屋根あり";icon.title="屋根あり";p.appendChild(icon);}
td.appendChild(p);tr.appendChild(td);tbody.appendChild(tr);tr=document.createElement("tr");td=document.createElement("td");td.appendChild(document.createTextNode(" "));tr.appendChild(td);td=document.createElement("td");td.setAttribute("colSpan",3);td.style.cssText="padding:5px";p=document.createElement("p");if(busstops[i].description){p.appendChild(document.createTextNode(busstops[i].description));}
td.appendChild(p);tr.appendChild(td);tbody.appendChild(tr);tr=document.createElement("tr");td=document.createElement("td");td.setAttribute("colSpan",4);var hr=document.createElement("hr");hr.style.cssText="border-style:solid;border-color:#ccc;border-width:1px";td.appendChild(hr);tr.appendChild(td);tbody.appendChild(tr);}
$('newbusstoplist').appendChild(tbl);$('busstopcount').innerHTML="登録バス停数："+info.count;}});}
function doodleRegistAsSpot(idx,spotName){if(spotName.length==0){alert("スポット名を入力してください");return false;}
var ldmk=landmarkArray[idx];var AjaxRequest=new Ajax.Request("/calta/servlet/CaltaSessionServlet?action=login&account=guest&password="+MD5_hexhash("mizube2006"),{method:'post',onComplete:function(request){var spotUpdater=new SpotUpdater([{"param":"lat","value":ldmk.lat},{"param":"lng","value":ldmk.lng},{"param":"name","value":spotName},{"param":"description","value":ldmk.description},{"param":"objtype","value":13},{"param":"iconid","value":ldmk.iconid},{"param":"updaterid","value":50},{"param":"creatorid","value":50},{"param":"zoommax","value":999},{"param":"zoommin","value":14},{"param":"url","value":ldmk.bbslink},{"param":"category","value":"doodle-"+ldmk.doodleno}]);spotUpdater.update(function(marker){App.gmap.landMarkManger.landmarkArray.push(marker);marker.addOverlay();var url='/calta/servlet/CaltaServlet?objtype=6,8,9,10,12,13,15&ver=2';var prm=App.gmap.getAreaRangeStr();var AjaxRequest=new Ajax.Request(url+prm,{method:'post',onComplete:function(request){var xml=request.responseXML;App.gmap.landMarkManger.overlay(xml);}});})},onTimeout:function(req,ajaxComponent){alert("タイムアウトが発生しました");}});}