$(document).ready(function() {
	initialize_trucks();
});

function initialize_trucks() {
	if ( map_options.crew_truck_icon == '' )
		return;	// Don't display trucks.

	var trucks = viewer_data.trucks.length;
	for ( var i = 0; i < trucks; i++ ) {
		var truck = viewer_data.trucks[i];
		var description =
			'<div style="padding-top: 4px;">Type: <strong>' + truck.Type + '</strong></div>' +
			'<div style="padding-top: 4px;">Speed: <strong>' + truck.Speed + '</strong></div>' +
			'<div style="padding-top: 4px;">Heading: <strong>' + truck.Heading + '</strong></div>' +
			'<div style="padding-top: 4px;">Event Time: <strong>' + truck.EventTime + '</strong></div>' +
			'<div style="padding-top: 4px;">Location: <strong>' + truck.Location + '</strong></div>';
		add_truck(truck.Lat, truck.Lon, truck.VehicleName, description);
	}
}

// Add a truck to the map.
function add_truck(lat, lon, title, description) {
	var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(lat, lon));
	shape.SetCustomIcon('<img src="' + map_options.crew_truck_icon + '" />');
	shape.SetTitle(title);
	shape.SetDescription(description);
	map.AddShape(shape);
	shape_ids[shape_ids.length] = shape.GetID();
}

