/* 
 * TimeMap Copyright 2008 Nick Rabinowitz.
 * Licensed under the MIT License (see LICENSE.txt)
 */
var JSONLoader={};JSONLoader.counter=0;JSONLoader.read=function(B,C){var D="_"+JSONLoader.counter++;JSONLoader[D]=function(E){C(E)};var A=document.createElement("script");A.src=B+"JSONLoader."+D;document.body.appendChild(A)};/* 
 * TimeMap Copyright 2008 Nick Rabinowitz.
 * Licensed under the MIT License (see LICENSE.txt)
 */
TimeMap.prototype.clear=function(){this.each(function(A){A.clear()});this.datasets=[]};TimeMap.prototype.deleteDataset=function(A){this.datasets[A].clear();delete this.datasets[A]};TimeMap.prototype.hideDataset=function(A){if(A in this.datasets){this.datasets[A].hide()}};TimeMap.prototype.hideDatasets=function(){this.each(function(A){A.visible=false});this.filter("map")};TimeMap.prototype.showDataset=function(A){if(A in this.datasets){this.datasets[A].show()}};TimeMap.prototype.showDatasets=function(){this.each(function(A){A.visible=true});this.filter("map")};TimeMap.prototype.changeMapType=function(A){if(A==this.opts.mapType){return }if(typeof (A)=="string"){A=TimeMap.mapTypes[A]}if(!A){return }this.opts.mapType=A;this.map.setMapType(A)};TimeMap.prototype.refreshTimeline=function(){var B=this.timeline.getBand(0);var A=B.getCenterVisibleDate();B.getEventPainter().getLayout()._laidout=false;this.timeline.layout();B.setCenterVisibleDate(A)};TimeMap.prototype.changeTimeIntervals=function(C){if(C==this.opts.bandIntervals){return }if(typeof (C)=="string"){C=TimeMap.intervals[C]}if(!C){return }this.opts.bandIntervals=C;var D=function(G,F){G.getEther()._interval=Timeline.DateTime.gregorianUnitLengths[F];G.getEtherPainter()._unit=F};var E=this.timeline.getBand(0);var B=E.getCenterVisibleDate();for(var A=0;A<this.timeline.getBandCount();A++){D(this.timeline.getBand(A),C[A])}E.getEventPainter().getLayout()._laidout=false;this.timeline.layout();E.setCenterVisibleDate(B)};TimeMap.prototype.scrollTimeline=function(B){var D=this.timeline.getBand(0);var A=D.getCenterVisibleDate();var C=A.getFullYear()+parseFloat(B);A.setFullYear(C);D.setCenterVisibleDate(A)};TimeMapDataset.prototype.clear=function(){this.each(function(A){A.clear()});this.items=[];this.timemap.timeline.layout()};TimeMapDataset.prototype.deleteItem=function(B){for(var A=0;A<this.items.length;A++){if(this.items[A]==B){B.clear();this.items.splice(A,1);break}}this.timemap.timeline.layout()};TimeMapDataset.prototype.show=function(){if(!this.visible){this.visible=true;this.timemap.filter("map")}};TimeMapDataset.prototype.hide=function(){if(this.visible){this.visible=false;this.timemap.filter("map")}};TimeMapDataset.prototype.changeTheme=function(A){this.opts.theme=A;this.each(function(B){B.changeTheme(A)});this.timemap.timeline.layout()};TimeMapItem.prototype.clear=function(){if(this.event){this.dataset.timemap.timeline.getBand(0).getEventSource()._events._events.remove(this.event)}if(this.placemark){this.hidePlacemark();f=function(C){try{this.map.removeOverlay(C)}catch(B){}};if(this.getType()=="array"){for(var A=0;A<this.placemark.length;A++){f(this.placemark[A])}}else{f(this.placemark)}}this.event=this.placemark=null};TimeMapItem.prototype.createEvent=function(C,E){var A=(E==undefined);var B=this.opts.theme.eventIcon;var F=this.getTitle();var D=new Timeline.DefaultEventSource.Event(C,E,null,null,A,F,null,null,null,this.opts.theme.eventIcon,this.opts.theme.eventColor,null);D.item=this;this.event=D;this.dataset.eventSource.add(D)};TimeMapItem.prototype.changeTheme=function(C){this.opts.theme=C;if(this.placemark){var B=function(D,E,F){E=E||TimeMapItem.getPlacemarkType(D);switch(E){case"marker":D.setImage(F.icon.image);break;case"polygon":D.setFillStyle({color:C.fillColor,opacity:C.fillOpacity});case"polyline":D.setStrokeStyle({color:C.lineColor,weight:C.lineWeight,opacity:C.lineOpacity});break}};if(this.getType()=="array"){for(var A=0;A<this.placemark.length;A++){B(this.placemark[A],false,C)}}else{B(this.placemark,this.getType(),C)}}if(this.event){this.event._color=C.eventColor;this.event._icon=C.eventIcon}};TimeMapItem.getPlacemarkType=function(A){if("getIcon" in A){return"marker"}if("getVertex" in A){return"setFillStyle" in A?"polygon":"polyline"}return false};var Metaweb={};Metaweb.HOST="http://www.freebase.com";Metaweb.QUERY_SERVICE="/api/service/mqlread";Metaweb.counter=0;Metaweb.read=function(E,D){var F="_"+Metaweb.counter++;Metaweb[F]=function(J){var I=J.qname;if(I.code.indexOf("/api/status/ok")!=0){var H=I.messages[0];throw H.code+": "+H.message}var G=I.result;document.body.removeChild(A);delete Metaweb[F];D(G)};envelope={qname:{query:E}};var C=encodeURIComponent(JSON.stringify(envelope));var B=Metaweb.HOST+Metaweb.QUERY_SERVICE+"?queries="+C+"&callback=Metaweb."+F;var A=document.createElement("script");A.src=B;document.body.appendChild(A)};/* 
 * TimeMap Copyright 2008 Nick Rabinowitz.
 * Licensed under the MIT License (see LICENSE.txt)
 */
