﻿// JavaScript Document

var iconBlue = new GIcon(); 
iconBlue.image = '../i/parking.png';
iconBlue.shadow = '';
iconBlue.iconSize = new GSize(32, 37);
iconBlue.shadowSize = new GSize(22, 20);
iconBlue.iconAnchor = new GPoint(6, 20);
iconBlue.infoWindowAnchor = new GPoint(5, 1);

var iconRed = new GIcon(); 
iconRed.image = '../i/theater.png';
iconRed.shadow = '';
iconRed.iconSize = new GSize(32, 37);
iconRed.shadowSize = new GSize(22, 20);
iconRed.iconAnchor = new GPoint(6, 20);
iconRed.infoWindowAnchor = new GPoint(5, 1);

var customIcons = [];
customIcons["restaurant"] = iconBlue;
customIcons["bar"] = iconRed;

function load() {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.setCenter(new GLatLng(-30.0283,-51.21515), 16);
	
	var name = 'Casa de Teatro de Porto Alegre';
	var address = 'Rua Garibaldi, 853, Porto Alegre - RS';
	var type = 'bar';
	var point = new GLatLng(-30.02799,-51.21547);
	var marker = createMarker(point, name, address, type);
	map.addOverlay(marker);
	
	
	var name = 'Estacionamento Conveniado 1';
	var address = 'Rua Alberto Bins, 128, Independência, Porto Alegre - RS';
	var type = 'restaurant';
	var point = new GLatLng(-30.0276,-51.2163);
	var marker = createMarker(point, name, address, type);
	map.addOverlay(marker);

	var name = 'Estacionamento Conveniado 1';
	var address = 'Av, Independência, 766, Independência, Porto Alegre - RS';
	var type = 'restaurant';
	var point = new GLatLng(-30.0293,-51.2135);
	var marker = createMarker(point, name, address, type);
	map.addOverlay(marker);
  }
}


function createMarker(point, name, address, type) {
  var marker = new GMarker(point, customIcons[type]);
  var html = "<b>" + name + "</b> <br/>" + address;
  GEvent.addListener(marker, 'click', function() {
	marker.openInfoWindowHtml(html);
  });
  return marker;
}
