//	EGeoXml required for all maps, HtmlControl required for map loading animation

/*********************************************************************\
*                                                                     *
* egeoxml.js                                         by Mike Williams *
*                                                                     *
* A Google Maps API Extension                                         *
*                                                                     *
* Renders the contents of a My Maps (or similar) KML file             *
*                                                                     *
* Documentation: http://econym.org.uk/gmap/egeoxml.htm                * 
*                                                                     *
***********************************************************************
*                                                                     *
*   This Javascript is provided by Mike Williams                      *
*   Blackpool Community Church Javascript Team                        *
*   http://www.blackpoolchurch.org/                                   *
*   http://econym.org.uk/gmap/                                        *
*                                                                     *
*   This work is licenced under a Creative Commons Licence            *
*   http://creativecommons.org/licenses/by/2.0/uk/                    *
*                                                                     *
\*********************************************************************/

function EGeoXml(myvar, map, url, opts) {
  function myZIndex(marker, b){
	  return GOverlay.getZIndex(90)+1000;
  }
  // store the parameters
  this.myvar=myvar;
  this.map=map;
  this.url=url;
  if (typeof url == "string") {
    this.urls=[url];
  } else {
    this.urls=url;
  }
  this.opts=opts || {};
  // infowindow styles
  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;"';
  // sidebar/dropbox functions
  this.sidebarfn=this.opts.sidebarfn || EGeoXml.addSidebar;
  this.dropboxfn=this.opts.dropboxfn || EGeoXml.addDropdown;
  // elabel options 
  this.elabelopacity=this.opts.elabelopacity || 100;
  // other useful "global" stuff
  this.bounds=new GLatLngBounds();
  this.gmarkers=[];
  this.gpolylines=[];
  this.gpolygons=[];
  this.groundoverlays=[];
  this.side_bar_html="";
  this.side_bar_list=[];
  this.styles=[]; // associative array
  this.iwwidth=this.opts.iwwidth || 250;
  this.progress=0;
  this.lastmarker=false;   
  this.myimages=[];
  this.imageNum =0;
  this.imagesToPreload=[];
  if(opts.elabel){
	  this._eLabel=new ELabel(new GLatLng(0, 0), '', 'eLabelStyle');
	  map.addOverlay(this._eLabel);
	  this._eLabel.hide();
	  this._eLabel.isVisible=false;
	  this._mouseHoverEnabled=true;
	  var highlightIcon=new GIcon();
	  highlightIcon.image='images/anim_icon.gif';
	  highlightIcon.iconSize=new GSize(20, 20);
	  highlightIcon.iconAnchor=new GPoint(10, 10);
	  this._eLabel.marker=new GMarker(new GLatLng(0, 0), {icon:highlightIcon, hide:true, zIndexProcess:myZIndex, clickable:false});
	  map.addOverlay(this._eLabel.marker);
  }
}
               
// uses GXml.value, then removes leading and trailing whitespace
EGeoXml.value=function(e) {
  var a=GXml.value(e);
  a=a.replace(/^\s*/,"");
  a=a.replace(/\s*$/,"");
  return a;
};

// Create Marker

