/*--------------------------------------------------------------------
JAVASCRIPT - google maps, Praxis

Version: 	2.0 - 2008
author: 	Burocratik (alexandre gomes)
email: 		alex@burocratik.com
website: 	http://www.burocratik.com
-----------------------------------------------------------------------*/
/* =WINDOW.onload
-----------------------------------------------------------------------*/
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != "function") {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

/* =GOOGLE MAPS
-----------------------------------------------------------------------*/
function iniciarMapa() {
	if (GBrowserIsCompatible()) {
   	var map = new GMap2(document.getElementById("flashContent")); //usar div. Da Erro em IE se usar um p ou outro elemento
    //posicao e tipo dos controls
    var topRight1 = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,60));
	var topRight2 = new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(20,60));
    map.addControl(new GLargeMapControl3D(), topRight1);
    map.addControl(new GMenuMapTypeControl(true), topRight2);

    map.setCenter(new GLatLng(39.756552,-8.827364), 10);
	 	map.addMapType(G_PHYSICAL_MAP);
	 	map.setMapType(G_PHYSICAL_MAP);
		
// Criar marker icon
		var icon = new GIcon();
		icon.image = "imgs/gmap-icon.png";
		icon.shadow = "imgs/gmap-icon-sombra.png";
		icon.iconSize = new GSize(71, 68); //Pixel size(width,height)
		icon.shadowSize = new GSize(104, 70); //Pixel size(width,height)
		icon.iconAnchor = new GPoint(30, 68); //Top left corner of the icon image at which this icon is anchored to the map.
	  	icon.infoWindowAnchor = new GPoint(35, 5); //Pixel coordinate relative to the top left corner of the icon image at which the INFO WINDOW is anchored to this icon (tipo iconAnchor). APAGAR se nao usar Info Windows

// Funcao Criar Marker com Info Windows
		function fMarker(point,icon,html){
			var marker = new GMarker(point,icon);
			GEvent.addListener(marker, "click", function() {
	   		 marker.openInfoWindowHtml(html, {maxWidth:250}); //Tamanho minimo e' de 250px
  			});	
 			return marker;
		}

///////LOCALIZACAO
		var point = new GLatLng(39.756552,-8.827364);
		var html = "<h4>GRUPO LENA</h4><p>Estrada da Esta&ccedil;&atilde;o, 9 - 11<br>3&ordm; andar Marrazes<br>2415-409 LEIRIA<br>Portugal<br><br></p><!--<p><strong>GPS:</strong> +39&deg; 45' 23.59'', -8&deg; 49' 38.51''</p>--><p>&nbsp;</p>";
		var marker = fMarker(point,icon,html);
		map.addOverlay(marker);
	}
}

/* =window.onunload
-----------------------------------------------------------------------*/
window.onunload = GUnload;


/* =Preparar Eventos
-----------------------------------------------------------------------*/
addLoadEvent(iniciarMapa);
