function Callout()
{
	this.callout = false;
	this.calloutContent = false;
	this.mapSize = applicationObject.mapObject.map.getSize();
	this.mapWidth = this.mapSize.width;
	this.mapHeight = this.mapSize.height;
	this.infoWindowContent = '';
	this.pixelPoint = new GPoint(0, 0);

	this.createCallout = function()
	{
		this.callout = document.createElement("div");
		this.callout.id = "callout";
		this.callout.className = "marker_container_small";
		this.callout.style.position = "absolute";
		this.callout.style.zIndex = "100";
		this.callout.style.left = "-1000px";
		this.callout.style.top = "-1000px";
		this.callout.style.cursor = "pointer";
		this.callout.style.cursor = "hand";
		this.callout.innerHTML = '<div class="marker_clicked_top png_bg"></div><div class="marker_clicked_content png_bg"><p class="nomargin ml7 mr7"><span id="callout_content" class="bold">&nbsp;</span></p></div><div class="marker_tip png_bg"></div>';
		
		document.body.appendChild(this.callout);
		this.calloutContent = $('#callout_content').get(0);
	}

	this.showCallout = function(lat, lng, content, infoWindow)
	{
		var centerPixel = applicationObject.mapObject.map.fromLatLngToContainerPixel(applicationObject.mapObject.map.getCenter());
		this.pixelPoint = applicationObject.mapObject.map.fromLatLngToContainerPixel(new GLatLng(lat, lng));

		if(this.pixelPoint)
		{
			fromCenter = this.subGPoints(this.pixelPoint, centerPixel);

			container_x = fromCenter.x + (this.mapWidth / 2);
			container_y = fromCenter.y + (this.mapHeight / 2);
			
			this.calloutContent.innerHTML = content;
			var offsetLeft = $('#map').position().left;
			var offsetTop = $('#map').position().top;
			var calloutHeight = 0;
			if(jQuery.browser.msie)
			{
				if(jQuery.browser.msie && jQuery.browser.version > 6)
				{
					container_x = container_x + 1;
					calloutHeight = ($('#callout').innerHeight() - 6);
				}
				else
				{
					calloutHeight = ($('#callout').innerHeight() - 4);
				}
			}
			else
			{
				calloutHeight = ($('#callout').innerHeight() - 5);
			}

			this.callout.style.left = (offsetLeft + container_x + 12) + "px";
			this.callout.style.top = ((offsetTop + container_y) - calloutHeight)+ "px";

			this.infoWindowContent = infoWindow;
			
			var self = this;
			$("#callout").unbind("click");
			$("#callout").click(function(event)
			{
				// Take care of zoom
				var zoom = applicationObject.mapObject.map.getZoom();
				if(zoom < 16)
				{ 
					zoom = 16;
					applicationObject.mapObject.setCenter(lat, lng, zoom);
					applicationObject.mapObject.mapControlsObject.setZoomSlider(zoom);
				}
				self.pixelPoint = applicationObject.mapObject.map.fromLatLngToContainerPixel(new GLatLng(lat, lng));
				self.hideCallout();
				applicationObject.mapObject.markerManagerObject.infoWindow.setClickedPoint(lat, lng); // remember for zoom tool
				applicationObject.mapObject.markerManagerObject.infoWindow.showInfowindow(self.pixelPoint.x, self.pixelPoint.y, self.infoWindowContent);
			});
		}
	}
	
	this.hideCallout = function()
	{
		this.callout.style.left = "-1000px";
		this.callout.style.top = "-1000px";
	}

	this.subGPoints = function (a,b)
	{
		return new GPoint(a.x-b.x, a.y-b.y);
	}
}


