// JavaScript Document
function Overlay(map, buttonId, properties) {
	this.visible = false;
	this.map = map;
	this.buttonId = buttonId;
	if (properties == null) {
		this.properties = {};
	} else {
    	this.properties = properties;
	}
	if (typeof(this.properties.zIndexProcess) == 'undefined')
	{
		this.properties.zIndexProcess = this.getMarkerZIndex;
	}
	this.overlays = new Array();
}
Overlay.prototype.show = function()
{
	if(!this.visible)
	{
	this.loadOverlays();
	var element = document.getElementById(this.buttonId);
	element.style.backgroundColor='#ffff00';
	this.visible = true;
	}
}
Overlay.prototype.hide = function()
{
	//add display code here
	if(this.visible)
	{
	for (var i = 0; i < this.overlays.length; i++) {
	        this.map.removeOverlay(this.overlays[i]);
	    }
	this.overlays = new Array();
	var element = document.getElementById(this.buttonId);
	element.style.backgroundColor='#cccccc';
	this.visible = false;
	}
}
Overlay.prototype.toggle = function()
{
	if (this.visible) 
	{
		this.hide();	
	}
	else
	{
		this.show();
	}
}
Overlay.prototype.addGGeoXML = function(URL)
{
this.addOverlay(new GGeoXml(URL));	
}

Overlay.prototype.addOverlay = function(overlay)
{
	this.map.addOverlay(overlay);
	this.overlays[this.overlays.length] = overlay;
}

Overlay.prototype.addMarker = function (latitude, longitude, title, theHTML)
{
		var LatLong = new GLatLng(latitude,longitude);
		var marker = new GMarker(LatLong, this.properties);
		var tooltip = new Tooltip(marker,title,1);
		marker.tooltip = tooltip;
		this.map.addOverlay(tooltip);
		GEvent.addListener(marker,'mouseover',function(){
			this.tooltip.show();
		});
		GEvent.addListener(marker,'mouseout',function(){
			this.tooltip.hide();
		});
		GEvent.addListener(marker,"click",function()
			{
				map.openInfoWindow(LatLong, (theHTML));
			}
		);
		this.addOverlay(marker);
}

Overlay.prototype.getMarkerZIndex = function(marker,b) {
	return 1;
	}

Overlay.prototype.loadOverlays = function()
{
	alert('override this method');
}
