function FonectaMap(a){if(typeof a==="undefined"||a==null){a=FonectaMap.options()
}this.initParams=a;
this.markers=new Array();
this.started=false
}FonectaMap.options=function(){return{url:"http://maps.fonecta.fi",mapAreaId:"MapArea",iframeid:"MapArea_iframe",width:500,height:500,centerX:62.241716,centerY:25.74946,scale:9,showOverview:true,showTileSwitcher:true,showSmallControls:false,storeLocation:false,callbackUrl:null,tooltipsEnabled:false,showCrosshair:false,locationCallback:null,domain:null}
};
FonectaMap.prototype.start=function(){var b=document.getElementById(this.initParams.mapAreaId);
if(b!=null){b.style.width=this.initParams.width;
b.style.height=this.initParams.height;
b.innerHTML="";
var a=document.createElement("iframe");
a.src=this.makeIframeUrl();
a.width=this.initParams.width;
a.height=this.initParams.height;
a.name=this.initParams.iframeid;
a.id=this.initParams.iframeid;
a.frameBorder="No";
a.scrolling="No";
b.appendChild(a);
this.started=true
}};
FonectaMap.prototype.changeSize=function(b,a){if(!this.started){return false
}this.started=false;
this.initParams.width=b;
this.initParams.height=a;
this.refreshMap();
return this.started
};
FonectaMap.prototype.geocode=function(a,b,c){window[this.initParams.iframeid].MapRemote.geocodeAddresses([a],[b],0,0,false,false,c)
};
FonectaMap.prototype.sendLocation=function(a){if(!this.started){return false
}this.started=false;
this.initParams.callbackUrl=a;
this.refreshMap();
this.initParams.callbackUrl=null;
return this.started
};
FonectaMap.prototype.addMarkerByAddress=function(g,b,f,e,d,c){if(f==null){return
}if(this.markers==null){this.markers=new Array()
}var a=new Marker(g,null,null,b,f,e,d,c);
this.markers.push(a)
};
FonectaMap.prototype.addMarkerByCoordinates=function(g,a,f,e,d,c){if(a==null||f==null){return
}if(this.markers==null){this.markers=new Array()
}var b=new Marker(g,a,f,null,null,e,d,c);
this.markers.push(b)
};
FonectaMap.prototype.removeMarker=function(c){var b=new Array();
for(var a in this.markers){if(this.markers[a].id!=c){b.push(this.markers[a])
}}this.markers=b
};
FonectaMap.prototype.refreshMap=function(){var b=document.getElementById(this.initParams.mapAreaId);
if(b!=null){b.style.width=this.initParams.width;
b.style.height=this.initParams.height;
var a=document.getElementById(this.initParams.iframeid);
a.src=this.makeIframeUrl();
a.width=this.initParams.width;
a.height=this.initParams.height;
a.name=this.initParams.iframeid;
a.id=this.initParams.iframeid;
this.started=true
}};
FonectaMap.prototype.makeIframeUrl=function(){var b=this.initParams.url+"/kartat/map.fon?";
b+="m.a="+this.initParams.width;
b+="&m.b="+this.initParams.height;
b+="&m.c="+this.initParams.centerX;
b+="&m.d="+this.initParams.centerY;
b+="&m.e=Map";
b+="&m.f="+this.initParams.scale;
for(var a=0;
a<this.markers.length;
a++){if(typeof this.markers[a].centerX!=="undefined"&&this.markers[a].centerX!=null){b+="&m.p["+a+"].la="+this.markers[a].centerX
}if(typeof this.markers[a].centerY!=="undefined"&&this.markers[a].centerY!=null){b+="&m.p["+a+"].lo="+this.markers[a].centerY
}if(typeof this.markers[a].balloonText!=="undefined"&&this.markers[a].balloonText!=null){b+="&m.p["+a+"].t="+this.markers[a].balloonText
}if(typeof this.markers[a].number!=="undefined"&&this.markers[a].number!=null){b+="&m.p["+a+"].n="+this.markers[a].number
}if(typeof this.markers[a].type!=="undefined"&&this.markers[a].type!=null){b+="&m.p["+a+"].ty="+this.markers[a].type
}if(typeof this.markers[a].address!=="undefined"&&this.markers[a].address!=null){b+="&m.p["+a+"].a="+this.markers[a].address
}if(typeof this.markers[a].city!=="undefined"&&this.markers[a].city!=null){b+="&m.p["+a+"].c="+this.markers[a].city
}}b+="&m.q="+(this.initParams.storeLocation?"true":"false");
b+="&m.g="+(this.initParams.showOverview?"true":"false");
b+="&m.h="+(this.initParams.showTileSwitcher?"true":"false");
b+="&m.i="+(this.initParams.showSmallControls?"true":"false");
b+="&m.j="+(this.initParams.tooltipsEnabled?"true":"false");
if(typeof this.initParams.callbackUrl!=="undefined"&&this.initParams.callbackUrl!=null){b+="&m.r="+this.initParams.callbackUrl
}if(typeof this.initParams.address!=="undefined"&&this.initParams.address!=null){b+="&m.s="+this.initParams.address
}if(typeof this.initParams.city!=="undefined"&&this.initParams.city!=null){b+="&m.t="+this.initParams.city
}if(typeof this.initParams.clickUrl!=="undefined"&&this.initParams.clickUrl!=null){b+="&m.u="+encodeURIComponent(this.initParams.clickUrl.replace(/&/g,"__ampresand__"))
}if(typeof this.initParams.clickUrlTarget!=="undefined"&&this.initParams.clickUrlTarget!=null){b+="&m.v="+this.initParams.clickUrlTarget
}b+="&m.x="+(this.initParams.showCrosshair?"true":"false");
if(typeof this.initParams.locationCallback!=="undefined"&&this.initParams.locationCallback!=null){b+="&m.y="+this.initParams.locationCallback
}if(typeof this.initParams.domain!=="undefined"&&this.initParams.domain!=null){b+="&m.z="+this.initParams.domain
}return b
};
FonectaMap.prototype.toggleDraggablePois=function(a,b){document.getElementById(this.initParams.iframeid).contentWindow.naytaRaahattavatPinnit(a,b)
};
function Marker(h,a,g,b,f,e,d,c){this.id=h;
this.centerX=(typeof a!=="undefined"?a:null);
this.centerY=(typeof g!=="undefined"?g:null);
this.address=(typeof b!=="undefined"?b:null);
this.city=(typeof f!=="undefined"?f:null);
this.balloonText=(typeof e!=="undefined"?e:null);
this.number=(typeof d!=="undefined"?d:"");
this.type=(typeof c!=="undefined"?c:"default")
};
