//--------------------------------------------------------------------------------------------------
function customPanZoomControl(controlPosition)
{
	this.clsControl = "gmap_customPanZoomControl";
	this.clsCenter = "center";
	this.clsPanUp = "panUp";
	this.clsPanDown = "panDown";
	this.clsPanLeft = "panLeft";
	this.clsPanRight = "panRight";
	this.clsZoomIn = "zoomIn";
	this.clsZoomOut = "zoomOut";
	
	if (!controlPosition)
	{
		this.controlPosition = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(8, 8));
	}
	else
	{
		this.controlPosition = controlPosition;
	}
}

// Default constructor for GControl
customPanZoomControl.prototype = new GControl(false, false);

// Default location for the control
customPanZoomControl.prototype.getDefaultPosition = function()
{
	return this.controlPosition;
};

// Initialize customPanZoomControl
customPanZoomControl.prototype.initialize = function(mapReference)
{
	
	//--- Create control element ------------------------------------------------------------------
	var controlContainer = document.createElement("div");
	controlContainer.className = this.clsControl;
	//---------------------------------------------------------------------------------------------
	
	//--- Create button elements ------------------------------------------------------------------
	var center = document.createElement("div");
	center.className = this.clsCenter;

	var panDown = document.createElement("div");
	panDown.className = this.clsPanDown;
	
	var panLeft = document.createElement("div");
	panLeft.className = this.clsPanLeft;
	
	var panRight = document.createElement("div");
	panRight.className = this.clsPanRight;
	
	var panUp = document.createElement("div");
	panUp.className = this.clsPanUp;
	
	var zoomIn = document.createElement("div");
	zoomIn.className = this.clsZoomIn;
	
	var zoomOut = document.createElement("div");
	zoomOut.className = this.clsZoomOut;

	//---------------------------------------------------------------------------------------------
	
	//--- Click handlers for the buttons ----------------------------------------------------------
	GEvent.addDomListener(panUp, "click", function()
	{
		mapReference.panDirection(0, 1)
	});
	
	GEvent.addDomListener(panLeft, "click", function()
	{
		mapReference.panDirection(1, 0);
	});
	
	GEvent.addDomListener(center, "click", function()
	{
		mapReference.setCenter(new GLatLng(latitude, longitude), zoomLevel);
	});
	
	GEvent.addDomListener(panRight, "click", function()
	{
		mapReference.panDirection(-1, 0);
	});
	
	GEvent.addDomListener(panDown, "click", function()
	{
		mapReference.panDirection(0, -1);
	});
	
	GEvent.addDomListener(zoomIn, "click", function()
	{
		mapReference.zoomIn();
	});
	
	GEvent.addDomListener(zoomOut, "click", function()
	{ 
		mapReference.zoomOut();
	});
	//---------------------------------------------------------------------------------------------
	
	
	//--- Append button controls to the controlContainer ------------------------------------------
	controlContainer.appendChild(panUp);
	controlContainer.appendChild(panLeft);
	controlContainer.appendChild(center);
	controlContainer.appendChild(panRight);
	controlContainer.appendChild(panDown);
	controlContainer.appendChild(zoomIn);
	controlContainer.appendChild(zoomOut);
	//---------------------------------------------------------------------------------------------
	
	
	//--- Append the controlContainer to the map --------------------------------------------------
	mapReference.getContainer().appendChild(controlContainer);
	//---------------------------------------------------------------------------------------------
	
	return controlContainer;
}
//-------------------------------------------------------------------------------------------------


//-------------------------------------------------------------------------------------------------
function customMapTypeButton(text, mapType, controlPosition)
{
	this.className = "gmap_customMapTypeButton";
	this.text = text;
	this.mapType = mapType;
	
	if (!controlPosition)
	{
		this.controlPosition = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(8, 8));
	}
	else
	{
		this.controlPosition = controlPosition;
	}
}

// Default constructor for GControl 
customMapTypeButton.prototype = new GControl(false, false);

// Default location for the control
customMapTypeButton.prototype.getDefaultPosition = function()
{
	return this.controlPosition;
};

customMapTypeButton.prototype.initialize = function(mapReference)
{
	//--- Get mapType for this button -------------------------------------------------------------
	var mapType = this.mapType;
	
	//--- Create DOM element for this button ------------------------------------------------------
	var controlContainer = document.createElement("div");
	controlContainer.className = this.className;
	controlContainer.innerHTML = this.text;
	
	// Add control to the map
	mapReference.getContainer().appendChild(controlContainer);
	
	//--- Click handler for this button -----------------------------------------------------------
	GEvent.addDomListener(controlContainer, "click", function()
	{
		// Normal map type.
		mapReference.setMapType(mapType);
	});
	//---------------------------------------------------------------------------------------------
	
	return controlContainer;
}
//--------------------------------------------------------------------------------------------------
