﻿// JScript File
var map;
var icon;
var geocoder;

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(40.5, -105), 9);

		geocoder = new GClientGeocoder();
	}
}

function createMarker(latitude, longitude, description, icon) {
	if (icon == 1) {
		//Create Marker Icon
		icon = new GIcon();
		icon.image = "/images/markers/energystar.png";
		icon.shadow = "/images/markers/shadow.png";
		icon.iconSize = new GSize(22, 33);
		icon.shadowSize = new GSize(37, 34);
		icon.iconAnchor = new GPoint(11, 33);
		icon.infoWindowAnchor = new GPoint(10, 1);
	}
	else if (icon == 2) {
		//Create Marker Icon
		icon = new GIcon();
		icon.image = "/images/markers/energystar+.png";
		icon.shadow = "/images/markers/shadow.png";
		icon.iconSize = new GSize(22, 33);
		icon.shadowSize = new GSize(37, 34);
		icon.iconAnchor = new GPoint(11, 33);
		icon.infoWindowAnchor = new GPoint(10, 1);
	}

	var point = new GLatLng(latitude, longitude);
	var marker = new GMarker(point, icon);
	if (marker != null) {
		GEvent.addListener(marker, "mouseover", function() {
			variable = true;
			setTimeout(function() {
				if (variable)
					marker.openInfoWindowHtml(description);
			}, 2000);
		});
		GEvent.addListener(marker, "mouseout", function() {
			variable = false;
		});
		GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(description);
		});
		map.addOverlay(marker);
	}
}