function EGeoXml(b,i,f,d){this.myvar=b;this.map=i;this.url=f;this.urls=typeof f=="string"?[f]:f;this.opts=d||{};this.titlestyle=this.opts.titlestyle||'style = "font-family: arial, sans-serif;font-size: medium;font-weight:bold;font-size: 100%;"';this.descstyle=this.opts.descstyle||'style = "font-family: arial, sans-serif;font-size: small;padding-bottom:.7em;"';this.directionstyle=this.opts.directionstyle||'style="font-family: arial, sans-serif;font-size: small;padding-left: 1px;padding-top: 1px;padding-right: 4px;"';
this.sidebarfn=this.opts.sidebarfn||EGeoXml.addSidebar;this.dropboxfn=this.opts.dropboxfn||EGeoXml.addDropdown;this.elabelopacity=this.opts.elabelopacity||100;this.bounds=new GLatLngBounds;this.gmarkers=[];this.gpolylines=[];this.gpolygons=[];this.groundoverlays=[];this.side_bar_html="";this.side_bar_list=[];this.styles=[];this.iwwidth=this.opts.iwwidth||250;this.progress=0;this.lastmarker={};this.myimages=[];this.imageNum=0}
EGeoXml.value=function(b){a=GXml.value(b);a=a.replace(/^\s*/,"");return a=a.replace(/\s*$/,"")};
EGeoXml.prototype.createMarker=function(b,i,f,d){var c=G_DEFAULT_ICON,e=this.opts.iwoptions||{},g=this.opts.markeroptions||{};if((this.opts.icontype||"style")=="style")if(this.styles[d])c=this.styles[d];if(!g.icon){g.icon=c;g.title=i}var h=new GMarker(b,g);if(this.opts.preloadimages){d=/<\s*img/ig;var k;g=/src\s*=\s*[\'\"]/;for(var j=/[\'\"]/;(k=d.exec(f))!=null;){k=f.substr(k.index);var l=g.exec(k);if(l!=null){k=k.substr(l.index+l[0].length);l=j.exec(k);if(l!=null){k=k.substr(0,l.index);this.myimages[this.imageNum]=
new Image;this.myimages[this.imageNum].src=k;this.imageNum++}}}}this.opts.elabelclass&&this.map.addOverlay(new ELabel(b,i,this.opts.elabelclass,this.opts.elabeloffset,this.elabelopacity,true));d="<div style = 'width:"+this.iwwidth+"px'><h1 "+this.titlestyle+">"+i+"</h1><div "+this.descstyle+">"+f+"</div>";if(this.opts.directions){var m=d+"<div "+this.directionstyle+'>Get Directions: <a href="javascript:GEvent.trigger('+this.myvar+".lastmarker,'click2')\">To Here</a> - <a href=\"javascript:GEvent.trigger("+
this.myvar+".lastmarker,'click3')\">From Here</a><br><a href=\"javascript:GEvent.trigger("+this.myvar+".lastmarker,'click4')\">Search nearby</a></div>",n=d+"<div "+this.directionstyle+'>Get Directions: To here - <a href="javascript:GEvent.trigger('+this.myvar+'.lastmarker,\'click3\')">From Here</a><br>Start address:<form action="http://maps.google.com/maps" method="get" target="_blank"><input type="text" SIZE=35 MAXLENGTH=80 name="saddr" id="saddr" value="" /><INPUT value="Go" TYPE="SUBMIT"><input type="hidden" name="daddr" value="'+
b.lat()+","+b.lng()+"("+i+')"/><br><a href="javascript:GEvent.trigger('+this.myvar+".lastmarker,'click')\">&#171; Back</a></div>",o=d+"<div "+this.directionstyle+'>Get Directions: <a href="javascript:GEvent.trigger('+this.myvar+'.lastmarker,\'click2\')">To Here</a> - From Here<br>End address:<form action="http://maps.google.com/maps" method="get"" target="_blank"><input type="text" SIZE=35 MAXLENGTH=80 name="daddr" id="daddr" value="" /><INPUT value="Go" TYPE="SUBMIT"><input type="hidden" name="saddr" value="'+
b.lat()+","+b.lng()+"("+i+')"/><br><a href="javascript:GEvent.trigger('+this.myvar+".lastmarker,'click')\">&#171; Back</a></div>",p=d+"<div "+this.directionstyle+'>Search nearby: e.g. "pizza"<br><form action="http://maps.google.com/maps" method="get"" target="_blank"><input type="text" SIZE=35 MAXLENGTH=80 name="q" id="q" value="" /><INPUT value="Go" TYPE="SUBMIT"><input type="hidden" name="near" value="'+i+" @"+b.lat()+","+b.lng()+'"/><br><a href="javascript:GEvent.trigger('+this.myvar+".lastmarker,'click')\">&#171; Back</a></div>";
GEvent.addListener(h,"click2",function(){h.openInfoWindowHtml(n+"</div>",e)});GEvent.addListener(h,"click3",function(){h.openInfoWindowHtml(o+"</div>",e)});GEvent.addListener(h,"click4",function(){h.openInfoWindowHtml(p+"</div>",e)})}else m=d;GEvent.addListener(h,"click",function(){h.openInfoWindowHtml(m+"</div>",e)});this.opts.addmarker?this.opts.addmarker(h,i,f,c.image,this.gmarkers.length):this.map.addOverlay(h);this.gmarkers.push(h);if(this.opts.sidebarid||this.opts.dropboxid)this.side_bar_list.push(i+
"$$$marker$$$"+(this.gmarkers.length-1)+"$$$")};
EGeoXml.prototype.createPolyline=function(b,i,f,d,c,e,g){var h=this.map,k=this.opts.iwoptions||{},j=new GPolyline(b,i,f,d,this.opts.polylineoptions||{});this.map.addOverlay(j);this.gpolylines.push(j);var l="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+e+"</div><div style='font-family: Arial, sans-serif;font-size: small;width:"+this.iwwidth+"px'>"+g+"</div>";GEvent.addListener(j,"click",function(){h.openInfoWindowHtml(j.getVertex(Math.floor(j.getVertexCount()/2)),l,k)});
this.opts.sidebarid&&this.side_bar_list.push(e+"$$$polyline$$$"+(this.gpolylines.length-1)+"$$$"+('&nbsp;&nbsp;<span style=";border-left:'+f+"px solid "+i+';">&nbsp;</span> '))};
EGeoXml.prototype.createPolygon=function(b,i,f,d,c,e,g,h,k){var j=this.map,l=this.opts.iwoptions||{};b=new GPolygon(b,i,f,d,c,e,this.opts.polygonoptions||{});this.map.addOverlay(b);this.gpolygons.push(b);var m="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+h+"</div><div style='font-family: Arial, sans-serif;font-size: small;width:"+this.iwwidth+"px'>"+k+"</div>";GEvent.addListener(b,"click",function(){j.openInfoWindowHtml(g.getCenter(),m,l)});this.opts.sidebarid&&this.side_bar_list.push(h+
"$$$polygon$$$"+(this.gpolygons.length-1)+"$$$"+('<span style="background-color:'+c+";border:2px solid "+i+';">&nbsp;&nbsp;&nbsp;&nbsp;</span> '))};
EGeoXml.addSidebar=function(b,i,f,d,c){if(f=="marker")return'<a href="javascript:GEvent.trigger('+b+".gmarkers["+d+"],'click')\">"+i+"</a><br>";if(f=="polyline")return'<div style="margin-top:6px;"><a href="javascript:GEvent.trigger('+b+".gpolylines["+d+"],'click')\">"+c+i+"</a></div>";if(f=="polygon")return'<div style="margin-top:6px;"><a href="javascript:GEvent.trigger('+b+".gpolygons["+d+"],'click')\">"+c+i+"</a></div>"};EGeoXml.addDropdown=function(b,i,f,d){return'<option value="'+d+'">'+i+"</option>"};
EGeoXml.prototype.parse=function(){this.gmarkers=[];this.gpolylines=[];this.gpolygons=[];this.groundoverlays=[];this.side_bar_html="";this.side_bar_list=[];this.styles=[];this.lastmarker={};this.myimages=[];this.imageNum=0;var b=this;this.progress=this.urls.length;for(u=0;u<this.urls.length;u++)GDownloadUrl(this.urls[u],function(i){b.processing(i)})};
EGeoXml.prototype.parseString=function(b){this.gmarkers=[];this.gpolylines=[];this.gpolygons=[];this.groundoverlays=[];this.side_bar_html="";this.side_bar_list=[];this.styles=[];this.lastmarker={};this.myimages=[];this.imageNum=0;this.docs=typeof b=="string"?[b]:b;this.progress=this.docs.length;for(u=0;u<this.docs.length;u++)this.processing(this.docs[u])};
EGeoXml.prototype.processing=function(b){var i=GXml.parse(b),f=i.documentElement.getElementsByTagName("Style");for(b=0;b<f.length;b++){var d=f[b].getAttribute("id"),c=f[b].getElementsByTagName("Icon");if(c.length>0){var e=EGeoXml.value(c[0].getElementsByTagName("href")[0]);if(e)if(this.opts.baseicon)this.styles["#"+d]=new GIcon(this.opts.baseicon,e);else{this.styles["#"+d]=new GIcon(G_DEFAULT_ICON,e);this.styles["#"+d].iconSize=new GSize(32,32);this.styles["#"+d].shadowSize=new GSize(59,32);this.styles["#"+
d].dragCrossAnchor=new GPoint(2,8);this.styles["#"+d].iconAnchor=new GPoint(16,32);if(this.opts.printgif){c=e.split("/");c=c[c.length-1];c=this.opts.printgifpath+c.replace(/.png/i,".gif");this.styles["#"+d].printImage=c;this.styles["#"+d].mozPrintImage=c}if(this.opts.noshadow)this.styles["#"+d].shadow="";else if(e.indexOf("/red.png")>-1||e.indexOf("/blue.png")>-1||e.indexOf("/green.png")>-1||e.indexOf("/yellow.png")>-1||e.indexOf("/lightblue.png")>-1||e.indexOf("/purple.png")>-1||e.indexOf("/pink.png")>
-1||e.indexOf("/orange.png")>-1||e.indexOf("-dot.png")>-1)this.styles["#"+d].shadow="http://maps.google.com/mapfiles/ms/micons/msmarker.shadow.png";else if(e.indexOf("-pushpin.png")>-1)this.styles["#"+d].shadow="http://maps.google.com/mapfiles/ms/micons/pushpin_shadow.png";else{c=e.replace(".png",".shadow.png");this.styles["#"+d].shadow=c}}}c=f[b].getElementsByTagName("LineStyle");if(c.length>0){e=parseInt(GXml.value(c[0].getElementsByTagName("width")[0]));if(e<1)e=5;c=EGeoXml.value(c[0].getElementsByTagName("color")[0]);
var g=c.substr(0,2),h=c.substr(2,2),k=c.substr(4,2);c=c.substr(6,2);c="#"+c+k+h;g=parseInt(g,16)/256;this.styles["#"+d]||(this.styles["#"+d]={});this.styles["#"+d].color=c;this.styles["#"+d].width=e;this.styles["#"+d].opacity=g}g=f[b].getElementsByTagName("PolyStyle");if(g.length>0){e=parseInt(GXml.value(g[0].getElementsByTagName("fill")[0]));var j=parseInt(GXml.value(g[0].getElementsByTagName("outline")[0]));c=EGeoXml.value(g[0].getElementsByTagName("color")[0]);if(g[0].getElementsByTagName("fill").length==
0)e=1;if(g[0].getElementsByTagName("outline").length==0)j=1;g=c.substr(0,2);h=c.substr(2,2);k=c.substr(4,2);c=c.substr(6,2);c="#"+c+k+h;g=parseInt(g,16)/256;this.styles["#"+d]||(this.styles["#"+d]={});this.styles["#"+d].fillcolor=c;this.styles["#"+d].fillopacity=g;if(!e)this.styles["#"+d].fillopacity=0;if(!j)this.styles["#"+d].opacity=0}}f=i.documentElement.getElementsByTagName("Placemark");for(b=0;b<f.length;b++){d=EGeoXml.value(f[b].getElementsByTagName("name")[0]);j=EGeoXml.value(f[b].getElementsByTagName("description")[0]);
if(j==""){j=EGeoXml.value(f[b].getElementsByTagName("text")[0]);j=j.replace(/\$\[name\]/,d);j=j.replace(/\$\[geDirections\]/,"")}if(j.match(/^http:\/\//i))j='<a href="'+j+'">'+j+"</a>";if(j.match(/^https:\/\//i))j='<a href="'+j+'">'+j+"</a>";h=EGeoXml.value(f[b].getElementsByTagName("styleUrl")[0]);c=GXml.value(f[b].getElementsByTagName("coordinates")[0]);c=c.replace(/\s+/g," ");c=c.replace(/^ /,"");c=c.replace(/ $/,"");c=c.replace(/, /,",");e=c.split(" ");if(e.length>1){k=[];var l=new GLatLngBounds;
for(g=0;g<e.length;g++){c=e[g].split(",");c=new GLatLng(parseFloat(c[1]),parseFloat(c[0]));k.push(c);this.bounds.extend(c);l.extend(c)}if(f[b].getElementsByTagName("LineString").length){if(this.styles[h]){e=this.styles[h].width;c=this.styles[h].color;g=this.styles[h].opacity}else{e=5;c="#0000ff";g=0.45}this.opts.createpolyline?this.opts.createpolyline(k,c,e,g,l,d,j):this.createPolyline(k,c,e,g,l,d,j)}if(f[b].getElementsByTagName("Polygon").length){if(this.styles[h]){e=this.styles[h].width;c=this.styles[h].color;
g=this.styles[h].opacity;var m=this.styles[h].fillopacity;h=this.styles[h].fillcolor}else{e=5;c="#0000ff";g=0.45;m=0.25;h="#0055ff"}this.opts.createpolygon?this.opts.createpolygon(k,c,e,g,h,m,l,d,j):this.createPolygon(k,c,e,g,h,m,l,d,j)}}else{c=e[0].split(",");c=new GLatLng(parseFloat(c[1]),parseFloat(c[0]));this.bounds.extend(c);this.opts.createmarker?this.opts.createmarker(c,d,j,h):this.createMarker(c,d,j,h)}}i=i.documentElement.getElementsByTagName("GroundOverlay");for(b=0;b<i.length;b++){c=EGeoXml.value(i[b].getElementsByTagName("href")[0]);
f=parseFloat(GXml.value(i[b].getElementsByTagName("north")[0]));e=parseFloat(GXml.value(i[b].getElementsByTagName("south")[0]));d=parseFloat(GXml.value(i[b].getElementsByTagName("east")[0]));j=parseFloat(GXml.value(i[b].getElementsByTagName("west")[0]));e=new GLatLng(e,j);f=new GLatLng(f,d);c=new GGroundOverlay(c,new GLatLngBounds(e,f));this.bounds.extend(e);this.bounds.extend(f);this.groundoverlays.push(c);this.map.addOverlay(c)}this.progress--;if(this.progress==0){this.opts.sortbyname&&this.side_bar_list.sort();
if(this.opts.sidebarid){for(b=0;b<this.side_bar_list.length;b++){c=this.side_bar_list[b].split("$$$",4);this.side_bar_html+=this.sidebarfn(this.myvar,c[0],c[1],c[2],c[3])}document.getElementById(this.opts.sidebarid).innerHTML+=this.side_bar_html}if(this.opts.dropboxid){for(b=0;b<this.side_bar_list.length;b++){c=this.side_bar_list[b].split("$$$",4);if(c[1]=="marker")this.side_bar_html+=this.dropboxfn(this.myvar,c[0],c[1],c[2],c[3])}document.getElementById(this.opts.dropboxid).innerHTML='<select onChange="var I=this.value;if(I>-1){GEvent.trigger('+
this.myvar+".gmarkers[I],'click'); }\"><option selected> - Select a location - </option>"+this.side_bar_html+"</select>"}GEvent.trigger(this,"parsed")}};
EGeoXml.prototype.hide=function(){for(var b=0;b<this.gmarkers.length;b++)this.gmarkers[b].hide();for(b=0;b<this.gpolylines.length;b++)this.gpolylines[b].hide();for(b=0;b<this.gpolygons.length;b++)this.gpolygons[b].hide();for(b=0;b<this.groundoverlays.length;b++)this.groundoverlays[b].hide();if(this.opts.sidebarid)document.getElementById(this.opts.sidebarid).style.display="none";if(this.opts.dropboxid)document.getElementById(this.opts.dropboxid).style.display="none"};
EGeoXml.prototype.show=function(){for(var b=0;b<this.gmarkers.length;b++)this.gmarkers[b].show();for(b=0;b<this.gpolylines.length;b++)this.gpolylines[b].show();for(b=0;b<this.gpolygons.length;b++)this.gpolygons[b].show();for(b=0;b<this.groundoverlays.length;b++)this.groundoverlays[b].show();if(this.opts.sidebarid)document.getElementById(this.opts.sidebarid).style.display="";if(this.opts.dropboxid)document.getElementById(this.opts.dropboxid).style.display=""};
