/*
MAPSTRACTION   v2.0.17   http://www.mapstraction.com

Copyright (c) 2011 Tom Carden, Steve Coast, Mikel Maron, Andrew Turner, Henri Bergius, Rob Moran, Derek Fowler, Gary Gale
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
 * Neither the name of the Mapstraction nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function(){var g=null;var c="core";var d;var e=document.getElementsByTagName("script");for(var h=0;h<e.length;h++){var k=e[h].src.replace(/%20/g,"").match(/^(.*?)mxn\.js(\?\(\[?(.*?)\]?\))?$/);if(k!==null){d=k[1];if(k[3]){var b=k[3].split(",[");g=b[0].replace("]","");if(b[1]){c+=","+b[1]}}break}}if(g===null||g=="none"){return}g=g.replace(/ /g,"").split(",");c=c.replace(/ /g,"").split(",");var l='<script type="text/javascript" src="'+d+"mxn.";var m='.js"><\/script>';var a=[];for(h=0;h<c.length;h++){a.push(l+c[h]+m);for(var f=0;f<g.length;f++){a.push(l+g[f]+"."+c[h]+m)}}document.write(a.join(""))})();(function(){var c={};var b=function(i,h,g,e,f){if(!d(i,h,g)){throw"Method "+g+" of object "+h+" is not supported by API "+i+". Are you missing a script tag?"}if(typeof(c[i][h].deferrable)!="undefined"&&c[i][h].deferrable[g]===true){a.deferUntilLoaded.call(e,function(){return c[i][h][g].apply(e,f)})}else{return c[i][h][g].apply(e,f)}};var d=function(g,f,e){if(typeof(c[g])=="undefined"){throw"API "+g+" not loaded. Are you missing a script tag?"}if(typeof(c[g][f])=="undefined"){throw"Object definition "+f+" in API "+g+" not loaded. Are you missing a script tag?"}return typeof(c[g][f][e])=="function"};var a=window.mxn={register:function(f,e){if(!c.hasOwnProperty(f)){c[f]={}}a.util.merge(c[f],e)},addProxyMethods:function(g,j,f){for(var e=0;e<j.length;e++){var h=j[e];if(f){g.prototype[h]=new Function("return this.invoker.go('"+h+"', arguments, { overrideApi: true } );")}else{g.prototype[h]=new Function("return this.invoker.go('"+h+"', arguments);")}}},checkLoad:function(f){if(this.loaded[this.api]===false){var e=this;this.onload[this.api].push(function(){f.callee.apply(e,f)});return true}return false},deferUntilLoaded:function(e){if(this.loaded[this.api]===false){var f=this;this.onload[this.api].push(e)}else{e.call(this)}},addEvents:function(f,h){for(var e=0;e<h.length;e++){var g=h[e];if(g in f){throw"Event or method "+g+" already declared."}f[g]=new a.Event(g,f)}}};a.Event=function(g,f){var e=[];if(!g){throw"Event name must be provided"}this.addHandler=function(i,h){e.push({context:h,handler:i})};this.removeHandler=function(k,h){for(var j=0;j<e.length;j++){if(e[j].handler==k&&e[j].context==h){e.splice(j,1)}}};this.removeAllHandlers=function(){e=[]};this.fire=function(k){var h=[g,f,k];for(var j=0;j<e.length;j++){e[j].handler.apply(e[j].context,h)}}};a.Invoker=function(g,h,k){var j=g;var f=h;var e=k;var i={overrideApi:false,context:null,fallback:null};this.go=function(o,m,l){m=typeof(m)!="undefined"?Array.prototype.slice.apply(m):[];if(typeof(l)=="undefined"){l=i}var n;if(l.overrideApi){n=m.shift()}else{n=e.apply(j)}if(typeof(n)!="string"){throw"API ID not available."}if(typeof(l.context)!="undefined"&&l.context!==null){m.push(l.context)}if(typeof(l.fallback)=="function"&&!d(n,f,o)){return l.fallback.apply(j,m)}else{return b(n,f,o,j,m)}}};a.util={merge:function(g,e){for(var f in e){if(e.hasOwnProperty(f)){if(!g.hasOwnProperty(f)||typeof(g[f])!=="object"||typeof(e[f])!=="object"){g[f]=e[f]}else{a.util.merge(g[f],e[f])}}}},$m:function(){var g=[];for(var f=0;f<arguments.length;f++){var e=arguments[f];if(typeof(e)=="string"){e=document.getElementById(e)}if(arguments.length==1){return e}g.push(e)}return g},loadScript:function(i,j){var f=document.createElement("script");f.type="text/javascript";f.src=i;if(j){if(f.addEventListener){f.addEventListener("load",j,true)}else{if(f.attachEvent){var e=false;f.attachEvent("onreadystatechange",function(){if(!e&&document.readyState==="complete"){e=true;j()}})}}}var g=document.getElementsByTagName("head")[0];g.appendChild(f);return},convertLatLonXY_Yahoo:function(e,l){var h=1<<(26-l);var j=h/360;var k=h/(2*Math.PI);var g=new YCoordPoint(h/2,h/2);var i=new YCoordPoint();i.x=Math.floor(g.x+e.lon*j);var f=Math.sin(e.lat*Math.PI/180);i.y=Math.floor(g.y+0.5*Math.log((1+f)/(1-f))*-k);return i},loadStyle:function(e){var f=document.createElement("link");f.type="text/css";f.rel="stylesheet";f.href=e;document.getElementsByTagName("head")[0].appendChild(f);return},getStyle:function(e,g){var f;if(e.currentStyle){f=e.currentStyle[g]}else{if(window.getComputedStyle){f=window.getComputedStyle(e,"").getPropertyValue(g)}}return f},lonToMetres:function(f,e){return f*(111200*Math.cos(e*(Math.PI/180)))},metresToLon:function(e,f){return e/(111200*Math.cos(f*(Math.PI/180)))},KMToMiles:function(e){return e/1.609344},milesToKM:function(e){return e*1.609344},getDegreesFromGoogleZoomLevel:function(f,e){return(360*f)/(Math.pow(2,e+8))},getGoogleZoomLevelFromDegrees:function(f,e){return a.util.logN((360*f)/e,2)-8},logN:function(e,f){return Math.log(e)/Math.log(f)},getAvailableProviders:function(){var f=[];for(var e in c){if(c.hasOwnProperty(e)){f.push(e)}}return f},stringFormat:function(g){var f=/\{\d+\}/g;var e=Array.prototype.slice.apply(arguments);e.shift();return g.replace(f,function(i){var h=i.slice(1,-1);return e[h]})},traverse:function(h){var f=Array.prototype.slice.apply(arguments);f.shift();var e=h;while(typeof(e)!="undefined"&&e!==null&&f.length>0){var g=f.shift();e=g(e)}}};a.util.Color=function(){if(arguments.length==3){this.red=arguments[0];this.green=arguments[1];this.blue=arguments[2]}else{if(arguments.length==1){this.setHexColor(arguments[0])}}};a.util.Color.prototype.reHex=/^#?([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;a.util.Color.prototype.setHexColor=function(f){var e=f.match(this.reHex);if(e){f=e[1]}else{throw"Invalid HEX color format, expected #000, 000, #000000 or 000000"}if(f.length==3){f=f.replace(/\w/g,function(g){return g.concat(g)})}this.red=parseInt(f.substr(0,2),16);this.green=parseInt(f.substr(2,2),16);this.blue=parseInt(f.substr(4,2),16)};a.util.Color.prototype.getHexColor=function(){var f=this.blue|(this.green<<8)|(this.red<<16);var e=f.toString(16).toUpperCase();if(e.length<6){e="0"+e}return"#"+e}})();