// A TextualZoomControl is a GControl that displays textual "Zoom In"
// and "Zoom Out" buttons (as opposed to the iconic buttons used in
// Google Maps).
function TextualZoomControl() {
}

TextualZoomControl.prototype = new GControl();

TextualZoomControl.prototype.initialize = function(map) {
	var container = document.createElement("div");
	
	var toUpDiv = document.createElement("div");
	this.setButtonStyle_(toUpDiv);
	container.appendChild(toUpDiv);
	toUpDiv.innerHTML = '<img src="/files/ccl/gmap/up.png" alt="" />';
	toUpDiv.style.top = '10px'; toUpDiv.style.left = '25px';
	GEvent.addDomListener(toUpDiv, "click", function() {
		map.panDirection(0, 1);
	});
	
	var toLeftDiv = document.createElement("div");
	this.setButtonStyle_(toLeftDiv);
	container.appendChild(toLeftDiv);
	toLeftDiv.innerHTML = '<img src="/files/ccl/gmap/left.png" alt="" />';
	toLeftDiv.style.top = '30px'; toLeftDiv.style.left = '10px';
	GEvent.addDomListener(toLeftDiv, "click", function() {
		map.panDirection(1, 0);
	});
	
	var toRightDiv = document.createElement("div");
	this.setButtonStyle_(toRightDiv);
	container.appendChild(toRightDiv);
	toRightDiv.innerHTML = '<img src="/files/ccl/gmap/right.png" alt="" />';
	toRightDiv.style.top = '30px'; toRightDiv.style.left = '40px';
	GEvent.addDomListener(toRightDiv, "click", function() {
		map.panDirection(-1, 0);
	});
	
	var toDownDiv = document.createElement("div");
	this.setButtonStyle_(toDownDiv);
	container.appendChild(toDownDiv);
	toDownDiv.innerHTML = '<img src="/files/ccl/gmap/down.png" alt="" />';
	toDownDiv.style.top = '50px'; toDownDiv.style.left = '25px';
	GEvent.addDomListener(toDownDiv, "click", function() {
		map.panDirection(0, -1);
	});
	
	var zoomInDiv = document.createElement("div");
	this.setButtonStyle_(zoomInDiv);
	container.appendChild(zoomInDiv);
	zoomInDiv.innerHTML = '<img src="/files/ccl/gmap/plus.png" alt="" />';
	zoomInDiv.style.top = '75px'; zoomInDiv.style.left = '25px';
	GEvent.addDomListener(zoomInDiv, "click", function() {
		map.zoomIn();
	});

	var zoomOutDiv = document.createElement("div");
	this.setButtonStyle_(zoomOutDiv);
	container.appendChild(zoomOutDiv);
	zoomOutDiv.innerHTML = '<img src="/files/ccl/gmap/minus.png" alt="" />';
	zoomOutDiv.style.top = '95px'; zoomOutDiv.style.left = '25px';
	GEvent.addDomListener(zoomOutDiv, "click", function() {
		map.zoomOut();
	});

	map.getContainer().appendChild(container);
	return container;
}

// By default, the control will appear in the top left corner of the
// map with 7 pixels of padding.
TextualZoomControl.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(0, 0));
}

// Sets the proper CSS for the given button element.
TextualZoomControl.prototype.setButtonStyle_ = function(button) {
	button.className = 'gmap_button';
}

function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new TextualZoomControl());
		map.setCenter(new GLatLng(60.1631, 24.9413), 13);
		
		var icon = new GIcon();
		icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
		icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
		icon.iconSize = new GSize(12, 20);
		icon.shadowSize = new GSize(22, 20);
		icon.iconAnchor = new GPoint(6, 20);
		//icon.infoWindowAnchor = new GPoint(5, 1);
		// var point = new GLatLng(60.1631, 24.9413);
		var point = new GLatLng(60.15870, 24.93326);
		map.addOverlay(new GMarker(point, icon));
	}
}