EGeoXml.prototype.createMarker=function(point,name,desc,style) {
	function convertDecDeg(deg){
		var gpsdeg=parseInt(deg);
		var remainder=deg-(gpsdeg*1.0);
		var gpsmin=remainder*60.0;
		return {deg:gpsdeg, mins:gpsmin.toFixed(4)};
	}
	
  var icon=new GIcon();
  icon.image='images/small_icon.png';
  icon.iconSize=new GSize(10, 10);
  icon.iconAnchor=new GPoint(5, 5);
  var markeroptions=this.opts.markeroptions || {};
  var icontype=this.opts.icontype || "style";
  if (icontype == "style" || icontype==="small") {
    if (!!this.styles[style]) {
      icon=this.styles[style];
    }
  }
  if (!markeroptions.icon) {
    markeroptions.icon=icon;
  }
  
  var title;
  if(icontype==="style"){
	  title='Klik for at aktiverer tekstboks';
  } else {
  	title=name;
	markeroptions.icon.iconSize=new GSize(18, 20);
	markeroptions.icon.iconAnchor=new GPoint(9, 10);
  }
  
  markeroptions.title=title;
  var m=new GMarker(point, markeroptions);
  
  if(icontype==="style"){
	  //	large map loaded
	  m._title=name;
	// Attempt to preload images
	if (this.opts.preloadimages) {
		var text=desc;
		var pattern=/<\s*img/ig;
		var result;
		var pattern2=/src\s*=\s*[\'\"]/;
		var pattern3=/[\'\"]/;
		while ((result=pattern.exec(text)) !== null) {
			var stuff=text.substr(result.index);
			var result2=pattern2.exec(stuff);
			if (result2!==null) {
				stuff=stuff.substr(result2.index+result2[0].length);
				var result3=pattern3.exec(stuff);
					if (result3!==null) {
					var imageUrl=stuff.substr(0,result3.index);
					//	this.myimages[this.imageNum]=new Image();
					this.imagesToPreload.push(imageUrl);
					//	this.myimages[this.imageNum].src=imageUrl;
					//	this.imageNum++;
				}
			}
		}
	}
	
	var east=convertDecDeg(point.lng()), north=convertDecDeg(point.lat()), gpsCoords='E&nbsp;'+east.deg+'&nbsp;'+east.mins+' N&nbsp;'+north.deg+'&nbsp;'+north.mins;
	var html='<table style="width:'+this.iwwidth+'px"><tr><td align="left" '+this.titlestyle+'>'+name+'</td></tr><tr><td '+this.descstyle+'>'+desc+'</td></tr><tr><td align="center">GPS koordinater: <span style="border:1px #0086DF solid; background-color:white">&nbsp;'+gpsCoords+'&nbsp;</span></td></tr></table>';
	m._html=html;
	
	var $this=this;
	  
	GEvent.addListener(m, 'click', function(){
		$this._mouseHoverEnabled=!$this._mouseHoverEnabled;
		if(m!==$this.lastmarker){
			GEvent.trigger(m, 'mouseover');
		}
	});
	  
	GEvent.addListener(m, "mouseover", function() {
		if($this._mouseHoverEnabled){
			$this.showElabel(m);
			document.getElementById('locationsCtnCtn').scrollTop=document.getElementById('sidebar'+m._index).offsetTop-140;
		}
	});
	GEvent.addListener(m, 'mouseout', function(){
		if($this._mouseHoverEnabled){
			$this.hideElabel();
		}
	});
  } else {
	  //	small map
	  GEvent.addListener(m, "click", function() {
		var url='google_map_large.php?index='+m._index;
		if(MARKER_CLICK_ACTION==='category'){
			url+='&category='+m._category;
		} else if(MARKER_CLICK_ACTION!=='index'){
			if(MARKER_CLICK_ACTION.length===1){
				url+='&category='+MARKER_CLICK_ACTION[0];
			} else {
				for(var i=0; i<MARKER_CLICK_ACTION.length; i++){
					url+='&category[]='+MARKER_CLICK_ACTION[i];
				}
			}
		}
		//	location.href=encodeURI(url);
		//	javascript open large map in new window
		parent.location.href=encodeURI(url);
	  });
	  
  }
  
  if (!!this.opts.addmarker) {
    this.opts.addmarker(m,name,desc,icon.image,this.gmarkers.length);
  } else {
    this.map.addOverlay(m);
  }
  this.gmarkers.push(m);
  if (this.opts.sidebarid || this.opts.dropboxid) {
    var n=this.gmarkers.length-1;
    this.side_bar_list.push (name + "$$$marker$$$" + n +"$$$" );
  }
};

EGeoXml.prototype.showElabel=function(marker){
	var eLabel=this._eLabel, mapCenter=this.map.getCenter(), lng=marker.getLatLng().lng(), x, y, html;
	if(this.lastmarker!==false){
		document.getElementById('sidebar'+this.lastmarker._index).className='';
	}
	if(!this.map.getBounds().contains(marker.getLatLng())){
		this.map.setCenter(marker.getLatLng());
	}
	html='<table class="elabelHtml"><tr><td>'+marker._html+'</td></tr><tr><td align="center"><a onclick="addLocationToRoutePlan('+marker._index+')" target="_top" style="cursor:pointer; text-decoration:underline">Føj til Ruteplan</a></td></tr><tr><td align="center"><a onclick="zoomIn()" style="cursor:pointer"><img src="images/zoomin.gif" width="22" height="22" alt="Zoom ind" title="Zoom ind" border="0" /></a>&nbsp;<a onclick="resetZoom()" style="cursor:pointer"><img src="images/resetzoom.gif" width="22" height="22" alt="Nulstil zoom" title="Nulstil zoom" border="0" /></a>&nbsp;<a onclick="exml.hideElabel()" style="cursor:pointer"><img src="images/close.gif" width="22" height="22" alt="Luk vindue" title="Luk vindue" border="0" /></a></td></tr></table>';
	this._eLabel.marker.setLatLng(marker.getLatLng());
	this._eLabel.marker.show();
	eLabel.setContents(html);
	eLabel.setPoint(marker.getLatLng());
	if(!eLabel.isVisible){
		eLabel.show();
		eLabel.isVisible=true;
	}
	if(lng>mapCenter.lng()){
		x=(-eLabel.div_.offsetWidth)-20;
	} else {
		x=20;
	}
	var eLabelAnchorPointY=this.map.fromLatLngToContainerPixel(marker.getLatLng()).y;
	var eLabelHeight=eLabel.div_.offsetHeight;
	var mapHeight=this.map.getSize().height;
	y=eLabelHeight/2;
	if(eLabelAnchorPointY+(eLabelHeight/2)>=mapHeight){
		y-=(eLabelHeight-(mapHeight-eLabelAnchorPointY))/2;
	} else if(eLabelAnchorPointY-(eLabelHeight/2)<=0){
		y+=(eLabelHeight-eLabelAnchorPointY)/2;
	}
	
	eLabel.pixelOffset=new GSize(x, y);
	eLabel.redraw(true);
	document.getElementById('sidebar'+marker._index).className='activeMarker';
	this.lastmarker=marker;
};

EGeoXml.prototype.hideElabel=function(){
	this._eLabel.hide();
	this._eLabel.marker.hide();
	this._eLabel.setPoint(new GLatLng(0, 0));	//	move/hide from GDirections infowindow
	this._eLabel.isVisible=false;
	if(this.lastmarker!==false){
		document.getElementById('sidebar'+this.lastmarker._index).className='';
	}
	this._mouseHoverEnabled=true;
	this.lastmarker=false;
};


EGeoXml.prototype.toggleElabel=function(index){
	var eLabel=this._eLabel;
	if(eLabel.isVisible && this.gmarkers[index]===this.lastmarker){
		this.hideElabel();
	} else {
		this.showElabel(this.gmarkers[index]);
	}
};

// Create Polyline

EGeoXml.prototype.createPolyline=function(points,color,width,opacity,pbounds,name,desc) {
  var thismap=this.map;
  var iwoptions=this.opts.iwoptions || {};
  var polylineoptions=this.opts.polylineoptions || {};
  var p=new GPolyline(points,color,width,opacity,polylineoptions);
  this.map.addOverlay(p);
  this.gpolylines.push(p);
  var html="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+name+"</div>"+"<div style='font-family: Arial, sans-serif;font-size: small;width:"+this.iwwidth+"px'>"+desc+"</div>";
  GEvent.addListener(p,"click", function() {
    thismap.openInfoWindowHtml(p.getVertex(Math.floor(p.getVertexCount()/2)),html,iwoptions);
  } );
  if (this.opts.sidebarid) {
    var n=this.gpolylines.length-1;
    var blob='&nbsp;&nbsp;<span style=";border-left:'+width+'px solid '+color+';">&nbsp;</span> ';
    this.side_bar_list.push (name + "$$$polyline$$$" + n +"$$$" + blob );
  }
};

// Create Polygon

EGeoXml.prototype.createPolygon=function(points,color,width,opacity,fillcolor,fillopacity,pbounds, name, desc) {
  var thismap=this.map;
  var iwoptions=this.opts.iwoptions || {};
  var polygonoptions=this.opts.polygonoptions || {};
  var p=new GPolygon(points,color,width,opacity,fillcolor,fillopacity,polygonoptions);
  this.map.addOverlay(p);
  this.gpolygons.push(p);
  var html="<div style='font-weight: bold; font-size: medium; margin-bottom: 0em;'>"+name+"</div>"+"<div style='font-family: Arial, sans-serif;font-size: small;width:"+this.iwwidth+"px'>"+desc+"</div>";
  GEvent.addListener(p,"click", function() {
    thismap.openInfoWindowHtml(pbounds.getCenter(),html,iwoptions);
  } );
  if (this.opts.sidebarid) {
    var n=this.gpolygons.length-1;
    var blob='<span style="background-color:' +fillcolor + ';border:2px solid '+color+';">&nbsp;&nbsp;&nbsp;&nbsp;</span> ';
    this.side_bar_list.push (name + "$$$polygon$$$" + n +"$$$" + blob );
  }
};


// Sidebar factory method One - adds an entry to the sidebar
EGeoXml.addSidebar=function(myvar,name,type,i,graphic) {
  if (type == "marker") {
	  var $html='<div id="sidebar'+i+'"><a onclick="'+myvar+'._mouseHoverEnabled=false;'+myvar+'.toggleElabel('+i+')" style="cursor:pointer; text-decoration:underline">' + name + '</a></div>';
    return $html;
  }
  if (type == "polyline") {
    return '<div style="margin-top:6px;"><a href="javascript:GEvent.trigger(' + myvar+ '.gpolylines['+i+'],\'click\')">' + graphic + name + '</a></div>';
  }
  if (type == "polygon") {
    return '<div style="margin-top:6px;"><a href="javascript:GEvent.trigger(' + myvar+ '.gpolygons['+i+'],\'click\')">' + graphic + name + '</a></div>';
  }
};

// Dropdown factory method
EGeoXml.addDropdown=function(myvar,name,type,i,graphic) {
    return '<option value="' + i + '">' + name +'</option>';
};

  
// Request to Parse an XML file

EGeoXml.prototype.parse=function() {
  // clear some variables
  this.gmarkers=[];
  this.gpolylines=[];
  this.gpolygons=[];
  this.groundoverlays=[];
  this.side_bar_html="";
  this.side_bar_list=[];
  this.styles=[]; // associative array
  this.lastmarker=false;   
  this.myimages=[];
  this.imageNum =0;
  var that=this;
  this.progress=this.urls.length;
  for (var u=0; u<this.urls.length; u++) {
    GDownloadUrl(this.urls[u], function(doc) {that.processing(doc);});
  }
};

EGeoXml.prototype.parseString=function(doc) {
  // clear some variables
  this.gmarkers=[];
  this.gpolylines=[];
  this.gpolygons=[];
  this.groundoverlays=[];
  this.side_bar_html="";
  this.side_bar_list=[];
  this.styles=[]; // associative array
  this.lastmarker=false;   
  this.myimages=[];
  this.imageNum =0;
  if (typeof doc == "string") {
    this.docs=[doc];
  } else {
    this.docs=doc;
  }
  this.progress=this.docs.length;
  for (var u=0; u<this.docs.length; u++) {
    this.processing(this.docs[u]);
  }
};


EGeoXml.prototype.processing=function(doc) {
    var that=this;
    var xmlDoc=GXml.parse(doc);
    // Read through the Styles
    var styles=xmlDoc.documentElement.getElementsByTagName("Style");
    for (var i=0; i <styles.length; i++) {
      var styleID=styles[i].getAttribute("id");
      var icons=styles[i].getElementsByTagName("Icon");
      // This might not be am icon style
      if (icons.length > 0) {
        var href=EGeoXml.value(icons[0].getElementsByTagName("href")[0]);
        if (!!href) {
          if (!!that.opts.baseicon) {
            that.styles["#"+styleID]=new GIcon(that.opts.baseicon,href);
          } else {
            that.styles["#"+styleID]=new GIcon();
			//	workaround for By.png
			if(href==='http://bellamallorca.dk/upload/images/google-maps-icons-1.2/By.png'){
				href='images/By.png';	
			}
            that.styles["#"+styleID].image=href;
            that.styles["#"+styleID].iconSize=new GSize(36,40);
            that.styles["#"+styleID].iconAnchor=new GPoint(18,36);
            if (that.opts.printgif) {
              var bits=href.split("/");
              var gif=bits[bits.length-1];
              gif=that.opts.printgifpath + gif.replace(/.png/i,".gif");
              that.styles["#"+styleID].printImage=gif;
              that.styles["#"+styleID].mozPrintImage=gif;
            }
          }
        }
      }
      // is it a LineStyle ?
      var linestyles=styles[i].getElementsByTagName("LineStyle");
      if (linestyles.length > 0) {
        var width=parseInt(GXml.value(linestyles[0].getElementsByTagName("width")[0]));
        if (width < 1) {width=5;}
        var color=EGeoXml.value(linestyles[0].getElementsByTagName("color")[0]);
        var aa=color.substr(0,2);
        var bb=color.substr(2,2);
        var gg=color.substr(4,2);
        var rr=color.substr(6,2);
        color="#" + rr + gg + bb;
        var opacity=parseInt(aa,16)/256;
        if (!that.styles["#"+styleID]) {
          that.styles["#"+styleID]={};
        }
        that.styles["#"+styleID].color=color;
        that.styles["#"+styleID].width=width;
        that.styles["#"+styleID].opacity=opacity;
      }
      // is it a PolyStyle ?
      var polystyles=styles[i].getElementsByTagName("PolyStyle");
      if (polystyles.length > 0) {
        var fill=parseInt(GXml.value(polystyles[0].getElementsByTagName("fill")[0]));
        var outline=parseInt(GXml.value(polystyles[0].getElementsByTagName("outline")[0]));
        var color=EGeoXml.value(polystyles[0].getElementsByTagName("color")[0]);

        if (polystyles[0].getElementsByTagName("fill").length===0) {fill=1;}
        if (polystyles[0].getElementsByTagName("outline").length===0) {outline=1;}
        var aa=color.substr(0,2);
        var bb=color.substr(2,2);
        var gg=color.substr(4,2);
        var rr=color.substr(6,2);
        color="#" + rr + gg + bb;

        var opacity=parseInt(aa,16)/256;
        if (!that.styles["#"+styleID]) {
          that.styles["#"+styleID]={};
        }
        that.styles["#"+styleID].fillcolor=color;
        that.styles["#"+styleID].fillopacity=opacity;
        if (!fill) { that.styles["#"+styleID].fillopacity=0; }
        if (!outline) { that.styles["#"+styleID].opacity=0; } 
      }
    }

    // Read through the Placemarks
    var placemarks=xmlDoc.documentElement.getElementsByTagName("Placemark");
    for (var i=0; i < placemarks.length; i++) {
      var name=EGeoXml.value(placemarks[i].getElementsByTagName("name")[0]);
      var desc=EGeoXml.value(placemarks[i].getElementsByTagName("description")[0]);
      if (desc==="") {
        var desc=EGeoXml.value(placemarks[i].getElementsByTagName("text")[0]);
        desc=desc.replace(/\$\[name\]/,name);
        desc=desc.replace(/\$\[geDirections\]/,"");
      }
      if (desc.match(/^http:\/\//i)) {
        desc='<a href="' + desc + '">' + desc + '</a>';
      }
      if (desc.match(/^https:\/\//i)) {
        desc='<a href="' + desc + '">' + desc + '</a>';
      }
      var style=EGeoXml.value(placemarks[i].getElementsByTagName("styleUrl")[0]);
      var coords=GXml.value(placemarks[i].getElementsByTagName("coordinates")[0]);
      coords=coords.replace(/\s+/g," "); // tidy the whitespace
      coords=coords.replace(/^ /,"");    // remove possible leading whitespace
      coords=coords.replace(/ $/,"");    // remove possible trailing whitespace
      coords=coords.replace(/, /,",");   // tidy the commas
      var path=coords.split(" ");

      // Is this a polyline/polygon?
      if (path.length > 1) {
        // Build the list of points
        var points=[];
        var pbounds=new GLatLngBounds();
        for (var p=0; p<path.length; p++) {
          var bits=path[p].split(",");
          var point=new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));
          points.push(point);
          that.bounds.extend(point);
          pbounds.extend(point);
        }
        var linestring=placemarks[i].getElementsByTagName("LineString");
        if (linestring.length) {
          // it's a polyline grab the info from the style
          if (!!that.styles[style]) {
            var width=that.styles[style].width; 
            var color=that.styles[style].color; 
            var opacity=that.styles[style].opacity; 
          } else {
            var width=5;
            var color="#0000ff";
            var opacity=0.45;
          }
          // Does the user have their own createmarker function?
          if (!!that.opts.createpolyline) {
            that.opts.createpolyline(points,color,width,opacity,pbounds,name,desc);
          } else {
            that.createPolyline(points,color,width,opacity,pbounds,name,desc);
          }
        }

        var polygons=placemarks[i].getElementsByTagName("Polygon");
        if (polygons.length) {
          // it's a polygon grab the info from the style
          if (!!that.styles[style]) {
            var width=that.styles[style].width; 
            var color=that.styles[style].color; 
            var opacity=that.styles[style].opacity; 
            var fillopacity=that.styles[style].fillopacity; 
            var fillcolor=that.styles[style].fillcolor; 
          } else {
            var width=5;
            var color="#0000ff";
            var opacity=0.45;
            var fillopacity=0.25;
            var fillcolor="#0055ff";
          }
          // Does the user have their own createmarker function?
          if (!!that.opts.createpolygon) {
            that.opts.createpolygon(points,color,width,opacity,fillcolor,fillopacity,pbounds,name,desc);
          } else {
            that.createPolygon(points,color,width,opacity,fillcolor,fillopacity,pbounds,name,desc);
          }
        }
      } else {
        // It's not a poly, so I guess it must be a marker
        var bits=path[0].split(",");
        var point=new GLatLng(parseFloat(bits[1]),parseFloat(bits[0]));
        that.bounds.extend(point);
        // Does the user have their own createmarker function?
        if (!!that.opts.createmarker) {
          that.opts.createmarker(point, name, desc, style);
        } else {
          that.createMarker(point, name, desc, style);
        }
      }
    }
    
    // Scan through the Ground Overlays
    var grounds=xmlDoc.documentElement.getElementsByTagName("GroundOverlay");
    for (var i=0; i < grounds.length; i++) {
      var url=EGeoXml.value(grounds[i].getElementsByTagName("href")[0]);
      var north=parseFloat(GXml.value(grounds[i].getElementsByTagName("north")[0]));
      var south=parseFloat(GXml.value(grounds[i].getElementsByTagName("south")[0]));
      var east=parseFloat(GXml.value(grounds[i].getElementsByTagName("east")[0]));
      var west=parseFloat(GXml.value(grounds[i].getElementsByTagName("west")[0]));
      var sw=new GLatLng(south,west);
      var ne=new GLatLng(north,east);                           
      var ground=new GGroundOverlay(url, new GLatLngBounds(sw,ne));
      that.bounds.extend(sw); 
      that.bounds.extend(ne); 
      that.groundoverlays.push(ground);
      that.map.addOverlay(ground);
    }

    // Is this the last file to be processed?
    that.progress--;
    if (that.progress===0) {
      // Shall we zoom to the bounds?
      if (!that.opts.nozoom) {
        that.map.setZoom(that.map.getBoundsZoomLevel(that.bounds));
        that.map.setCenter(that.bounds.getCenter());
      }
      // Shall we display the sidebar?
      if (that.opts.sortbyname) {
        that.side_bar_list.sort();
      }
      if (that.opts.sidebarid) {
        for (var i=0; i<that.side_bar_list.length; i++) {
          var bits=that.side_bar_list[i].split("$$$",4);
          that.side_bar_html += that.sidebarfn(that.myvar,bits[0],bits[1],bits[2],bits[3]); 
        }
        document.getElementById(that.opts.sidebarid).innerHTML+='<fieldset><legend>Lokationer</legend>'+that.side_bar_html+'</fieldset>';
      }
      if (that.opts.dropboxid) {
        for (var i=0; i<that.side_bar_list.length; i++) {
          var bits=that.side_bar_list[i].split("$$$",4);
          if (bits[1] == "marker") {
            that.side_bar_html += that.dropboxfn(that.myvar,bits[0],bits[1],bits[2],bits[3]); 
          }
        }
        document.getElementById(that.opts.dropboxid).innerHTML='<select onChange="var I=this.value;if(I>-1){GEvent.trigger('+that.myvar+'.gmarkers[I],\'click\'); }"><option selected> - Select a location - </option>'+that.side_bar_html+'</select>';
      }
      GEvent.trigger(that,"parsed");
    }
};

EGeoXml.prototype.hide=function() {
  for (var i=0; i<this.gmarkers.length; i++) {
    this.gmarkers[i].hide();
  }
  for (var i=0; i<this.gpolylines.length; i++) {
    this.gpolylines[i].hide();
  }
  for (var i=0; i<this.gpolygons.length; i++) {
    this.gpolygons[i].hide();
  }
  for (var i=0; i<this.groundoverlays.length; i++) {
    this.groundoverlays[i].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 i=0; i<this.gmarkers.length; i++) {
    this.gmarkers[i].show();
  }
  for (var i=0; i<this.gpolylines.length; i++) {
    this.gpolylines[i].show();
  }
  for (var i=0; i<this.gpolygons.length; i++) {
    this.gpolygons[i].show();
  }
  for (var i=0; i<this.groundoverlays.length; i++) {
    this.groundoverlays[i].show();
  }
  if (this.opts.sidebarid) {
    document.getElementById(this.opts.sidebarid).style.display="";
  }
  if (this.opts.dropboxid) {
    document.getElementById(this.opts.dropboxid).style.display="";
  }
};

function HtmlControl(_1,_2){this.html=_1;this.isVisible=true;this.isPrintable=false;this.isSelectable=false;if(_2){this.isVisible=(_2.visible===false)?false:true;this.isPrintable=(_2.printable===true)?true:false;this.isSelectable=(_2.selectable===true)?true:false;}}HtmlControl.prototype=new GControl();HtmlControl.prototype.initialize=function(_3){this.div=document.createElement("div");this.div.innerHTML=this.html;this.setVisible(this.isVisible);_3.getContainer().appendChild(this.div);return this.div;};HtmlControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(7,7));};HtmlControl.prototype.selectable=function(){return this.isSelectable;};HtmlControl.prototype.printable=function(){return this.isPrintable;};HtmlControl.prototype.setVisible=function(_4){this.div.style.display=_4?"":"none";this.isVisible=_4;};HtmlControl.prototype.visible=function(){return this.isVisible;};
