var map;

var icons = [];
icons['train'] = new GIcon({image:'http://google-maps-icons.googlecode.com/files/train.png',size:new GSize(32,37),iconAnchor:new GPoint(16,35)});
icons['airport'] = new GIcon({image:'http://google-maps-icons.googlecode.com/files/airport.png',size:new GSize(32,37),iconAnchor:new GPoint(16,35)});
icons['hotel'] = new GIcon({image:'http://google-maps-icons.googlecode.com/files/hotel.png',size:new GSize(32,37),iconAnchor:new GPoint(16,35)});
icons['culture'] = new GIcon({image:'http://google-maps-icons.googlecode.com/files/theater.png',size:new GSize(32,37),iconAnchor:new GPoint(16,35)});

var points = [];
points['center'] = new GLatLng(50.098834,14.364280);
points['hotelChristie'] = new GLatLng(50.081613,14.421283);
points['municipalHouse'] = new GLatLng(50.087533,14.427967);
points['ruzyne'] = new GLatLng(50.101313,14.256134);
points['main'] = new GLatLng(50.083568,14.435970);
points['holesovice'] = new GLatLng(50.110230,14.439768);

var marks = [];
marks['main'] = new GMarker(points['main'],{title:'Main Railway station',icon:icons['train']});
marks['holesovice'] = new GMarker(points['holesovice'],{title:'Holešovice Railway station',icon:icons['train']});
marks['ruzyne'] = new GMarker(points['ruzyne'],{title:'Ruzyně Airport',icon:icons['airport']});
marks['hotelChristie'] = new GMarker(points['hotelChristie'],{title:'Hotel Christie',icon:icons['hotel']});
marks['municipalHouse'] = new GMarker(points['municipalHouse'],{title:'Municipal House',icon:icons['culture']});

var paths = [];
paths['HMH'] = {overlay: false, path: new GPolyline.fromEncoded({color: "#0000ff", weight: 5, opacity: 0.5, points: 'cqtpHis_wA_@AFwA?yCaCRaBd@g@p@mJqO}@gB_A_C}GmM_@eB@\UdB', levels: "PB@EABFC@ABE@P", zoomFactor: 32, numLevels: 4})}; 
paths['AH'] = {overlay: false, path: new GPolyline([points['ruzyne'],points['hotelChristie']],'#cf0000', 5)};

function initialize() {
  if (GBrowserIsCompatible()) {
  	// creates and sets up the map
    map = new GMap2(document.getElementById("map"));
    map.setUIToDefault();
    map.enableScrollWheelZoom();

		// sets marks into the map
		for (key in marks) {
			map.addOverlay(marks[key]);
		}

		// default position
		resetMap();
  } else {
		// .. browser is not supported
	}
}

function resetMap() {
	map.setCenter(points['center'], 11);
}

function moveTo(point) {
	map.panTo(points[point]);
}

function togglePath(path) {
	if (paths[path].overlay) {
		if (paths[path].path.isHidden()) {
			paths[path].path.show();
		} else {
			paths[path].path.hide();
		}
	} else {
		paths[path].overlay = true;
		map.addOverlay(paths[path].path);
	}
}

