var map = null;
var geocoder = null;

$(document).ready(function() {
	autoSetForm(destinationVar, departureVar);

	if (GBrowserIsCompatible()) {
		var mapOptions = {
           	googleBarOptions : { style : "new" }
        }
     	map = new GMap2(document.getElementById("map"), mapOptions);
		map.addControl(new GSmallMapControl());
		map.setCenter(new GLatLng(42, 10), 4);

		var ftcIcon = new GIcon(G_DEFAULT_ICON);
		ftcIcon.image = dirString + "images/pin-clear.png";
		ftcIcon.shadow = dirString + "images/pin-shadow.png";
		ftcIcon.shadowSize = new GSize(20, 26);
		ftcIcon.iconSize = new GSize(18, 22);
        ftcIcon.iconAnchor = new GPoint(4, 20);
        ftcIcon.infoWindowAnchor = new GPoint(18, 20);
		markerOptions = { icon:ftcIcon };
		
		geocoder = new GClientGeocoder();

		if (geocoder) {
			geocoder.getLatLng(destinationCityString + ", " + destinationCountryString, function(point) {
				if (!point) {
					alert(address + " not found");
				} else {
					map.setCenter(point,8);
					var marker = new GMarker(point, markerOptions);
					map.addOverlay(marker);
					GEvent.addListener(marker, "click", function() {
						window.location = "http://book.flythomascook.com/skylights/cgi-bin/skylights.cgi?module=CP&page=FLIGHTS_" + destinationCityString.toUpperCase();
					});
				}
			});
		}
		
	}									
});
