(function(){var g=null,i,k=this;function l(a,b){var c=a.split("."),d=k;!(c[0]in d)&&d.execScript&&d.execScript("var "+c[0]);for(var e;c.length&&(e=c.shift());)!c.length&&m(b)?d[e]=b:d=d[e]?d[e]:d[e]={}}function aa(){}
function n(a){var b=typeof a;if(b=="object")if(a){if(a instanceof Array)return"array";else if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if(c=="[object Window]")return"object";if(c=="[object Array]"||typeof a.length=="number"&&typeof a.splice!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("splice"))return"array";if(c=="[object Function]"||typeof a.call!="undefined"&&typeof a.propertyIsEnumerable!="undefined"&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
else if(b=="function"&&typeof a.call=="undefined")return"object";return b}function m(a){return a!==void 0}function o(a){return n(a)=="array"}function p(a){var b=n(a);return b=="array"||b=="object"&&typeof a.length=="number"}function q(a){return typeof a=="string"}function r(a){a=n(a);return a=="object"||a=="array"||a=="function"}Math.floor(Math.random()*2147483648).toString(36);var ba=Date.now||function(){return+new Date};var ca={};var da=/^[a-zA-Z0-9\-_.!~*'()]*$/;function s(a){a=String(a);return!da.test(a)?encodeURIComponent(a):a}
function ea(a){for(var b=0,c=String(t).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),a=String(a).replace(/^[\s\xa0]+|[\s\xa0]+$/g,"").split("."),d=Math.max(c.length,a.length),e=0;b==0&&e<d;e++){var f=c[e]||"",h=a[e]||"",j=RegExp("(\\d*)(\\D*)","g"),va=RegExp("(\\d*)(\\D*)","g");do{var w=j.exec(f)||["","",""],x=va.exec(h)||["","",""];if(w[0].length==0&&x[0].length==0)break;b=u(w[1].length==0?0:parseInt(w[1],10),x[1].length==0?0:parseInt(x[1],10))||u(w[2].length==0,x[2].length==0)||u(w[2],x[2])}while(b==
0)}return b}function u(a,b){if(a<b)return-1;else if(a>b)return 1;return 0};var v=Array.prototype,fa=v.indexOf?function(a,b,c){return v.indexOf.call(a,b,c)}:function(a,b,c){c=c==g?0:c<0?Math.max(0,a.length+c):c;if(q(a))return!q(b)||b.length!=1?-1:a.indexOf(b,c);for(;c<a.length;c++)if(c in a&&a[c]===b)return c;return-1},ga=v.forEach?function(a,b,c){v.forEach.call(a,b,c)}:function(a,b,c){for(var d=a.length,e=q(a)?a.split(""):a,f=0;f<d;f++)f in e&&b.call(c,e[f],f,a)};
function ha(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c],e;if(o(d)||(e=p(d))&&d.hasOwnProperty("callee"))a.push.apply(a,d);else if(e)for(var f=a.length,h=d.length,j=0;j<h;j++)a[f+j]=d[j];else a.push(d)}};function ia(a,b){for(var c in a)b.call(void 0,a[c],c,a)}function ja(a){var b=[],c=0,d;for(d in a)b[c++]=a[d];return b}function ka(a){var b=[],c=0,d;for(d in a)b[c++]=d;return b};function la(a){if(typeof a.l=="function")return a.l();if(q(a))return a.split("");if(p(a)){for(var b=[],c=a.length,d=0;d<c;d++)b.push(a[d]);return b}return ja(a)}function ma(a,b,c){if(typeof a.forEach=="function")a.forEach(b,c);else if(p(a)||q(a))ga(a,b,c);else{var d;if(typeof a.o=="function")d=a.o();else if(typeof a.l!="function")if(p(a)||q(a)){d=[];for(var e=a.length,f=0;f<e;f++)d.push(f)}else d=ka(a);else d=void 0;for(var e=la(a),f=e.length,h=0;h<f;h++)b.call(c,e[h],d&&d[h],a)}};function y(a,b){this.h={};this.c=[];var c=arguments.length;if(c>1){if(c%2)throw Error("Uneven number of arguments");for(var d=0;d<c;d+=2)this.set(arguments[d],arguments[d+1])}else if(a){a instanceof y?(c=a.o(),d=a.l()):(c=ka(a),d=ja(a));for(var e=0;e<c.length;e++)this.set(c[e],d[e])}}i=y.prototype;i.b=0;i.A=0;i.l=function(){z(this);for(var a=[],b=0;b<this.c.length;b++)a.push(this.h[this.c[b]]);return a};i.o=function(){z(this);return this.c.concat()};i.i=function(a){return A(this.h,a)};
i.remove=function(a){return A(this.h,a)?(delete this.h[a],this.b--,this.A++,this.c.length>2*this.b&&z(this),!0):!1};function z(a){if(a.b!=a.c.length){for(var b=0,c=0;b<a.c.length;){var d=a.c[b];A(a.h,d)&&(a.c[c++]=d);b++}a.c.length=c}if(a.b!=a.c.length){for(var e={},c=b=0;b<a.c.length;)d=a.c[b],A(e,d)||(a.c[c++]=d,e[d]=1),b++;a.c.length=c}}i.get=function(a,b){return A(this.h,a)?this.h[a]:b};i.set=function(a,b){A(this.h,a)||(this.b++,this.c.push(a),this.A++);this.h[a]=b};i.n=function(){return new y(this)};
function A(a,b){return Object.prototype.hasOwnProperty.call(a,b)};var na=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([\\w\\d\\-\\u0100-\\uffff.%]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$");function B(a,b){var c;a instanceof B?(this.q(b==g?a.e:b),C(this,a.j),D(this,a.t),E(this,a.k),F(this,a.p),G(this,a.m),H(this,a.f.n()),I(this,a.r)):a&&(c=String(a).match(na))?(this.q(!!b),C(this,c[1]||"",!0),D(this,c[2]||"",!0),E(this,c[3]||"",!0),F(this,c[4]),G(this,c[5]||"",!0),H(this,c[6]||"",!0),I(this,c[7]||"",!0)):(this.q(!!b),this.f=new J(g,this,this.e))}i=B.prototype;i.j="";i.t="";i.k="";i.p=g;i.m="";i.r="";i.C=!1;i.e=!1;
i.toString=function(){if(this.d)return this.d;var a=[];this.j&&a.push(K(this.j,oa),":");this.k&&(a.push("//"),this.t&&a.push(K(this.t,oa),"@"),a.push(q(this.k)?encodeURIComponent(this.k):g),this.p!=g&&a.push(":",String(this.p)));this.m&&(this.k&&this.m.charAt(0)!="/"&&a.push("/"),a.push(K(this.m,this.m.charAt(0)=="/"?pa:qa)));var b=String(this.f);b&&a.push("?",b);this.r&&a.push("#",K(this.r,ra));return this.d=a.join("")};
i.n=function(){var a=this.j,b=this.t,c=this.k,d=this.p,e=this.m,f=this.f.n(),h=this.r,j=new B(g,this.e);a&&C(j,a);b&&D(j,b);c&&E(j,c);d&&F(j,d);e&&G(j,e);f&&H(j,f);h&&I(j,h);return j};function C(a,b,c){L(a);delete a.d;a.j=c?b?decodeURIComponent(b):"":b;if(a.j)a.j=a.j.replace(/:$/,"")}function D(a,b,c){L(a);delete a.d;a.t=c?b?decodeURIComponent(b):"":b}function E(a,b,c){L(a);delete a.d;a.k=c?b?decodeURIComponent(b):"":b}
function F(a,b){L(a);delete a.d;if(b){b=Number(b);if(isNaN(b)||b<0)throw Error("Bad port number "+b);a.p=b}else a.p=g}function G(a,b,c){L(a);delete a.d;a.m=c?b?decodeURIComponent(b):"":b}function H(a,b,c){L(a);delete a.d;b instanceof J?(a.f=b,a.f.s=a,a.f.q(a.e)):(c||(b=K(b,sa)),a.f=new J(b,a,a.e))}function ta(a,b,c){L(a);delete a.d;o(c)||(c=[String(c)]);a=a.f;M(a);N(a);b=O(a,b);if(a.i(b)){var d=a.a.get(b);o(d)?a.b-=d.length:a.b--}c.length>0&&(a.a.set(b,c),a.b+=c.length)}
function I(a,b,c){L(a);delete a.d;a.r=c?b?decodeURIComponent(b):"":b}function L(a){if(a.C)throw Error("Tried to modify a read-only Uri");}i.q=function(a){this.e=a;this.f&&this.f.q(a);return this};var ua=/^[a-zA-Z0-9\-_.!~*'():\/;?]*$/;function K(a,b){var c=g;q(a)&&(c=a,ua.test(c)||(c=encodeURI(a)),c.search(b)>=0&&(c=c.replace(b,wa)));return c}function wa(a){a=a.charCodeAt(0);return"%"+(a>>4&15).toString(16)+(a&15).toString(16)}var oa=/[#\/\?@]/g,qa=/[\#\?:]/g,pa=/[\#\?]/g,sa=/[\#\?@]/g,ra=/#/g;
function J(a,b,c){this.g=a||g;this.s=b||g;this.e=!!c}function M(a){if(!a.a&&(a.a=new y,a.b=0,a.g))for(var b=a.g.split("&"),c=0;c<b.length;c++){var d=b[c].indexOf("="),e=g,f=g;d>=0?(e=b[c].substring(0,d),f=b[c].substring(d+1)):e=b[c];e=decodeURIComponent(e.replace(/\+/g," "));e=O(a,e);a.add(e,f?decodeURIComponent(f.replace(/\+/g," ")):"")}}i=J.prototype;i.a=g;i.b=g;
i.add=function(a,b){M(this);N(this);a=O(this,a);if(this.i(a)){var c=this.a.get(a);o(c)?c.push(b):this.a.set(a,[c,b])}else this.a.set(a,b);this.b++;return this};i.remove=function(a){M(this);a=O(this,a);if(this.a.i(a)){N(this);var b=this.a.get(a);o(b)?this.b-=b.length:this.b--;return this.a.remove(a)}return!1};i.i=function(a){M(this);a=O(this,a);return this.a.i(a)};
i.o=function(){M(this);for(var a=this.a.l(),b=this.a.o(),c=[],d=0;d<b.length;d++){var e=a[d];if(o(e))for(var f=0;f<e.length;f++)c.push(b[d]);else c.push(b[d])}return c};i.l=function(a){M(this);if(a)if(a=O(this,a),this.i(a)){var b=this.a.get(a);if(o(b))return b;else a=[],a.push(b)}else a=[];else for(var b=this.a.l(),a=[],c=0;c<b.length;c++){var d=b[c];o(d)?ha(a,d):a.push(d)}return a};
i.set=function(a,b){M(this);N(this);a=O(this,a);if(this.i(a)){var c=this.a.get(a);o(c)?this.b-=c.length:this.b--}this.a.set(a,b);this.b++;return this};i.get=function(a,b){M(this);a=O(this,a);if(this.i(a)){var c=this.a.get(a);return o(c)?c[0]:c}else return b};
i.toString=function(){if(this.g)return this.g;if(!this.a)return"";for(var a=[],b=0,c=this.a.o(),d=0;d<c.length;d++){var e=c[d],f=s(e),e=this.a.get(e);if(o(e))for(var h=0;h<e.length;h++)b>0&&a.push("&"),a.push(f),e[h]!==""&&a.push("=",s(e[h])),b++;else b>0&&a.push("&"),a.push(f),e!==""&&a.push("=",s(e)),b++}return this.g=a.join("")};function N(a){delete a.v;delete a.g;a.s&&delete a.s.d}i.n=function(){var a=new J;if(this.v)a.v=this.v;if(this.g)a.g=this.g;if(this.a)a.a=this.a.n();return a};
function O(a,b){var c=String(b);a.e&&(c=c.toLowerCase());return c}i.q=function(a){a&&!this.e&&(M(this),N(this),ma(this.a,function(a,c){var d=c.toLowerCase();c!=d&&(this.remove(c),this.add(d,a))},this));this.e=a};var P,Q,R,S;function xa(){return k.navigator?k.navigator.userAgent:g}S=R=Q=P=!1;var T;if(T=xa()){var ya=k.navigator;P=T.indexOf("Opera")==0;Q=!P&&T.indexOf("MSIE")!=-1;R=!P&&T.indexOf("WebKit")!=-1;S=!P&&!R&&ya.product=="Gecko"}var U=Q,V=S,za=R,t;
a:{var W="",X;if(P&&k.opera)var Aa=k.opera.version,W=typeof Aa=="function"?Aa():Aa;else if(V?X=/rv\:([^\);]+)(\)|;)/:U?X=/MSIE\s+([^\);]+)(\)|;)/:za&&(X=/WebKit\/(\S+)/),X)var Ba=X.exec(xa()),W=Ba?Ba[1]:"";if(U){var Ca,Da=k.document;Ca=Da?Da.documentMode:void 0;if(Ca>parseFloat(W)){t=String(Ca);break a}}t=W}var Y={},Ea={};function Fa(){return Ea[9]||(Ea[9]=U&&document.documentMode&&document.documentMode>=9)};!U||Fa();if(V||U)if(!U||!Fa())V&&(Y["1.9.1"]||(Y["1.9.1"]=ea("1.9.1")>=0));U&&(Y["9"]||(Y["9"]=ea("9")>=0));function Ga(a,b){ia(b,function(b,d){d=="style"?a.style.cssText=b:d=="class"?a.className=b:d=="for"?a.htmlFor=b:d in Ha?a.setAttribute(Ha[d],b):d.lastIndexOf("aria-",0)==0?a.setAttribute(d,b):a[d]=b})}var Ha={cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",height:"height",width:"width",usemap:"useMap",frameborder:"frameBorder",maxlength:"maxLength",type:"type"};function Ia(a,b){this.s=new B(a);this.B=b?b:"callback";this.u=5E3}var Z="_callbacks_",Ja=0;
Ia.prototype.send=function(a,b,c,d){a=a||g;if(!document.documentElement.firstChild)return c&&c(a),g;d=d||"_"+(Ja++).toString(36)+ba().toString(36);k[Z]||(k[Z]={});var e=document.createElement("script"),f=g;this.u>0&&(f=k.setTimeout(Ka(d,e,a,c),this.u));c=this.s.n();if(a)for(var h in a)(!a.hasOwnProperty||a.hasOwnProperty(h))&&ta(c,h,a[h]);b&&(k[Z][d]=La(d,e,b,f),ta(c,this.B,Z+"."+d));Ga(e,{type:"text/javascript",id:d,charset:"UTF-8",src:c.toString()});document.getElementsByTagName("head")[0].appendChild(e);
return{F:d,u:f}};function Ka(a,b,c,d){return function(){Ma(a,b,!1);d&&d(c)}}function La(a,b,c,d){return function(e){k.clearTimeout(d);Ma(a,b,!0);c.apply(void 0,arguments)}}function Ma(a,b,c){k.setTimeout(function(){b&&b.parentNode&&b.parentNode.removeChild(b)},0);k[Z][a]&&(c?delete k[Z][a]:k[Z][a]=aa)};Z="jsonp";function $(a){this.localStorage=!1;this.format="table";if(m(a))for(var b in a)this[b]=a[b]}
$.prototype.load=function(a,b){if(m(a)&&(typeof a=="number"&&(a={id:a}),!this.localStorage||!ca.H.G.get(this))){var c;if(q(a))c=a;else{var d="";c=m(a.cols)?a.cols:"*";m(a.where)&&(d=" WHERE "+a.where);if(m(a.bounds)){var d=d.length==0?" WHERE ":" AND ",e=a.bounds;d+="ST_INTERSECTS(kml_4326, RECTANGLE(LATLNG("+e[1]+","+e[0]+"),LATLNG("+e[3]+","+e[2]+"))) "}c="SELECT "+c+" FROM "+a.id+d}var f=a.D||this.format,h=this;this.w(c,function(c){switch(f){case "geojson":c=h.z(c,a.keys);break}b.call(h,c)})}};
$.prototype.w=function(a,b){var c=new Ia("http://tables.googlelabs.com/api/query","jsonCallback");c.u=6E4;c.send({sql:a},b,function(){alert("The request failed to return within 60 seconds")})};
$.prototype.z=function(a,b){var c=a.table.rows,d=a.table.cols;if(!m(b))for(var b={properties:{}},e=c[0],f,h=0,j=e.length;h<j;h++)f=e[h],r(f)&&m(f.coordinates)?b.geometry=h:b.properties[d[h]]=h;e={type:"FeatureCollection"};f=[];Na(this,b,d);h=0;for(j=c.length;h<j;h++)d={type:"Feature"},Oa(this,d,b,c[h]),f.push(d);e.features=f;return e};function Na(a,b,c){for(var d in b)r(b[d])?Na(a,b[d],c):q(b[d])&&(b[d]=fa(c,b[d]))}
function Oa(a,b,c,d){for(var e in c)r(c[e])?(b[e]={},Oa(a,b[e],c[e],d)):b[e]=d[c[e]]};l("Fusion",$);l("Fusion.prototype.load",$.prototype.load);l("Fusion.prototype.query",$.prototype.w);l("Fusion.prototype.toGeoJSON",$.prototype.z);})();

