var lastpinnumber = -1;

function newIcon(type) {
	var icon = new google.maps.Icon();
	if (type == 'both') {
		icon.image = '/img/pin-red-blue.png';
	} else if (type == 'pro') {
		icon.image = '/img/pin-blue.png';
	} else if (type == 'it') {
		icon.image = '/img/pin-red.png';
	} else {
		icon.image = '/img/pin-blue.png';
	}
	icon.iconSize = new google.maps.Size(24, 25);
	icon.iconAnchor = new google.maps.Point(5, 24);
	icon.infoWindowAnchor = new google.maps.Point(5, 1);
	return icon;
}

function addPin(lat, lng, title, info, type) {
	var pin = new google.maps.Marker(new google.maps.LatLng(lat, lng), { icon: newIcon(type), title: title });
	gmarkers[j] = pin;  j++;
	google.maps.Event.addListener(pin, 'click',
		function() {
			pin.openInfoWindowHtml(info);
		}
	);
	map.addOverlay(pin);
}

function showPins() {
	var bounds = new google.maps.LatLngBounds;
	for (var i=0; i<pins.length; i++) {
		addPin(pins[i].lat, pins[i].lng, pins[i].org, pins[i].vcard, pins[i].type);
		bounds.extend(new google.maps.LatLng(pins[i].lat, pins[i].lng));
	}
	map.setCenter(bounds.getCenter());
	map.setZoom(map.getBoundsZoomLevel(bounds));
}
function highlightLoc(pinnumber) {
	if (pinnumber != lastpinnumber) {
		GEvent.trigger(gmarkers[pinnumber], "click");
		lastpinnumber = pinnumber;
	}
}
