var pos;
function initialize() {
	var map = new GMap2(document.getElementById("map"));
	//pos = new GLatLng(41.37873658863031, -8.506186687154781);
	//p = new GLatLng(41.380431,-8.503418);
	
	pos = new GLatLng(41.378717, -8.505982);
	p = new GLatLng(41.378717, -8.505982);
	map.setCenter(p, 17);
	map.enableScrollWheelZoom();
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new CenterButton());
	var marker = new GMarker(pos);
	map.addOverlay(marker);
	marker.setImage('/sites/all/themes/desifilme/gicon.png');
	var html = "Desifilme,<br/>Centro de Picagem e Desenho<br/>";
	html += '<p>Rua D. Afonso Henriques<br />Loteamento Industrial de Pedras<br />Pavilhão nº.10<br />4760-480 Esmeriz</p>';
	html += '<a href="http://maps.google.com/maps?saddr=&daddr=' + pos.toUrlValue() + '" target ="_blank">Como Chegar</a>';
	marker.openInfoWindowHtml(html);
	GEvent.addListener(marker, "click", function() {
		marker.openInfoWindowHtml(html);
	});

}

function CenterButton() {
}


CenterButton.prototype = new GControl();

CenterButton.prototype.initialize = function(map) {
	var button = document.createElement("div");
	button.appendChild(document.createTextNode("Centrar"));
	this.Style_(button);
	GEvent.addDomListener(button, "click", function() {
		map.setCenter(p);
	});
	map.getContainer().appendChild(button);
	return button;
}

CenterButton.prototype.Style_ = function(button) {
	button.style.color = "red";
	button.style.backgroundColor = "#ccc";
	button.style.cursor = "pointer";
	button.style.padding = "5px";
	button.style.marginBottom = "5px";
}

CenterButton.prototype.getDefaultPosition = function() {
	return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(20, 10));
}


google.setOnLoadCallback(initialize);