function TimeMap(A,D,B){this.mElement=D;this.tElement=A;this.datasets={};this.filters={};this.mapBounds=new GLatLngBounds();this.opts=B||{};if(typeof (B.mapType)=="string"){B.mapType=TimeMap.mapTypes[B.mapType]}this.opts.mapCenter=B.mapCenter||new GLatLng(0,0);this.opts.mapZoom=B.mapZoom||0;this.opts.mapType=B.mapType||G_PHYSICAL_MAP;this.opts.mapTypes=B.mapTypes||[G_NORMAL_MAP,G_SATELLITE_MAP,G_PHYSICAL_MAP];this.opts.syncBands=("syncBands" in B)?B.syncBands:true;this.opts.showMapTypeCtrl=("showMapTypeCtrl" in B)?B.showMapTypeCtrl:true;this.opts.showMapCtrl=("showMapCtrl" in B)?B.showMapCtrl:true;this.opts.hidePastFuture=("hidePastFuture" in B)?B.hidePastFuture:true;this.opts.showMomentOnly=("showMomentOnly" in B)?B.showMomentOnly:false;this.opts.centerMapOnItems=("centerMapOnItems" in B)?B.centerMapOnItems:true;if(GBrowserIsCompatible()){this.map=new GMap2(this.mElement);if(this.opts.showMapCtrl){this.map.addControl(new GLargeMapControl())}if(this.opts.showMapTypeCtrl){this.map.addControl(new GMapTypeControl())}for(var C=G_DEFAULT_MAP_TYPES.length-1;C>0;C--){this.map.removeMapType(G_DEFAULT_MAP_TYPES[C])}this.map.addMapType(this.opts.mapTypes[0]);this.map.removeMapType(G_DEFAULT_MAP_TYPES[0]);for(var C=1;C<this.opts.mapTypes.length;C++){this.map.addMapType(this.opts.mapTypes[C])}this.map.enableDoubleClickZoom();this.map.enableScrollWheelZoom();this.map.enableContinuousZoom();this.map.setCenter(this.opts.mapCenter,this.opts.mapZoom);this.map.setMapType(this.opts.mapType)}Timeline.DurationEventPainter.prototype._showBubble=function(E,G,F){F.item.openInfoWindow()}}TimeMap.init=function(D){if(!("mapId" in D)||!D.mapId){alert("TimeMap init: No map id was specified!");return }if(!("timelineId" in D)||!D.timelineId){alert("TimeMap init: No timeline id was specified!");return }D=D||{};D.options=D.options||{};D.datasets=D.datasets||[];D.bandInfo=D.bandInfo||false;D.scrollTo=D.scrollTo||"earliest";if(!D.bandInfo){var I=D.bandIntervals||D.options["bandIntervals"]||[Timeline.DateTime.WEEK,Timeline.DateTime.MONTH];if(typeof (I)=="string"){I=TimeMap.intervals[I]}D.options["bandIntervals"]=I;D.bandInfo=[{width:"80%",intervalUnit:I[0],intervalPixels:70},{width:"20%",intervalUnit:I[1],intervalPixels:100,showEventText:false,trackHeight:0.4,trackGap:0.2}]}var L=new TimeMap(document.getElementById(D.timelineId),document.getElementById(D.mapId),D.options);var H=[];for(var K=0;K<D.datasets.length;K++){var C=D.datasets[K];var F=C.options||{};F.title=C.title||"";F.theme=C.theme||undefined;if(C.dateParser){F.dateParser=C.dateParser}var B=C.id||"ds"+K;H[K]=L.createDataset(B,F);if(K>0){H[K].eventSource=H[0].eventSource}}var G=[];var E=(H[0]&&H[0]["eventSource"])||new Timeline.DefaultEventSource();for(var K=0;K<D.bandInfo.length;K++){var J=D.bandInfo[K];if(!(("eventSource" in J)&&J.eventSource==null)){J.eventSource=E}else{J.eventSource=null}G[K]=Timeline.createBandInfo(J);if(K>0){G[K].eventPainter.setLayout(G[0].eventPainter.getLayout())}}L.initTimeline(G);var A={};A.count=0;A.loadTarget=D.datasets.length;A.ifLoadedFunction=function(){if(D.dataLoadedFunction){D.dataLoadedFunction(L)}else{var M=new Date();if(E.getCount()>0){if(D.scrollTo=="earliest"){M=E.getEarliestDate()}else{if(D.scrollTo!="now"&&D.scrollTo!=null){M=E.getLatestDate()}}L.timeline.getBand(0).setCenterVisibleDate(M)}L.timeline.layout();if(D.dataDisplayedFunction){D.dataDisplayedFunction(L)}}};A.ifLoaded=function(){this.count++;if(this.count==this.loadTarget){this.ifLoadedFunction()}};for(var K=0;K<D.datasets.length;K++){(function(M){var R=D.datasets[M]["data"];var Q=H[M];var S=function(T){return T};var P=D.datasets[M]["preloadFunction"]||S;var O=D.datasets[M]["transformFunction"]||S;switch(R.type){case"basic":var N=P(R.value);Q.loadItems(N,O);A.ifLoaded();break;case"json":JSONLoader.read(R.url,function(T){var U=P(T);Q.loadItems(U,O);A.ifLoaded()});break;case"kml":GDownloadUrl(R.url,function(T){var U=TimeMapDataset.parseKML(T);U=P(U);Q.loadItems(U,O);A.ifLoaded()});break;case"metaweb":Metaweb.read(R.query,function(T){var U=P(T);Q.loadItems(T,O);A.ifLoaded()});break}})(K)}return L};var timemapInit=TimeMap.init;TimeMap.intervals={sec:[Timeline.DateTime.SECOND,Timeline.DateTime.MINUTE],min:[Timeline.DateTime.MINUTE,Timeline.DateTime.HOUR],hr:[Timeline.DateTime.HOUR,Timeline.DateTime.DAY],day:[Timeline.DateTime.DAY,Timeline.DateTime.WEEK],wk:[Timeline.DateTime.WEEK,Timeline.DateTime.MONTH],mon:[Timeline.DateTime.MONTH,Timeline.DateTime.YEAR],yr:[Timeline.DateTime.YEAR,Timeline.DateTime.DECADE],dec:[Timeline.DateTime.DECADE,Timeline.DateTime.CENTURY]};TimeMap.mapTypes={normal:G_NORMAL_MAP,satellite:G_SATELLITE_MAP,hybrid:G_HYBRID_MAP,physical:G_PHYSICAL_MAP,moon:G_MOON_VISIBLE_MAP,sky:G_SKY_VISIBLE_MAP};TimeMap.prototype.createDataset=function(D,B){B=B||{};if(!("title" in B)){B.title=D}var C=new TimeMapDataset(this,B);this.datasets[D]=C;if(this.opts.centerMapOnItems){var A=this;GEvent.addListener(C,"itemsloaded",function(){A.map.setZoom(A.map.getBoundsZoomLevel(A.mapBounds));A.map.setCenter(A.mapBounds.getCenter())})}return C};TimeMap.prototype.each=function(A){for(id in this.datasets){A(this.datasets[id])}};TimeMap.prototype.initTimeline=function(D){for(var A=1;A<D.length;A++){if(this.opts.syncBands){D[A].syncWith=(A-1)}D[A].highlight=true}this.timeline=Timeline.create(this.tElement,D);var B=this;this.timeline.getBand(0).addOnScrollListener(function(){B.filter("map")});GEvent.addListener(B.map,"moveend",function(){B.filter("timeline")});this.addFilterChain("map",function(E){E.showPlacemark()},function(E){E.hidePlacemark()});this.addFilter("map",function(E){return E.dataset.visible});if(this.opts.hidePastFuture){this.addFilter("map",TimeMap.hidePastFuture)}else{if(this.opts.showMomentOnly){this.addFilter("map",TimeMap.showMomentOnly)}}resizeTimerID=null;var C=this.timeline;window.onresize=function(){if(resizeTimerID==null){resizeTimerID=window.setTimeout(function(){resizeTimerID=null;C.layout()},500)}}};TimeMap.prototype.filter=function(B){var A=this.filters[B];if(!A||!A.chain||A.chain.length==0){return }this.each(function(C){C.each(function(E){F_LOOP:{for(var D=A.chain.length-1;D>=0;D--){if(!A.chain[D](E)){A.off(E);break F_LOOP}}A.on(E)}})})};TimeMap.prototype.addFilterChain=function(C,B,A){this.filters[C]={chain:[],on:B,off:A}};TimeMap.prototype.removeFilterChain=function(C,A,B){this.filters[C]=null};TimeMap.prototype.addFilter=function(B,A){if(this.filters[B]&&this.filters[B].chain){this.filters[B].chain.push(A)}};TimeMap.prototype.removeFilter=function(A){if(this.filters[A]&&this.filters[A].chain){this.filters[A].chain.pop()}};TimeMap.hidePastFuture=function(D){var F=D.dataset.timemap.timeline.getBand(0);var B=F.getMaxVisibleDate().getTime();var C=F.getMinVisibleDate().getTime();if(D.event!=null){var A=D.event.getStart().getTime();var E=D.event.getEnd().getTime();if(A>B){return false}else{if(E<C||(D.event.isInstant()&&A<C)){return false}}}return true};TimeMap.showMomentOnly=function(B){var D=B.dataset.timemap.timeline.getBand(0);var E=D.getCenterVisibleDate().getTime();if(B.event!=null){var A=B.event.getStart().getTime();var C=B.event.getEnd().getTime();if(A>E){return false}else{if(C<E||(B.event.isInstant()&&A<E)){return false}}}return true};function TimeMapDataset(A,B){this.timemap=A;this.eventSource=new Timeline.DefaultEventSource();this.items=[];this.visible=true;this.opts=B||{};this.opts.title=B.title||"";if(typeof (B.theme)=="string"){B.theme=TimeMapDataset.themes[B.theme]}this.opts.theme=B.theme||this.timemap.opts.theme||new TimeMapDatasetTheme({});this.opts.theme.eventIconPath=B.eventIconPath||this.timemap.opts.eventIconPath||this.opts.theme.eventIconPath;this.opts.theme.eventIcon=B.eventIconPath+this.opts.theme.eventIconImage;if(typeof (B.dateParser)=="string"){B.dateParser=TimeMapDataset.dateParsers[B.dateParser]}this.opts.dateParser=B.dateParser||TimeMapDataset.dateParsers.iso8601;this.getItems=function(){return this.items};this.getTitle=function(){return this.opts.title}}TimeMapDataset.dateParsers={iso8601:Timeline.DateTime.parseIso8601DateTime,gregorian:Timeline.DateTime.parseGregorianDateTime};TimeMapDataset.prototype.each=function(B){for(var A=0;A<this.items.length;A++){B(this.items[A])}};TimeMapDataset.prototype.loadItems=function(C,B){for(var A=0;A<C.length;A++){this.loadItem(C[A],B)}GEvent.trigger(this,"itemsloaded")};TimeMapDataset.prototype.loadItem=function(T,J){if(J!=undefined){T=J(T)}if(T==null){return }var E=T.options||{};if(typeof (E.theme)=="string"){E.theme=TimeMapDataset.themes[E.theme]}var S=E.theme||this.opts.theme;S.eventIconPath=E.eventIconPath||this.opts.theme.eventIconPath;S.eventIcon=S.eventIconPath+S.eventIconImage;var D=this.timemap;var H=(T.start==undefined||T.start=="")?null:this.opts.dateParser(T.start);var G=(T.end==undefined||T.end=="")?null:this.opts.dateParser(T.end);var C=(T.end==undefined);var B=S.eventIcon;var U=T.title;if(H!=null){var O=new Timeline.DefaultEventSource.Event(H,G,null,null,C,U,null,null,null,B,S.eventColor,null)}else{var O=null}var L=function(Y){var X=null,Z="",b=null;if("point" in Y){b=new GLatLng(parseFloat(Y.point.lat),parseFloat(Y.point.lon));if(D.opts.centerMapOnItems){D.mapBounds.extend(b)}markerIcon=("icon" in Y)?Y.icon:S.icon;X=new GMarker(b,{icon:markerIcon});Z="marker";b=X.getLatLng()}else{if("polyline" in Y||"polygon" in Y){var d=[];if("polyline" in Y){var e=Y.polyline}else{var e=Y.polygon}for(var a=0;a<e.length;a++){b=new GLatLng(parseFloat(e[a]["lat"]),parseFloat(e[a]["lon"]));d.push(b);if(D.opts.centerMapOnItems){D.mapBounds.extend(b)}}if("polyline" in Y){X=new GPolyline(d,S.lineColor,S.lineWeight,S.lineOpacity);Z="polyline";b=X.getVertex(Math.floor(X.getVertexCount()/2))}else{X=new GPolygon(d,S.polygonLineColor,S.polygonLineWeight,S.polygonLineOpacity,S.fillColor,S.fillOpacity);Z="polygon";b=X.getBounds().getCenter()}}else{if("overlay" in Y){var c=new GLatLng(parseFloat(Y.overlay.south),parseFloat(Y.overlay.west));var W=new GLatLng(parseFloat(Y.overlay.north),parseFloat(Y.overlay.east));if(D.opts.centerMapOnItems){D.mapBounds.extend(c);D.mapBounds.extend(W)}var V=new GLatLngBounds(c,W);X=new GGroundOverlay(Y.overlay.image,V);Z="overlay";b=V.getCenter()}}}return{placemark:X,type:Z,point:b}};var R=[],M=[],A=null,F="",N=null;if("placemarks" in T){M=T.placemarks}else{var I=["point","polyline","polygon","overlay"];for(var P=0;P<I.length;P++){if(I[P] in T){A={};A[I[P]]=T[I[P]];M.push(A)}}}if(M){for(var P=0;P<M.length;P++){var K=L(M[P]);if(!N){N=K.point}if(!F){F=K.type}R.push(K.placemark)}}if(R.length>1){F="array"}E.title=U;E.type=F||"none";E.theme=S;if(E.infoPoint){E.infoPoint=new GLatLng(parseFloat(E.infoPoint.lat),parseFloat(E.infoPoint.lon))}else{E.infoPoint=N}var Q=new TimeMapItem(R,O,this,E);if(O!=null){O.item=Q;this.eventSource.add(O)}if(R.length>0){for(var P=0;P<R.length;P++){R[P].item=Q;GEvent.addListener(R[P],"click",function(){Q.openInfoWindow()});D.map.addOverlay(R[P]);R[P].hide()}}this.items.push(Q);return Q};TimeMapDataset.parseKML=function(H){var G=[],D,B,I,A;B=GXml.parse(H);var E=function(Q,O){var P=Q.getElementsByTagName(O);if(P.length>0){return P[0].firstChild.nodeValue}else{return""}};var N=function(R,Q){var O=false;nList=R.getElementsByTagName("TimeStamp");if(nList.length>0){Q.start=E(nList[0],"when");O=true}else{nList=R.getElementsByTagName("TimeSpan");if(nList.length>0){Q.start=E(nList[0],"begin");Q.end=E(nList[0],"end");O=true}}if(!O){var P=R.parentNode;if(P.nodename=="Folder"||P.nodename=="Document"){TimeMapDataset.findNodeTime(P,Q)}P=null}};I=B.getElementsByTagName("Placemark");for(var C=0;C<I.length;C++){A=I[C];D={options:{}};D.title=E(A,"name");D.options.description=E(A,"description");N(A,D);PLACEMARK:{var L,M,F,J;nList=A.getElementsByTagName("Point");if(nList.length>0){D.point={};L=E(nList[0],"coordinates");F=L.split(",");D.point={lat:trim(F[1]),lon:trim(F[0])};break PLACEMARK}nList=A.getElementsByTagName("LineString");if(nList.length>0){J="polyline"}else{nList=A.getElementsByTagName("Polygon");if(nList.length>0){J="polygon"}}if(nList.length>0){D[J]=[];L=E(nList[0],"coordinates");M=trim(L).split(/[\r\n\f ]+/);for(var K=0;K<M.length;K++){F=M[K].split(",");D[J].push({lat:trim(F[1]),lon:trim(F[0])})}break PLACEMARK}}G.push(D)}I=B.getElementsByTagName("GroundOverlay");for(var C=0;C<I.length;C++){A=I[C];D={options:{},overlay:{}};D.title=E(A,"name");D.options.description=E(A,"description");N(A,D);nList=A.getElementsByTagName("Icon");D.overlay.image=E(nList[0],"href");nList=A.getElementsByTagName("LatLonBox");D.overlay.north=E(nList[0],"north");D.overlay.south=E(nList[0],"south");D.overlay.east=E(nList[0],"east");D.overlay.west=E(nList[0],"west");G.push(D)}B=null;I=null;A=null;nList=null;return G};function TimeMapDatasetTheme(B){B=B||{};if(!B.icon){var A=new GIcon(G_DEFAULT_ICON);this.iconImage=B.iconImage||"http://www.google.com/intl/en_us/mapfiles/ms/icons/red-dot.png";A.image=this.iconImage;A.iconSize=new GSize(32,32);A.shadow="http://www.google.com/intl/en_us/mapfiles/ms/icons/msmarker.shadow.png";A.shadowSize=new GSize(59,32)}this.icon=B.icon||A;this.color=B.color||"#FE766A";this.lineColor=B.lineColor||this.color;this.polygonLineColor=B.polygonLineColor||this.lineColor;this.lineOpacity=B.lineOpacity||1;this.polgonLineOpacity=B.polgonLineOpacity||this.lineOpacity;this.lineWeight=B.lineWeight||2;this.polygonLineWeight=B.polygonLineWeight||this.lineWeight;this.fillColor=B.fillColor||this.color;this.fillOpacity=B.fillOpacity||0.25;this.eventColor=B.eventColor||this.color;this.eventIconPath=B.eventIconPath||"timemap/images/";this.eventIconImage=B.eventIconImage||"red-circle.png";this.eventIcon=B.eventIcon||this.eventIconPath+this.eventIconImage}TimeMapDataset.redTheme=function(A){return new TimeMapDatasetTheme(A)};TimeMapDataset.blueTheme=function(A){A=A||{};A.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/blue-dot.png";A.color="#5A7ACF";A.eventIconImage="blue-circle.png";return new TimeMapDatasetTheme(A)};TimeMapDataset.greenTheme=function(A){A=A||{};A.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/green-dot.png";A.color="#19CF54";A.eventIconImage="green-circle.png";return new TimeMapDatasetTheme(A)};TimeMapDataset.ltblueTheme=function(A){A=A||{};A.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/ltblue-dot.png";A.color="#5ACFCF";A.eventIconImage="ltblue-circle.png";return new TimeMapDatasetTheme(A)};TimeMapDataset.purpleTheme=function(A){A=A||{};A.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/purple-dot.png";A.color="#8E67FD";A.eventIconImage="purple-circle.png";return new TimeMapDatasetTheme(A)};TimeMapDataset.orangeTheme=function(A){A=A||{};A.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/orange-dot.png";A.color="#FF9900";A.eventIconImage="orange-circle.png";return new TimeMapDatasetTheme(A)};TimeMapDataset.yellowTheme=function(A){A=A||{};A.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/yellow-dot.png";A.color="#ECE64A";A.eventIconImage="yellow-circle.png";return new TimeMapDatasetTheme(A)};TimeMapDataset.themes={red:TimeMapDataset.redTheme(),blue:TimeMapDataset.blueTheme(),green:TimeMapDataset.greenTheme(),ltblue:TimeMapDataset.ltblueTheme(),orange:TimeMapDataset.orangeTheme(),yellow:TimeMapDataset.yellowTheme(),purple:TimeMapDataset.purpleTheme()};function TimeMapItem(B,C,D,A){this.event=C;this.dataset=D;this.map=D.timemap.map;if(B&&isArray(B)&&B.length==0){B=null}if(B&&B.length==1){B=B[0]}this.placemark=B;this.opts=A||{};this.opts.type=A.type||"";this.opts.title=A.title||"";this.opts.description=A.description||"";this.opts.infoPoint=A.infoPoint||null;this.opts.infoHtml=A.infoHtml||"";this.opts.infoUrl=A.infoUrl||"";this.getType=function(){return this.opts.type};this.getTitle=function(){return this.opts.title};this.getInfoPoint=function(){return this.opts.infoPoint||this.map.getCenter()};this.visible=false;this.showPlacemark=function(){if(this.placemark){if(this.getType()=="array"){for(var E=0;E<this.placemark.length;E++){this.placemark[E].show()}}else{this.placemark.show()}this.visible=true}};this.hidePlacemark=function(){if(this.placemark){if(this.getType()=="array"){for(var E=0;E<this.placemark.length;E++){this.placemark[E].hide()}}else{this.placemark.hide()}this.visible=false}this.closeInfoWindow()};this.openInfoWindow=A.openInfoWindow||D.opts.openInfoWindow||D.timemap.opts.openInfoWindow||false;if(!this.openInfoWindow){if(this.opts.infoUrl!=""){this.openInfoWindow=TimeMapItem.openInfoWindowAjax}else{this.openInfoWindow=TimeMapItem.openInfoWindowBasic}}this.closeInfoWindow=A.closeInfoWindow||TimeMapItem.closeInfoWindowBasic}TimeMapItem.openInfoWindowBasic=function(){var A=this.opts.infoHtml;if(A==""){A='<div class="infotitle">'+this.opts.title+"</div>";if(this.opts.description!=""){A+='<div class="infodescription">'+this.opts.description+"</div>"}}if(this.placemark&&!this.visible&&this.event){var B=this.dataset.timemap.timeline.getBand(0);B.setCenterVisibleDate(this.event.getStart())}if(this.getType()=="marker"){this.placemark.openInfoWindowHtml(A)}else{this.map.openInfoWindowHtml(this.getInfoPoint(),A)}};TimeMapItem.openInfoWindowAjax=function(){if(this.opts.infoHtml!=""){this.openInfoWindow=TimeMapItem.openInfoWindowBasic;this.openInfoWindow()}else{if(this.opts.infoUrl!=""){var A=this;GDownloadUrl(this.opts.infoUrl,function(B){A.opts.infoHtml=B;A.openInfoWindow()})}else{this.openInfoWindow=TimeMapItem.openInfoWindowBasic;this.openInfoWindow()}}};TimeMapItem.closeInfoWindowBasic=function(){if(this.getType()=="marker"){this.placemark.closeInfoWindow()}else{var A=this.map.getInfoWindow();if(A.getPoint()==this.getInfoPoint()&&!A.isHidden()){this.map.closeInfoWindow()}}};function trim(A){return A.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function isArray(A){return A&&!(A.propertyIsEnumerable("length"))&&typeof A==="object"&&typeof A.length==="number"};TimeMap.prototype.toJSON=function(){var A={options:this.makeOptionData,datasets:this.datasets};A=this.addExportData(A)};TimeMap.prototype.makeOptionData=function(){var E={};for(k in this.opts){E[k]=this.opts[k]}if(E.mapCenter){E.mapCenter=TimeMap.makePoint(E.mapCenter)}if(E.mapType){E.mapType=revHash(TimeMap.mapTypes,E.mapType)}if(E.mapTypes){var F=[],C;for(var B=0;B<E.mapTypes.length;B++){C=revHash(TimeMap.mapTypes,E.mapTypes[B]);if(C){F.push(C)}}E.mapTypes=F}if(E.bandIntervals){E.bandIntervals=revHash(TimeMap.intervals,E.bandIntervals)}var A=[],D;for(id in this.datasets){D=revHash(TimeMapDataset.themes,this.datasets[id].opts.theme);if(D){A.push(D)}}E.themes=D;return E};TimeMap.prototype.addExportData=function(A){A.options=A.options||{};A.options["saveOpts"]=this.opts.saveOpts;return A};TimeMapDataset.prototype.toJSON=function(){var A={title:this.getTitle(),theme:revHash(TimeMapDataset.themes,this.opts.theme),data:{type:"basic",value:this.getItems()}};A=this.addExportData(A);return A};TimeMapDataset.prototype.addExportData=function(A){A.options=A.options||{};A.options["saveOpts"]=this.opts.saveOpts;return A};TimeMapItem.prototype.toJSON=function(){var C={title:this.getTitle(),options:{description:this.opts.description}};if(this.event){C.start=this.event.getStart();if(!this.event.isInstant()){C.end=this.event.getEnd()}}if(this.placemark){var B=function(F,E,G){F=F||TimeMapItem.getPlacemarkType(E);switch(F){case"marker":G.point=TimeMap.makePoint(E.getLatLng());break;case"polyline":case"polygon":line=[];for(var D=0;D<E.getVertexCount();D++){line.push(TimeMap.makePoint(E.getVertex(D)))}G[F]=line;break}return G};if(this.getType()=="array"){C.placemarks=[];for(var A=0;A<this.placemark.length;A++){C.placemarks.push(B(false,this.placemark[A],{}))}}else{C=B(this.getType(),this.placemark,C)}}C=this.addExportData(C);return C};TimeMapItem.prototype.addExportData=function(A){A.options=A.options||{};A.options["saveOpts"]=this.opts.saveOpts;return A};TimeMap.makePoint=function(A){return{lat:A.lat(),lon:A.lng()}};function revHash(A,B){for(k in A){if(A[k]==B){return k}}return null};var JSONLoader={};JSONLoader.counter=0;JSONLoader.read=function(H,G){var F="_"+JSONLoader.counter++;JSONLoader[F]=function(A){G(A)};var E=document.createElement("script");E.src=H+"JSONLoader."+F;document.body.appendChild(E)};TimeMap.prototype.clear=function(){this.each(function(B){B.clear()});this.datasets=[]};TimeMap.prototype.deleteDataset=function(B){this.datasets[B].clear();delete this.datasets[B]};TimeMap.prototype.hideDataset=function(B){if(B in this.datasets){this.datasets[B].hide()}};TimeMap.prototype.hideDatasets=function(){this.each(function(B){B.visible=false});this.filter("map")};TimeMap.prototype.showDataset=function(B){if(B in this.datasets){this.datasets[B].show()}};TimeMap.prototype.showDatasets=function(){this.each(function(B){B.visible=true});this.filter("map")};TimeMap.prototype.changeMapType=function(B){if(B==this.opts.mapType){return }if(typeof (B)=="string"){B=TimeMap.mapTypes[B]}if(!B){return }this.opts.mapType=B;this.map.setMapType(B)};TimeMap.prototype.refreshTimeline=function(){var D=this.timeline.getBand(0);var C=D.getCenterVisibleDate();D.getEventPainter().getLayout()._laidout=false;this.timeline.layout();D.setCenterVisibleDate(C)};TimeMap.prototype.changeTimeIntervals=function(I){if(I==this.opts.bandIntervals){return }if(typeof (I)=="string"){I=TimeMap.intervals[I]}if(!I){return }this.opts.bandIntervals=I;var H=function(A,B){A.getEther()._interval=Timeline.DateTime.gregorianUnitLengths[B];A.getEtherPainter()._unit=B};var G=this.timeline.getBand(0);var J=G.getCenterVisibleDate();for(var F=0;F<this.timeline.getBandCount();F++){H(this.timeline.getBand(F),I[F])}G.getEventPainter().getLayout()._laidout=false;this.timeline.layout();G.setCenterVisibleDate(J)};TimeMap.prototype.scrollTimeline=function(H){var F=this.timeline.getBand(0);var E=F.getCenterVisibleDate();var G=E.getFullYear()+parseFloat(H);E.setFullYear(G);F.setCenterVisibleDate(E)};TimeMapDataset.prototype.clear=function(){this.each(function(B){B.clear()});this.items=[];this.timemap.timeline.layout()};TimeMapDataset.prototype.deleteItem=function(D){for(var C=0;C<this.items.length;C++){if(this.items[C]==D){D.clear();this.items.splice(C,1);break}}this.timemap.timeline.layout()};TimeMapDataset.prototype.show=function(){if(!this.visible){this.visible=true;this.timemap.filter("map")}};TimeMapDataset.prototype.hide=function(){if(this.visible){this.visible=false;this.timemap.filter("map")}};TimeMapDataset.prototype.changeTheme=function(B){this.opts.theme=B;this.each(function(A){A.changeTheme(B)});this.timemap.timeline.layout()};TimeMapItem.prototype.clear=function(){if(this.event){this.dataset.timemap.timeline.getBand(0).getEventSource()._events._events.remove(this.event)}if(this.placemark){this.hidePlacemark();f=function(A){try{this.map.removeOverlay(A)}catch(D){}};if(this.getType()=="array"){for(var B=0;B<this.placemark.length;B++){f(this.placemark[B])}}else{f(this.placemark)}}this.event=this.placemark=null};TimeMapItem.prototype.createEvent=function(K,I){var G=(I==undefined);var L=this.opts.theme.eventIcon;var H=this.getTitle();var J=new Timeline.DefaultEventSource.Event(K,I,null,null,G,H,null,null,null,this.opts.theme.eventIcon,this.opts.theme.eventColor,null);J.item=this;this.event=J;this.dataset.eventSource.add(J)};TimeMapItem.prototype.changeTheme=function(E){this.opts.theme=E;if(this.placemark){var F=function(C,B,A){B=B||TimeMapItem.getPlacemarkType(C);switch(B){case"marker":C.setImage(A.icon.image);break;case"polygon":C.setFillStyle({color:E.fillColor,opacity:E.fillOpacity});case"polyline":C.setStrokeStyle({color:E.lineColor,weight:E.lineWeight,opacity:E.lineOpacity});break}};if(this.getType()=="array"){for(var D=0;D<this.placemark.length;D++){F(this.placemark[D],false,E)}}else{F(this.placemark,this.getType(),E)}}if(this.event){this.event._color=E.eventColor;this.event._icon=E.eventIcon}};TimeMapItem.getPlacemarkType=function(B){if("getIcon" in B){return"marker"}if("getVertex" in B){return"setFillStyle" in B?"polygon":"polyline"}return false};var Metaweb={};Metaweb.HOST="http://www.freebase.com";Metaweb.QUERY_SERVICE="/api/service/mqlread";Metaweb.counter=0;Metaweb.read=function(I,J){var H="_"+Metaweb.counter++;Metaweb[H]=function(A){var B=A.qname;if(B.code.indexOf("/api/status/ok")!=0){var C=B.messages[0];throw C.code+": "+C.message}var D=B.result;document.body.removeChild(G);delete Metaweb[H];J(D)};envelope={qname:{query:I}};var K=encodeURIComponent(JSON.stringify(envelope));var L=Metaweb.HOST+Metaweb.QUERY_SERVICE+"?queries="+K+"&callback=Metaweb."+H;var G=document.createElement("script");G.src=L;document.body.appendChild(G)};function TimeMap(E,F,H){this.mElement=F;this.tElement=E;this.datasets={};this.filters={};this.mapBounds=new GLatLngBounds();this.opts=H||{};if(typeof (H.mapType)=="string"){H.mapType=TimeMap.mapTypes[H.mapType]}this.opts.mapCenter=H.mapCenter||new GLatLng(0,0);this.opts.mapZoom=H.mapZoom||0;this.opts.mapType=H.mapType||G_PHYSICAL_MAP;this.opts.mapTypes=H.mapTypes||[G_NORMAL_MAP,G_SATELLITE_MAP,G_PHYSICAL_MAP];this.opts.syncBands=("syncBands" in H)?H.syncBands:true;this.opts.showMapTypeCtrl=("showMapTypeCtrl" in H)?H.showMapTypeCtrl:true;this.opts.showMapCtrl=("showMapCtrl" in H)?H.showMapCtrl:true;this.opts.hidePastFuture=("hidePastFuture" in H)?H.hidePastFuture:true;this.opts.showMomentOnly=("showMomentOnly" in H)?H.showMomentOnly:false;this.opts.centerMapOnItems=("centerMapOnItems" in H)?H.centerMapOnItems:true;if(GBrowserIsCompatible()){this.map=new GMap2(this.mElement);if(this.opts.showMapCtrl){this.map.addControl(new GLargeMapControl())}if(this.opts.showMapTypeCtrl){this.map.addControl(new GMapTypeControl())}for(var G=G_DEFAULT_MAP_TYPES.length-1;G>0;G--){this.map.removeMapType(G_DEFAULT_MAP_TYPES[G])}this.map.addMapType(this.opts.mapTypes[0]);this.map.removeMapType(G_DEFAULT_MAP_TYPES[0]);for(var G=1;G<this.opts.mapTypes.length;G++){this.map.addMapType(this.opts.mapTypes[G])}this.map.enableDoubleClickZoom();this.map.enableScrollWheelZoom();this.map.enableContinuousZoom();this.map.setCenter(this.opts.mapCenter,this.opts.mapZoom);this.map.setMapType(this.opts.mapType)}Timeline.DurationEventPainter.prototype._showBubble=function(C,A,B){B.item.openInfoWindow()}}TimeMap.init=function(M){if(!("mapId" in M)||!M.mapId){alert("TimeMap init: No map id was specified!");return }if(!("timelineId" in M)||!M.timelineId){alert("TimeMap init: No timeline id was specified!");return }M=M||{};M.options=M.options||{};M.datasets=M.datasets||[];M.bandInfo=M.bandInfo||false;M.scrollTo=M.scrollTo||"earliest";if(!M.bandInfo){var T=M.bandIntervals||M.options.bandIntervals||[Timeline.DateTime.WEEK,Timeline.DateTime.MONTH];if(typeof (T)=="string"){T=TimeMap.intervals[T]}M.options.bandIntervals=T;M.bandInfo=[{width:"80%",intervalUnit:T[0],intervalPixels:70},{width:"20%",intervalUnit:T[1],intervalPixels:100,showEventText:false,trackHeight:0.4,trackGap:0.2}]}var Q=new TimeMap(document.getElementById(M.timelineId),document.getElementById(M.mapId),M.options);var U=[];for(var R=0;R<M.datasets.length;R++){var N=M.datasets[R];var W=N.options||{};W.title=N.title||"";W.theme=N.theme||undefined;if(N.dateParser){W.dateParser=N.dateParser}var O=N.id||"ds"+R;U[R]=Q.createDataset(O,W);if(R>0){U[R].eventSource=U[0].eventSource}}var V=[];var X=(U[0]&&U[0]["eventSource"])||new Timeline.DefaultEventSource();for(var R=0;R<M.bandInfo.length;R++){var S=M.bandInfo[R];if(!(("eventSource" in S)&&S.eventSource==null)){S.eventSource=X}else{S.eventSource=null}V[R]=Timeline.createBandInfo(S);if(R>0){V[R].eventPainter.setLayout(V[0].eventPainter.getLayout())}}Q.initTimeline(V);var P={};P.count=0;P.loadTarget=M.datasets.length;P.ifLoadedFunction=function(){if(M.dataLoadedFunction){M.dataLoadedFunction(Q)}else{var A=new Date();if(X.getCount()>0){if(M.scrollTo=="earliest"){A=X.getEarliestDate()}else{if(M.scrollTo!="now"&&M.scrollTo!=null){A=X.getLatestDate()}}Q.timeline.getBand(0).setCenterVisibleDate(A)}Q.timeline.layout();if(M.dataDisplayedFunction){M.dataDisplayedFunction(Q)}}};P.ifLoaded=function(){this.count++;if(this.count==this.loadTarget){this.ifLoadedFunction()}};for(var R=0;R<M.datasets.length;R++){(function(G){var B=M.datasets[G]["data"];var C=U[G];var A=function(H){return H};var D=M.datasets[G]["preloadFunction"]||A;var E=M.datasets[G]["transformFunction"]||A;switch(B.type){case"basic":var F=D(B.value);C.loadItems(F,E);P.ifLoaded();break;case"json":JSONLoader.read(B.url,function(I){var H=D(I);C.loadItems(H,E);P.ifLoaded()});break;case"kml":GDownloadUrl(B.url,function(I){var H=TimeMapDataset.parseKML(I);H=D(H);C.loadItems(H,E);P.ifLoaded()});break;case"metaweb":Metaweb.read(B.query,function(I){var H=D(I);C.loadItems(I,E);P.ifLoaded()});break}})(R)}return Q};var timemapInit=TimeMap.init;TimeMap.intervals={sec:[Timeline.DateTime.SECOND,Timeline.DateTime.MINUTE],min:[Timeline.DateTime.MINUTE,Timeline.DateTime.HOUR],hr:[Timeline.DateTime.HOUR,Timeline.DateTime.DAY],day:[Timeline.DateTime.DAY,Timeline.DateTime.WEEK],wk:[Timeline.DateTime.WEEK,Timeline.DateTime.MONTH],mon:[Timeline.DateTime.MONTH,Timeline.DateTime.YEAR],yr:[Timeline.DateTime.YEAR,Timeline.DateTime.DECADE],dec:[Timeline.DateTime.DECADE,Timeline.DateTime.CENTURY]};TimeMap.mapTypes={normal:G_NORMAL_MAP,satellite:G_SATELLITE_MAP,hybrid:G_HYBRID_MAP,physical:G_PHYSICAL_MAP,moon:G_MOON_VISIBLE_MAP,sky:G_SKY_VISIBLE_MAP};TimeMap.prototype.createDataset=function(F,H){H=H||{};if(!("title" in H)){H.title=F}var G=new TimeMapDataset(this,H);this.datasets[F]=G;if(this.opts.centerMapOnItems){var E=this;GEvent.addListener(G,"itemsloaded",function(){E.map.setZoom(E.map.getBoundsZoomLevel(E.mapBounds));E.map.setCenter(E.mapBounds.getCenter())})}return G};TimeMap.prototype.each=function(B){for(id in this.datasets){B(this.datasets[id])}};TimeMap.prototype.initTimeline=function(F){for(var E=1;E<F.length;E++){if(this.opts.syncBands){F[E].syncWith=(E-1)}F[E].highlight=true}this.timeline=Timeline.create(this.tElement,F);var H=this;this.timeline.getBand(0).addOnScrollListener(function(){H.filter("map")});GEvent.addListener(H.map,"moveend",function(){H.filter("timeline")});this.addFilterChain("map",function(A){A.showPlacemark()},function(A){A.hidePlacemark()});this.addFilter("map",function(A){return A.dataset.visible});if(this.opts.hidePastFuture){this.addFilter("map",TimeMap.hidePastFuture)}else{if(this.opts.showMomentOnly){this.addFilter("map",TimeMap.showMomentOnly)}}resizeTimerID=null;var G=this.timeline;window.onresize=function(){if(resizeTimerID==null){resizeTimerID=window.setTimeout(function(){resizeTimerID=null;G.layout()},500)}}};TimeMap.prototype.filter=function(D){var C=this.filters[D];if(!C||!C.chain||C.chain.length==0){return }this.each(function(A){A.each(function(B){F_LOOP:{for(var F=C.chain.length-1;F>=0;F--){if(!C.chain[F](B)){C.off(B);break F_LOOP}}C.on(B)}})})};TimeMap.prototype.addFilterChain=function(E,F,D){this.filters[E]={chain:[],on:F,off:D}};TimeMap.prototype.removeFilterChain=function(E,D,F){this.filters[E]=null};TimeMap.prototype.addFilter=function(D,C){if(this.filters[D]&&this.filters[D].chain){this.filters[D].chain.push(C)}};TimeMap.prototype.removeFilter=function(B){if(this.filters[B]&&this.filters[B].chain){this.filters[B].chain.pop()}};TimeMap.hidePastFuture=function(J){var H=J.dataset.timemap.timeline.getBand(0);var L=H.getMaxVisibleDate().getTime();var K=H.getMinVisibleDate().getTime();if(J.event!=null){var G=J.event.getStart().getTime();var I=J.event.getEnd().getTime();if(G>L){return false}else{if(I<K||(J.event.isInstant()&&G<K)){return false}}}return true};TimeMap.showMomentOnly=function(J){var H=J.dataset.timemap.timeline.getBand(0);var G=H.getCenterVisibleDate().getTime();if(J.event!=null){var F=J.event.getStart().getTime();var I=J.event.getEnd().getTime();if(F>G){return false}else{if(I<G||(J.event.isInstant()&&F<G)){return false}}}return true};function TimeMapDataset(C,D){this.timemap=C;this.eventSource=new Timeline.DefaultEventSource();this.items=[];this.visible=true;this.opts=D||{};this.opts.title=D.title||"";if(typeof (D.theme)=="string"){D.theme=TimeMapDataset.themes[D.theme]}this.opts.theme=D.theme||this.timemap.opts.theme||new TimeMapDatasetTheme({});this.opts.theme.eventIconPath=D.eventIconPath||this.timemap.opts.eventIconPath||this.opts.theme.eventIconPath;this.opts.theme.eventIcon=D.eventIconPath+this.opts.theme.eventIconImage;if(typeof (D.dateParser)=="string"){D.dateParser=TimeMapDataset.dateParsers[D.dateParser]}this.opts.dateParser=D.dateParser||TimeMapDataset.dateParsers.iso8601;this.getItems=function(){return this.items};this.getTitle=function(){return this.opts.title}}TimeMapDataset.dateParsers={iso8601:Timeline.DateTime.parseIso8601DateTime,gregorian:Timeline.DateTime.parseGregorianDateTime};TimeMapDataset.prototype.each=function(D){for(var C=0;C<this.items.length;C++){D(this.items[C])}};TimeMapDataset.prototype.loadItems=function(E,F){for(var D=0;D<E.length;D++){this.loadItem(E[D],F)}GEvent.trigger(this,"itemsloaded")};TimeMapDataset.prototype.loadItem=function(W,h){if(h!=undefined){W=h(W)}if(W==null){return }var n=W.options||{};if(typeof (n.theme)=="string"){n.theme=TimeMapDataset.themes[n.theme]}var X=n.theme||this.opts.theme;X.eventIconPath=n.eventIconPath||this.opts.theme.eventIconPath;X.eventIcon=X.eventIconPath+X.eventIconImage;var o=this.timemap;var j=(W.start==undefined||W.start=="")?null:this.opts.dateParser(W.start);var l=(W.end==undefined||W.end=="")?null:this.opts.dateParser(W.end);var p=(W.end==undefined);var q=X.eventIcon;var V=W.title;if(j!=null){var b=new Timeline.DefaultEventSource.Event(j,l,null,null,p,V,null,null,null,q,X.eventColor,null)}else{var b=null}var e=function(B){var C=null,A="",I=null;if("point" in B){I=new GLatLng(parseFloat(B.point.lat),parseFloat(B.point.lon));if(o.opts.centerMapOnItems){o.mapBounds.extend(I)}markerIcon=("icon" in B)?B.icon:X.icon;C=new GMarker(I,{icon:markerIcon});A="marker";I=C.getLatLng()}else{if("polyline" in B||"polygon" in B){var G=[];if("polyline" in B){var F=B.polyline}else{var F=B.polygon}for(var J=0;J<F.length;J++){I=new GLatLng(parseFloat(F[J]["lat"]),parseFloat(F[J]["lon"]));G.push(I);if(o.opts.centerMapOnItems){o.mapBounds.extend(I)}}if("polyline" in B){C=new GPolyline(G,X.lineColor,X.lineWeight,X.lineOpacity);A="polyline";I=C.getVertex(Math.floor(C.getVertexCount()/2))}else{C=new GPolygon(G,X.polygonLineColor,X.polygonLineWeight,X.polygonLineOpacity,X.fillColor,X.fillOpacity);A="polygon";I=C.getBounds().getCenter()}}else{if("overlay" in B){var H=new GLatLng(parseFloat(B.overlay.south),parseFloat(B.overlay.west));var D=new GLatLng(parseFloat(B.overlay.north),parseFloat(B.overlay.east));if(o.opts.centerMapOnItems){o.mapBounds.extend(H);o.mapBounds.extend(D)}var E=new GLatLngBounds(H,D);C=new GGroundOverlay(B.overlay.image,E);A="overlay";I=E.getCenter()}}}return{placemark:C,type:A,point:I}};var Y=[],d=[],r=null,m="",c=null;if("placemarks" in W){d=W.placemarks}else{var i=["point","polyline","polygon","overlay"];for(var a=0;a<i.length;a++){if(i[a] in W){r={};r[i[a]]=W[i[a]];d.push(r)}}}if(d){for(var a=0;a<d.length;a++){var g=e(d[a]);if(!c){c=g.point}if(!m){m=g.type}Y.push(g.placemark)}}if(Y.length>1){m="array"}n.title=V;n.type=m||"none";n.theme=X;if(n.infoPoint){n.infoPoint=new GLatLng(parseFloat(n.infoPoint.lat),parseFloat(n.infoPoint.lon))}else{n.infoPoint=c}var Z=new TimeMapItem(Y,b,this,n);if(b!=null){b.item=Z;this.eventSource.add(b)}if(Y.length>0){for(var a=0;a<Y.length;a++){Y[a].item=Z;GEvent.addListener(Y[a],"click",function(){Z.openInfoWindow()});o.map.addOverlay(Y[a]);Y[a].hide()}}this.items.push(Z);return Z};TimeMapDataset.parseKML=function(Y){var Z=[],O,Q,X,R;Q=GXml.parse(Y);var b=function(A,C){var B=A.getElementsByTagName(C);if(B.length>0){return B[0].firstChild.nodeValue}else{return""}};var S=function(A,B){var D=false;nList=A.getElementsByTagName("TimeStamp");if(nList.length>0){B.start=b(nList[0],"when");D=true}else{nList=A.getElementsByTagName("TimeSpan");if(nList.length>0){B.start=b(nList[0],"begin");B.end=b(nList[0],"end");D=true}}if(!D){var C=A.parentNode;if(C.nodename=="Folder"||C.nodename=="Document"){TimeMapDataset.findNodeTime(C,B)}C=null}};X=Q.getElementsByTagName("Placemark");for(var P=0;P<X.length;P++){R=X[P];O={options:{}};O.title=b(R,"name");O.options.description=b(R,"description");S(R,O);PLACEMARK:{var U,T,a,W;nList=R.getElementsByTagName("Point");if(nList.length>0){O.point={};U=b(nList[0],"coordinates");a=U.split(",");O.point={lat:trim(a[1]),lon:trim(a[0])};break PLACEMARK}nList=R.getElementsByTagName("LineString");if(nList.length>0){W="polyline"}else{nList=R.getElementsByTagName("Polygon");if(nList.length>0){W="polygon"}}if(nList.length>0){O[W]=[];U=b(nList[0],"coordinates");T=trim(U).split(/[\r\n\f ]+/);for(var V=0;V<T.length;V++){a=T[V].split(",");O[W].push({lat:trim(a[1]),lon:trim(a[0])})}break PLACEMARK}}Z.push(O)}X=Q.getElementsByTagName("GroundOverlay");for(var P=0;P<X.length;P++){R=X[P];O={options:{},overlay:{}};O.title=b(R,"name");O.options.description=b(R,"description");S(R,O);nList=R.getElementsByTagName("Icon");O.overlay.image=b(nList[0],"href");nList=R.getElementsByTagName("LatLonBox");O.overlay.north=b(nList[0],"north");O.overlay.south=b(nList[0],"south");O.overlay.east=b(nList[0],"east");O.overlay.west=b(nList[0],"west");Z.push(O)}Q=null;X=null;R=null;nList=null;return Z};function TimeMapDatasetTheme(D){D=D||{};if(!D.icon){var C=new GIcon(G_DEFAULT_ICON);this.iconImage=D.iconImage||"http://www.google.com/intl/en_us/mapfiles/ms/icons/red-dot.png";C.image=this.iconImage;C.iconSize=new GSize(32,32);C.shadow="http://www.google.com/intl/en_us/mapfiles/ms/icons/msmarker.shadow.png";C.shadowSize=new GSize(59,32)}this.icon=D.icon||C;this.color=D.color||"#FE766A";this.lineColor=D.lineColor||this.color;this.polygonLineColor=D.polygonLineColor||this.lineColor;this.lineOpacity=D.lineOpacity||1;this.polgonLineOpacity=D.polgonLineOpacity||this.lineOpacity;this.lineWeight=D.lineWeight||2;this.polygonLineWeight=D.polygonLineWeight||this.lineWeight;this.fillColor=D.fillColor||this.color;this.fillOpacity=D.fillOpacity||0.25;this.eventColor=D.eventColor||this.color;this.eventIconPath=D.eventIconPath||"timemap/images/";this.eventIconImage=D.eventIconImage||"red-circle.png";this.eventIcon=D.eventIcon||this.eventIconPath+this.eventIconImage}TimeMapDataset.redTheme=function(B){return new TimeMapDatasetTheme(B)};TimeMapDataset.blueTheme=function(B){B=B||{};B.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/blue-dot.png";B.color="#5A7ACF";B.eventIconImage="blue-circle.png";return new TimeMapDatasetTheme(B)};TimeMapDataset.greenTheme=function(B){B=B||{};B.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/green-dot.png";B.color="#19CF54";B.eventIconImage="green-circle.png";return new TimeMapDatasetTheme(B)};TimeMapDataset.ltblueTheme=function(B){B=B||{};B.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/ltblue-dot.png";B.color="#5ACFCF";B.eventIconImage="ltblue-circle.png";return new TimeMapDatasetTheme(B)};TimeMapDataset.purpleTheme=function(B){B=B||{};B.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/purple-dot.png";B.color="#8E67FD";B.eventIconImage="purple-circle.png";return new TimeMapDatasetTheme(B)};TimeMapDataset.orangeTheme=function(B){B=B||{};B.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/orange-dot.png";B.color="#FF9900";B.eventIconImage="orange-circle.png";return new TimeMapDatasetTheme(B)};TimeMapDataset.yellowTheme=function(B){B=B||{};B.iconImage="http://www.google.com/intl/en_us/mapfiles/ms/icons/yellow-dot.png";B.color="#ECE64A";B.eventIconImage="yellow-circle.png";return new TimeMapDatasetTheme(B)};TimeMapDataset.themes={red:TimeMapDataset.redTheme(),blue:TimeMapDataset.blueTheme(),green:TimeMapDataset.greenTheme(),ltblue:TimeMapDataset.ltblueTheme(),orange:TimeMapDataset.orangeTheme(),yellow:TimeMapDataset.yellowTheme(),purple:TimeMapDataset.purpleTheme()};function TimeMapItem(H,G,F,E){this.event=G;this.dataset=F;this.map=F.timemap.map;if(H&&isArray(H)&&H.length==0){H=null}if(H&&H.length==1){H=H[0]}this.placemark=H;this.opts=E||{};this.opts.type=E.type||"";this.opts.title=E.title||"";this.opts.description=E.description||"";this.opts.infoPoint=E.infoPoint||null;this.opts.infoHtml=E.infoHtml||"";this.opts.infoUrl=E.infoUrl||"";this.getType=function(){return this.opts.type};this.getTitle=function(){return this.opts.title};this.getInfoPoint=function(){return this.opts.infoPoint||this.map.getCenter()};this.visible=false;this.showPlacemark=function(){if(this.placemark){if(this.getType()=="array"){for(var A=0;A<this.placemark.length;A++){this.placemark[A].show()}}else{this.placemark.show()}this.visible=true}};this.hidePlacemark=function(){if(this.placemark){if(this.getType()=="array"){for(var A=0;A<this.placemark.length;A++){this.placemark[A].hide()}}else{this.placemark.hide()}this.visible=false}this.closeInfoWindow()};this.openInfoWindow=E.openInfoWindow||F.opts.openInfoWindow||F.timemap.opts.openInfoWindow||false;if(!this.openInfoWindow){if(this.opts.infoUrl!=""){this.openInfoWindow=TimeMapItem.openInfoWindowAjax}else{this.openInfoWindow=TimeMapItem.openInfoWindowBasic}}this.closeInfoWindow=E.closeInfoWindow||TimeMapItem.closeInfoWindowBasic}TimeMapItem.openInfoWindowBasic=function(){var C=this.opts.infoHtml;if(C==""){C='<div class="infotitle">'+this.opts.title+"</div>";if(this.opts.description!=""){C+='<div class="infodescription">'+this.opts.description+"</div>"}}if(this.placemark&&!this.visible&&this.event){var D=this.dataset.timemap.timeline.getBand(0);D.setCenterVisibleDate(this.event.getStart())}if(this.getType()=="marker"){this.placemark.openInfoWindowHtml(C)}else{this.map.openInfoWindowHtml(this.getInfoPoint(),C)}};TimeMapItem.openInfoWindowAjax=function(){if(this.opts.infoHtml!=""){this.openInfoWindow=TimeMapItem.openInfoWindowBasic;this.openInfoWindow()}else{if(this.opts.infoUrl!=""){var B=this;GDownloadUrl(this.opts.infoUrl,function(A){B.opts.infoHtml=A;B.openInfoWindow()})}else{this.openInfoWindow=TimeMapItem.openInfoWindowBasic;this.openInfoWindow()}}};TimeMapItem.closeInfoWindowBasic=function(){if(this.getType()=="marker"){this.placemark.closeInfoWindow()}else{var B=this.map.getInfoWindow();if(B.getPoint()==this.getInfoPoint()&&!B.isHidden()){this.map.closeInfoWindow()}}};function trim(B){return B.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function isArray(B){return B&&!(B.propertyIsEnumerable("length"))&&typeof B==="object"&&typeof B.length==="number"}TimeMap.prototype.toJSON=function(){var B={options:this.makeOptionData,datasets:this.datasets};B=this.addExportData(B)};TimeMap.prototype.makeOptionData=function(){var I={};for(k in this.opts){I[k]=this.opts[k]}if(I.mapCenter){I.mapCenter=TimeMap.makePoint(I.mapCenter)}if(I.mapType){I.mapType=revHash(TimeMap.mapTypes,I.mapType)}if(I.mapTypes){var H=[],K;for(var L=0;L<I.mapTypes.length;L++){K=revHash(TimeMap.mapTypes,I.mapTypes[L]);if(K){H.push(K)}}I.mapTypes=H}if(I.bandIntervals){I.bandIntervals=revHash(TimeMap.intervals,I.bandIntervals)}var G=[],J;for(id in this.datasets){J=revHash(TimeMapDataset.themes,this.datasets[id].opts.theme);if(J){G.push(J)}}I.themes=J;return I};TimeMap.prototype.addExportData=function(B){B.options=B.options||{};B.options.saveOpts=this.opts.saveOpts;return B};TimeMapDataset.prototype.toJSON=function(){var B={title:this.getTitle(),theme:revHash(TimeMapDataset.themes,this.opts.theme),data:{type:"basic",value:this.getItems()}};B=this.addExportData(B);return B};TimeMapDataset.prototype.addExportData=function(B){B.options=B.options||{};B.options.saveOpts=this.opts.saveOpts;return B};TimeMapItem.prototype.toJSON=function(){var E={title:this.getTitle(),options:{description:this.opts.description}};if(this.event){E.start=this.event.getStart();if(!this.event.isInstant()){E.end=this.event.getEnd()}}if(this.placemark){var F=function(B,C,A){B=B||TimeMapItem.getPlacemarkType(C);switch(B){case"marker":A.point=TimeMap.makePoint(C.getLatLng());break;case"polyline":case"polygon":line=[];for(var H=0;H<C.getVertexCount();H++){line.push(TimeMap.makePoint(C.getVertex(H)))}A[B]=line;break}return A};if(this.getType()=="array"){E.placemarks=[];for(var D=0;D<this.placemark.length;D++){E.placemarks.push(F(false,this.placemark[D],{}))}}else{E=F(this.getType(),this.placemark,E)}}E=this.addExportData(E);return E};TimeMapItem.prototype.addExportData=function(B){B.options=B.options||{};B.options.saveOpts=this.opts.saveOpts;return B};TimeMap.makePoint=function(B){return{lat:B.lat(),lon:B.lng()}};function revHash(C,D){for(k in C){if(C[k]==D){return k}}return null};
