var YMap=window.YMap||{};var RegisterButton=YMap.RegisterButton={urls:{register:"http://map.yahoo.co.jp/register?",mtf:"http://map.yahoo.co.jp/mtfm?",map_pc:"http://map.yahoo.co.jp/pl?",map_mobile:"http://map.mobile.yahoo.co.jp/pl?",help_poix_waiwai:"http://help.yahoo.co.jp/help/jp/maps/maps-57.html#send",help_poix_drive:"http://help.yahoo.co.jp/help/jp/drive/drive-34.html",help_appli_waiwai:"http://help.yahoo.co.jp/help/jp/maps/maps-57.html#appli",help_appli_drive:"http://help.yahoo.co.jp/help/jp/drive/drive-01.html",login:"https://login.yahoo.co.jp/config/login?.src=mp&lg=jp&.intl=jp&.done="},showButton:function(c){this.params=new RegisterParam(c);
if(!this.params.validateParam(true)){if(this.params.get("debug")=="on"){var a=this.params.getValidErr();window.alert(a.msg);}return;}this.parenttag=document.getElementById(this.params.get("tagid"));if(!this.parenttag){var a={};a.param="tagid";a.type="param_invalid";if(this.params.get("debug")=="on"){var b="パラメータ(tagid)の値が不正です。";window.alert(b);}return;}this.setCSS();this.button=this.createButton();
this.parenttag.appendChild(this.button);},createButton:function(){var o=this;var m=document.createElement("div");m.id="ymap-poix";m.style.postion="relative";var c=document.createElement("div");c.id="ymap-poix-link";var h=document.createElement("a");h.href="javascript:void(0)";h.onclick=function(){o.toggleMenu();};h.innerHTML=this.params.get("blabel");var l=document.createElement("img");l.id="ymap_register_tribtn";
l.src="http://i.yimg.jp/images/map/poix/images/ymap-poix-bt01.png";h.appendChild(l);c.appendChild(h);m.appendChild(c);var f=document.createElement("div");f.id="ymap-poix-menu";var b=document.createElement("div");b.id="outer-line-top";var h=document.createElement("a");h.className="ymap_link";h.href="javascript:void(0)";var p=document.createElement("a");p.className="ymap_help_icon";p.target="_ymhlp";
var k=document.createElement("img");k.src="http://i.yimg.jp/images/map/v2/helpicon.gif";k.width="13";k.height="15";k.border="0";k.alt="ヘルプ";p.appendChild(k);if(this.params.get("btype")=="spot2"){var d=document.createElement("div");d.id="menu03";var r=h.cloneNode(true);r.onclick=function(){o.mailToFriend("pc");return false;};r.innerHTML="パソコンへ送る";d.appendChild(r);b.appendChild(d);var a=document.createElement("div");
a.id="menu04";var q=h.cloneNode(true);q.onclick=function(){o.mailToFriend("mobile");return false;};q.innerHTML="ケータイへ送る";a.appendChild(q);b.appendChild(a);}var g=document.createElement("div");g.id="menu01";var t=h.cloneNode(true);var j=p.cloneNode(true);if(o.params.get("prop")=="drive"){j.href=this.urls.help_appli_drive;}else{j.href=this.urls.help_appli_waiwai;}t.onclick=function(){o.params.set("ptype","spot");
o.openPopup();return false;};t.innerHTML="路線・地図アプリへ送る";g.appendChild(t);g.appendChild(j);b.appendChild(g);var n=document.createElement("div");n.id="outer-line-bottom";var e=document.createElement("div");e.id="menu02";var s=h.cloneNode(true);var i=p.cloneNode(true);if(o.params.get("prop")=="drive"){i.href=this.urls.help_poix_drive;}else{i.href=this.urls.help_poix_waiwai;}s.onclick=function(){o.params.set("ptype","poix");
o.openPopup();return false;};s.innerHTML="カーナビへ送る";e.appendChild(s);e.appendChild(i);n.appendChild(e);f.appendChild(b);f.appendChild(n);this.menu=f;f.style.display="none";m.appendChild(f);return m;},toggleMenu:function(){var a=document.getElementById("ymap_register_tribtn");if(!a){return;}if(this.menu.style.display=="block"){a.src="http://i.yimg.jp/images/map/poix/images/ymap-poix-bt01.png";this.menu.style.display="none";
}else{a.src="http://i.yimg.jp/images/map/poix/images/ymap-poix-bt02.png";this.menu.style.display="block";}},openPopup:function(h){if(h){this.params=new YMap.RegisterParam(h);if(!this.params.validateParam(false)){if(this.params.get("debug")=="on"){var d=this.params.getValidErr();window.alert(d.msg);}return false;}}if(this.params.get("login")==""){var b=this.urls.login+encodeURIComponent(document.URL);
location.href=b;return false;}var f=this.params.get("ptype");var c=this.params.buildPopupUrl(f);var a="";var e="";if(f=="route"){a="730";e="_ymresister_route";}else{if(f=="poix"){a="653";e="_ymresister_poix";}else{a="440";e="_ymresister_spot";}}var g=window.open(c,e,"height="+a+",width=620,location=no,menubar=no,toolbar=no,scrollbars=yes");if(g){g.focus();this.toggleMenu();}return true;},showError:function(a){var b="";
switch(a.type){case"param_invalid":b="パラメータ("+a.param+")の値が不正です。";break;case"param_no":b="必要なパラメータ("+a.param+")が指定されていません。";break;default:b="予期せぬエラーが発生しました。";break;}window.alert(b);},setCSS:function(){var a=document.createElement("link");a.rel="stylesheet";a.type="text/css";a.id="yahoomap-register-css";a.media="all";if(this.customCSS){a.href=this.customCSS;}else{a.href="http://i.yimg.jp/images/map/poix/css/ymap_poix_cmn01.css";
}document.getElementsByTagName("head")[0].appendChild(a);},mailToFriend:function(b){var a=this.params.buildMtfUrl(b);window.location.href=a;}};var YMap=window.YMap||{};var RegisterParam=YMap.RegisterParam=function(a){this.params={prop:"",ptype:"spot",name:"",address:"",tel:"",lat:"",lon:"",datum:"tky",routeID:"",crumb:"",error:"",errPrm:"",poixid:"",poixmemo:"",cartype:"1",btype:"spot1",blabel:"この場所を送る",login:"",tagid:"YMapRegister",debug:"off",mtf:"",mtm:"",mtf_name:"",mtm_name:"",check:"off"};this.urls={register:"http://map.yahoo.co.jp/register?",mtf:"http://map.yahoo.co.jp/mtfm?",map_pc:"http://map.yahoo.co.jp/pl?",map_mobile:"http://map.mobile.yahoo.co.jp/pl?",help:"http://help.yahoo.co.jp/help/jp/maps/",login:"https://login.yahoo.co.jp/config/login?.src=mp&lg=jp&.intl=jp&.done="};
this.error={type:"",param:""};this.load(a);};YMap.RegisterParam.ERR_NO_PARAM="INPUT_NO";YMap.RegisterParam.ERR_INVALID_PARAM="INVALID_PARAM";YMap.RegisterParam.ERR_OVER_PARAM="INPUT_OVER";YMap.RegisterParam.PTYPE_ROUTE="route";YMap.RegisterParam.PTYPE_SPOT="spot";YMap.RegisterParam.PTYPE_POIX="poix";YMap.RegisterParam.BTYPE_SPOT1="spot1";YMap.RegisterParam.BTYPE_SPOT2="spot2";YMap.RegisterParam.CAR_TYPE_TOYOYA=1;
YMap.RegisterParam.CAR_TYPE_PANASONIC=2;YMap.RegisterParam.CAR_TYPE_NISSAN=2;YMap.RegisterParam.MAX_NAME=40;YMap.RegisterParam.MAX_ROUTE_NAME=30;YMap.RegisterParam.MAX_NAME_PANA=20;YMap.RegisterParam.MAX_POIX_MEMO=100;YMap.RegisterParam.MAX_ADDRESS=100;YMap.RegisterParam.MAX_ADDRESS_PANA=32;YMap.RegisterParam.MAX_TEL=10;YMap.RegisterParam.prototype.load=function(a){this.isNoParameter=true;var c=0;var d=this;
if(typeof(a)==="object"){for(var b in a){if(a[b]&&a[b].toString().length>0){d.set(b,a[b]);c++;}}}else{this.isNoParameter=false;}};YMap.RegisterParam.prototype.isNumber=function(a){if(!a){return false;}else{if(a==""){return false;}}return !isNaN(a);};YMap.RegisterParam.prototype.set=function(a,b){if(a=="ptype"){if(b!=RegisterParam.PTYPE_ROUTE&&b!=RegisterParam.PTYPE_SPOT&&b!=RegisterParam.PTYPE_POIX){b=RegisterParam.PTYPE_SPOT;
}}else{if(a=="btype"){if(b!=RegisterParam.BTYPE_SPOT1&&b!=RegisterParam.BTYPE_SPOT2){b=RegisterParam.BTYPE_SPOT1;}}}this.params[a]=b;};YMap.RegisterParam.prototype.get=function(a){return this.params[a];};YMap.RegisterParam.prototype.getValidErr=function(){switch(this.error.type){case RegisterParam.ERR_INVALID_PARAM:this.error.msg="パラメータ("+this.error.param+")の値が不正です。";break;case RegisterParam.ERR_OVER_PARAM:this.error.msg="パラメータ("+this.error.param+")の値が不正です。";
break;case RegisterParam.ERR_NO_PARAM:this.error.msg="必要なパラメータ("+this.error.param+")が指定されていません。";break;}return this.error;};YMap.RegisterParam.prototype.validateParam=function(a){if(!this.isNoParameter){this.error.param="all";this.error.type=YMap.RegisterParam.ERR_NO_PARAM;return false;}if(!this.params.prop){this.error.param="prop";this.error.type=YMap.RegisterParam.ERR_NO_PARAM;return false;}var b=true;
if(a){b=this.validatePoixParam();}else{if(this.params.ptype==RegisterParam.PTYPE_ROUTE){b=this.validateRouteParam();}else{if(this.params.ptype==RegisterParam.PTYPE_POIX){b=this.validatePoixParam();}else{b=this.validateSpotParam();}}}return b;};YMap.RegisterParam.prototype.validateRouteParam=function(){if(this.params.routeID==""){this.error.param="routeID";this.error.type=RegisterParam.ERR_NO_PARAM;
return false;}if(this.getByte(this.params.name)>RegisterParam.MAX_ROUTE_NAME){this.error.param="name";this.error.over=RegisterParam.MAX_ROUTE_NAME;this.error.type=RegisterParam.ERR_OVER_PARAM;return false;}return true;};YMap.RegisterParam.prototype.validateSpotParam=function(a){var b=RegisterParam.MAX_NAME;if(a&&a==RegisterParam.CAR_TYPE_PANASONIC){b=RegisterParam.MAX_NAME_PANA;}if(!this.isLatLng(this.params.lat)){this.error.param="lat";
this.error.type=RegisterParam.ERR_NO_PARAM;return false;}else{if(!this.isLatLng(this.params.lon)){this.error.param="lon";this.error.type=RegisterParam.ERR_NO_PARAM;return false;}}if(this.params.name==null){this.error.param="name";this.error.type=RegisterParam.ERR_NO_PARAM;return false;}if(this.getByte(this.params.name)>b){this.error.param="name";this.error.over=b;this.error.type=RegisterParam.ERR_OVER_PARAM;
return false;}if(this.params.check=="on"){this.params.check="on";}else{this.params.check="off";}if(this.params.datum=="wgs"){this.params.datum="wgs";}else{this.params.datum="tky";}return true;};YMap.RegisterParam.prototype.validatePoixParam=function(a){var c=RegisterParam.MAX_ADDRESS;var b=RegisterParam.MAX_POIX_MEMO;if(a&&a==RegisterParam.CAR_TYPE_PANASONIC){c=RegisterParam.MAX_ADDRESS_PANA;}if(!this.validateSpotParam(a)){return false;
}if(this.params.poixid==null){this.error.param="poixid";this.error.type=RegisterParam.ERR_NO_PARAM;return false;}if(this.getByte(this.params.tel)>RegisterParam.MAX_TEL){this.error.param="tel";this.error.over=RegisterParam.MAX_TEL;this.error.type=RegisterParam.ERR_OVER_PARAM;return false;}if(this.getByte(this.params.address)>c){this.error.param="address";this.error.over=RegisterParam.max_address;this.error.type=RegisterParam.ERR_OVER_PARAM;
return false;}if(this.getByte(this.params.poixmemo)>RegisterParam.MAX_POIX_MEMO){this.error.param="poixmemo";this.error.over=RegisterParam.MAX_POIX_MEMO;this.error.type=RegisterParam.ERR_OVER_PARAM;return false;}return true;};YMap.RegisterParam.prototype.getByte=function(e){e=e.replace(/[\s|　]/g," ");e=e.replace(/^\s/,"");e=e.replace(/\s$/,"");var b=0;for(var a=0;a<e.length;a++){var g=e.charCodeAt(a);
if((g>=0&&g<129)||(g==63728)||(g>=65377&&g<65440)||(g>=63729&&g<63732)){b++;}}var d=e.length-(b/2);var f=d;return f;};YMap.RegisterParam.prototype.checkStr=function(a){a=a.replace(/>/g,"&gt;");a=a.replace(/</g,"&lt;");a=a.replace(/'/g,"&#39;");a=a.replace(/"/g,"&quot;");return a;};YMap.RegisterParam.prototype.isLatLng=function(b){var a=true;if(!b||b==""){a=false;}else{if(isNaN(b)){a=false;}}return a;
};YMap.RegisterParam.prototype.buildMtfUrl=function(h){var g="";if(h=="mobile"&&this.params.mtm!=""){g=this.params.mtm;}else{if(h=="pc"&&this.params.mtf!=""){g=this.params.mtf;}else{var e="";var c="";if(h=="mobile"){title=this.params.mtm_name;page=this.urls.map_mobile;h="mobile";}else{title=this.params.mtf_name;page=this.urls.map_pc;h="pc";}var a=title||this.params.name||"スポット";var b=page+"lat="+this.params.lat+"&lon="+this.params.lon+"&datum="+this.params.datum;
var f=document.URL;var i=f.indexOf("#");if(i>0){f=f.slice(0,i);}var d={type:h,name:a,url:b,done:f};var g=this.urls.mtf+this.buildQueryString(d);}}return g;};YMap.RegisterParam.prototype.buildPopupUrl=function(b){var a=this.urls.register;var c={};c.prop=this.params.prop;c.name=this.params.name;if(b==RegisterParam.PTYPE_ROUTE){c.ptype=RegisterParam.PTYPE_ROUTE;c.routeID=this.params.routeID;}else{c.lat=this.params.lat;
c.lon=this.params.lon;c.datum=this.params.datum;c.check=this.params.check;if(b==RegisterParam.PTYPE_POIX){c.address=this.params.address;c.tel=this.params.tel;c.ptype=RegisterParam.PTYPE_POIX;}else{c.ptype=RegisterParam.PTYPE_SPOT;}}a+=this.buildQueryString(c);return a;};YMap.RegisterParam.prototype.buildQueryString=function(c){var b=[];for(var a in c){b.push(a+"="+encodeURIComponent(c[a]));}return b.join("&");
};
