function PostLocation(a){this.pluginPath=a+"/";this.initIcon();this.ajax_url=this.pluginPath+"postlocation-ajax.php?"}PostLocation.prototype={pluginPath:null,iconPath:null,icons:new Array(),iconInfo:new Array(),categoryIcons:{},loadExtent:null,map:null,geocoder:null,projection:null,locations:[],geoXml:[],MOVE:0,POINT:1,POLYLINE:2,POLYGON:3,postLinks:[],mapMoveListener:null,markerClickListener:null,markerMouseOverListener:null,markerMouseOutListener:null,wmsLayer:new Array(),wmsOverlay:new Array(),shownWMSIdx:-1,useOpacity:false,tmpIdx:-1,tmpMarkers:null,tmpConnections:null,postID:-1,maxBounds:null,ajax_url:"",ajax:null};
PostLocation.prototype.createHttpRequest=function(){if(window.XMLHttpRequest){this.ajax=new XMLHttpRequest()}else{if(window.ActiveXObject){try{this.ajax=new ActiveXObject("Msxml2.XMLHTTP")
}catch(a){this.ajax=new ActiveXObject("Microsoft.XMLHTTP")}}}};PostLocation.prototype.init=function(c,d,b){if(GBrowserIsCompatible()){var a=this;
if(b.cursor){GDraggableObject.setDraggableCursor(b.cursor)}this.map=new GMap2(document.getElementById(c));this.geocoder=new GClientGeocoder();
this.map.enableDoubleClickZoom();this.map.enableContinuousZoom()}};PostLocation.prototype.setIcons=function(b){for(var a=b.length-1;
a>=0;a-=2){this.iconInfo[b[a-1]]=this.iconInfo[b[a]]}};PostLocation.prototype.setCategoryIcons=function(b){for(var a=b.length-1;a>=0;
a-=2){this.categoryIcons[b[a-1]]=this.getIcon(b[a])}};PostLocation.prototype.getIcon=function(c){if(c==undefined||c==null){return this.icons.list
}if(this.categoryIcons[c]){return this.categoryIcons[c]}if(this.icons[c]){return this.icons[c]}if(!isNaN(c)){return this.createIcon(c)
}if(c.match(/^http/)||c.match(/^\//)){var b=c.split(",");if(b[0]){var a=(b.length>1)?Math.min(64,b[1]):32;var d=(b.length>2)?Math.min(64,b[2]):32;
icon=new OpenLayers.Icon(b[0],new OpenLayers.Size(a,d),new OpenLayers.Pixel(-a/2,-d/2))}this.icons[c]=icon;return icon}else{return this.createIcon(c)
}return null};PostLocation.prototype.createIcon=function(c){if(!this.iconInfo[c]){c="list"}var b=this.iconInfo[c];var a=new GIcon();
a.image=this.iconPath+b[0];a.iconSize=(b.length>2)?new GSize(b[1],b[2]):new GSize(32,32);a.iconAnchor=(b.length>4)?new GPoint(b[3],b[4]):new GPoint(16,16);
if(b.length>7){a.shadow=this.iconPath+b[5];a.shadowSize=new GSize(b[6],b[7])}this.icons[c]=a;return this.icons[c]};PostLocation.prototype.textToGeometries=function(a,e,f){var d=new Array();
for(var c=0;c<f.length;c++){switch(f[c][0]){case this.POINT:var b=e;if(b==-1){b=f[c][1]}d.push(this.createPoint(a,b,new GLatLng(f[c][3],f[c][2])));
break}}return d};PostLocation.prototype.getGeometryObject=function(a){return a[2]};PostLocation.prototype.createPoint=function(c,d,a){var b=this.createMarker(c,d,a);
return this.createPointGeometry(d,b)};PostLocation.prototype.createMarker=function(c,e,a){var b;b=new GMarker(a,{icon:this.getIcon(e)});
var d=this;GEvent.addListener(b,"click",function(){d.map.closeInfoWindow();d.showTmpMarker(c);d.openPopupWindow(b.getPoint(),c)});
return b};PostLocation.prototype.createTmpMarker=function(c,a){var b;b=new GMarker(a,{icon:this.getIcon("active"),zIndexProcess:this.orderOfCreation});
var d=this;GEvent.addListener(b,"click",function(){if(d.map.getInfoWindow().isHidden()){d.openPopupWindow(b.getPoint(),c)}});GEvent.addListener(b,"dblclick",function(){d.map.setZoom(d.getLocationZoom(c))
});return b};PostLocation.prototype.orderOfCreation=function(c,a){return 1800000-Math.ceil(c.getPoint().lng()*10000)};PostLocation.prototype.createPointGeometry=function(b,a){return new Array(this.POINT,b,a)
};PostLocation.prototype.isPoint=function(a){return a[0]==this.POINT};PostLocation.prototype.getPointIconId=function(a){return a[1]
};PostLocation.prototype.setPointIconId=function(b,a){b[1]=a};PostLocation.prototype.createConnection=function(e,h){if(!e||!h){return
}var d=[];var a=0;for(var g=0;g<e.length;g+=2){var f=h[e[g]];var c=h[e[g+1]];if(f&&c){var b=new GPolyline([f[2].getPoint(),c[2].getPoint()],"#FF0000",2,0.5);
this.map.addOverlay(b);d[a++]=b}}return d};PostLocation.prototype.addLocationByText=function(f,e,c,b,d,h,a){var g;if(!h){if(d==-1){d=0
}g=new Array(this.createPoint(this.locations.length,d,new GLatLng(c,e)))}else{g=this.textToGeometries(this.locations.length,d,h)}this.locations.push(new Array(f,e,c,b,d,g,a))
};PostLocation.prototype.clearLocations=function(){for(var b=0;b<this.locations.length;b++){var c=this.getLocationGeometries(b);for(var a=0;
a<c.length;a++){this.map.removeOverlay(this.getGeometryObject(c[a]))}delete this.locations[b]}this.locations.length=0};PostLocation.prototype.getLocationPostId=function(a){return this.locations[a][0]
};PostLocation.prototype.getLocationPoint=function(a){return new GLatLng(this.locations[a][2],this.locations[a][1])};PostLocation.prototype.getLocationZoom=function(a){return this.locations[a][3]
};PostLocation.prototype.getLocationGeometries=function(a){return this.locations[a][5]};PostLocation.prototype.getLocationConnection=function(a){return this.locations[a][6]
};PostLocation.prototype.createLocationOverlay=function(){for(var b=this.locations.length-1;b>=0;b--){var c=this.getLocationGeometries(b);
for(var a=0;a<c.length;a++){this.map.addOverlay(this.getGeometryObject(c[a]))}}};PostLocation.prototype.postIdToLocationIndex=function(b){for(var a=0;
a<this.locations.length;a++){if(this.locations[a][0]==b){return a}}return -1};PostLocation.prototype.setMarkCenter=function(a){if(document.getElementById("postlocation_markers").value.length==0){this.newPostMarker()
}this.setCenter(a)};PostLocation.prototype.setCenter=function(c){var a=c.split(",");var b=this.map.getZoom();this.map.setZoom(Number(a[2]));
this.map.panTo(new GLatLng(a[1],a[0]))};PostLocation.prototype.showGeoXml=function(b){this.clearGeoXml();var c=b.split("\n");for(var a=0;
a<c.length;a++){this.geoXml[a]=new GGeoXml(c[a]);this.map.addOverlay(this.geoXml[a])}};PostLocation.prototype.clearGeoXml=function(){for(var a=0;
a<this.geoXml.length;a++){this.geoXml[a].remove();delete this.geoXml[a]}};PostLocation.prototype.showPostIdTmpMarker=function(b){var a=this.postIdToLocationIndex(b);
if(a>=0){this.map.closeInfoWindow();this.showTmpMarker(a,0)}};PostLocation.prototype.showPostIdPopup=function(c){var b=this.postIdToLocationIndex(c);
if(b>=0){this.map.closeInfoWindow();this.showTmpMarker(b,0);var a=this.getLocationPoint(b);this.openPopupWindow(a,b)}};PostLocation.prototype.showPostPopup=function(b){this.map.closeInfoWindow();
this.showTmpMarker(b,0);var a=this.showPostCenter(b);this.openPopupWindow(a,b)};PostLocation.prototype.closePopup=function(){this.map.closeInfoWindow();
this.clearTmpMarker()};PostLocation.prototype.showPostCenter=function(c,b){var a=this.getLocationPoint(c);if(b!=undefined&&b==0){}else{if(!b){b=0
}var d=Math.min(this.map.getCurrentMapType().getMaximumResolution(),this.getLocationZoom(c)+b);this.map.setZoom(d)}this.map.panTo(a);
this.showTmpMarker(c,0);return a};PostLocation.prototype.showTmpMarker=function(b,e){if(this.postID!=-1){return}this.clearTmpMarker();
this.tmpIdx=b;this.tmpMarkers=new Array();var d=this.getLocationGeometries(b);for(var c=d.length-1;c>=0;c--){if(this.isPoint(d[c])){var a=this.getGeometryObject(d[c]);
this.tmpMarkers[c]=this.createTmpMarker(b,a.getPoint());this.map.addOverlay(this.tmpMarkers[c])}}this.tmpConnections=this.createConnection(this.getLocationConnection(b),d)
};PostLocation.prototype.clearTmpMarker=function(){this.tmpIdx=-1;if(this.tmpMarkers){for(var a=0;a<this.tmpMarkers.length;a++){this.tmpMarkers[a].remove();
delete this.tmpMarkers[a]}delete this.tmpMarkers}if(this.tmpConnections){for(var a=0;a<this.tmpConnections.length;a++){this.map.removeOverlay(this.tmpConnections[a]);
delete this.tmpConnections[a]}delete this.tmpConnections}};PostLocation.prototype.openPopupWindow=function(d,a){if(!this.ajax){this.createHttpRequest()
}var c=this.ajax_url+"&thumbnail";c+="&id="+this.getLocationPostId(a);this.ajax.open("GET",c);var b=this;this.ajax.onreadystatechange=function(){if(b.ajax.readyState==4&&b.ajax.status==200){values=b.ajax.responseText.split("\t");
var e="";if(values.length>5&&values[5].length>0){e='<img src="'+values[5]+'" width="80" style="float:left;padding-right:3px;"/>'}b.map.openInfoWindow(d,'<div style="width:200px;overflow:hide;font-size:11px;line-height:120%;padding:12px 0px;"><a href="'+values[1]+'">'+values[2]+"</a>"+e+'<div align="right" style="padding:2px;color:gray;">('+values[4]+")</div>"+values[3]+"</div>")
}};this.ajax.send("")};PostLocation.prototype.getCookie=function(a){a+="=";var d=document.cookie.split(";");for(var b=0;b<d.length;
b++){var e=d[b];while(e.charAt(0)==" "){e=e.substring(1,e.length)}if(e.indexOf(a)==0){return e.substring(a.length,e.length)}}return null
};PostLocation.prototype.addMapTypeControl=function(){this.map.addControl(new GMapTypeControl(1))};PostLocation.prototype.addSmallMapTypeControl=function(){var i=this;
var h=document.createElement("table");var b=document.createElement("tbody");var f=document.createElement("tr");h.style.position="absolute";
h.style.left="28px";h.style.top="6px";h.style.border="none";h.cellSpacing=0;h.cellPadding=0;var a=document.createElement("td");a.style.padding="0px";
var c=document.createElement("div");c.onclick=function(){i.map.setMapType(G_NORMAL_MAP)};c.style.border="1px solid black";c.style.backgroundColor="white";
c.style.marginRight="1px";c.style.padding="1px 3px 1px 3px";c.style.fontSize="11px";c.style.cursor="pointer";c.innerHTML="地図";a.appendChild(c);
f.appendChild(a);var e=c;a=document.createElement("td");a.style.padding="0px";c=document.createElement("div");c.onclick=function(){i.map.setMapType(G_SATELLITE_MAP)
};c.style.border="1px solid black";c.style.backgroundColor="white";c.style.marginRight="1px";c.style.padding="1px 3px 1px 3px";c.style.fontSize="11px";
c.style.cursor="pointer";c.innerHTML="写真";a.appendChild(c);f.appendChild(a);var d=c;b.appendChild(f);h.appendChild(b);this.map.getContainer().appendChild(h);
var g=this.map.getCurrentMapType();if(g==G_SATELLITE_MAP){e.style.fontWeight="normal";d.style.fontWeight="bold"}else{if(g==G_NORMAL_MAP){e.style.fontWeight="bold";
d.style.fontWeight="normal"}}GEvent.addListener(this.map,"maptypechanged",function(){var j=i.map.getCurrentMapType();if(j==G_SATELLITE_MAP){e.style.fontWeight="normal";
d.style.fontWeight="bold"}else{if(j==G_NORMAL_MAP){e.style.fontWeight="bold";d.style.fontWeight="normal"}}})};PostLocation.prototype.addMapTypeControl=function(){this.map.addControl(new GMapTypeControl(1))
};PostLocation.prototype.addWMSOverlay=function(e,f,c){return;var a=this;var d=new GTileLayer(new GCopyrightCollection(),0,17);d.opacity=c;
d.getTileUrl=function(h,g){return a.getWMSTileUrl(f,h,g)};d.getOpacity=function(){return this.opacity};var b=new GTileLayerOverlay(d);
this.wmsOverlay.push(new Array(e,b,d,c))};PostLocation.prototype.changeWMSOverlay=function(a){if(this.shownWMSIdx==a){return}document.cookie="wmsidx="+a+"; path=/;";
if(this.shownWMSIdx!=-1){this.wmsOverlay[this.shownWMSIdx][1].remove()}if(a>=0){this.shownWMSIdx=a;this.wmsOverlay[a][2].opacity=(this.useOpacity)?this.wmsOverlay[a][3]:1;
this.map.addOverlay(this.wmsOverlay[a][1])}else{this.shownWMSIdx=-1}};PostLocation.prototype.setWMSOpacity=function(a){this.useOpacity=a;
document.cookie="wmsopacity="+(a?1:0)+"; path=/;";if(this.shownWMSIdx!=-1){this.wmsOverlay[this.shownWMSIdx][2].opacity=(this.useOpacity)?this.wmsOverlay[this.shownWMSIdx][3]:1;
this.wmsOverlay[this.shownWMSIdx][1].remove();this.map.addOverlay(this.wmsOverlay[this.shownWMSIdx][1])}};PostLocation.prototype.getWMSTileUrl=function(a,i,p){this.projection=this.map.getCurrentMapType().getProjection();
var n=new GPoint(i.x*256,i.y*256);var m=new GPoint(n.x+255,n.y+255);var o=this.projection.fromPixelToLatLng(n,p);var l=this.projection.fromPixelToLatLng(m,p);
var f=o.lat();var h=o.lng();var d=l.lat();var g=l.lng();var b=Math.min(f,d);var j=Math.min(h,g);var c=Math.max(f,d);var k=Math.max(h,g);
var e="layers=unknown";return a+"&WIDTH=256&HEIGHT=256&BBOX="+j+","+b+","+k+","+c};PostLocation.prototype.addWMSControl=function(b,g){return;
var m=this;if(!b){b=28}if(!g){g=6}var l=this.getCookie("wmsidx");if(l==undefined||l==null){l=-1}var k=this.getCookie("wmsopacity");
this.useOpacity=(k!=undefined&&k!=null&&k==1);var a=document.createElement("div");a.style.position="absolute";a.style.left=b+"px";
a.style.top=g+"px";var j=document.createElement("select");j.onchange=function(){m.changeWMSOverlay(this.options[this.selectedIndex].value)
};j.onkeyup=function(){m.changeWMSOverlay(this.options[this.selectedIndex].value)};var f=document.createElement("option");f.innerHTML="- レイヤを選択 -";
f.value=-1;j.appendChild(f);for(var e=0;e<this.wmsOverlay.length;e++){f=document.createElement("option");f.innerHTML=this.wmsOverlay[e][0];
f.value=e;if(e==l){f.selected=true}j.appendChild(f)}a.appendChild(j);a.appendChild(document.createElement("br"));var c=document.createElement("label");
var h=document.createElement("input");h.type="checkbox";h.onclick=function(){m.setWMSOpacity(this.checked)};c.appendChild(h);if(this.useOpacity){h.checked=true
}var d=document.createElement("img");d.src=this.pluginPath+"icons/opacity.png";d.title="半透明";c.appendChild(d);a.appendChild(c);this.map.getContainer().appendChild(a);
this.changeWMSOverlay(l)};PostLocation.prototype.showAddress=function(a){if(this.geocoder){var b=this;this.geocoder.getLatLng(a,function(c){if(!c){alert(a+" \u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3002")
}else{b.map.setCenter(c)}})}};PostLocation.prototype.getDivWidth=function(a){return document.layers?a.clip.width:(a.offsetWidth||a.style.pixelWidth||0)
};
