
// http://www.ces.iisc.ernet.in/grass/grass54/manual/projections.html
Proj4js.defs["EPSG:54008"] = "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
Proj4js.defs["EPSG:54009"] = "+proj=moll +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";
Proj4js.defs["EPSG:3410"] = "+proj=cea +lon_0=0 +x_0=0 +y_0=0 +lat_ts=30 +ellps=WGS84 +datum=WGS84 +units=m +no_defs";

			 
var map;
var kmlFile = "../data/kml/infant_mortality_2005_choropleth.kml";
			  
function init(){
	createMap("EPSG:54009");
}
		 
function setProjection(radio) {
	createMap(radio.value);
}

function createMap(epsg) {

	// Map options
	var options = {
    	projection: new OpenLayers.Projection(epsg),
		units: 'm',
		maxResolution: 100000, 
        maxExtent: new OpenLayers.Bounds( -18040096,-22672290,18040096,22672290)
	};

	// Empty base layer
	var base = new OpenLayers.Layer("",{isBaseLayer: true});

	// KML layer
	var kml = new OpenLayers.Layer.GML( "KML", kmlFile, {  
		format: OpenLayers.Format.KML,
		formatOptions: {
			extractStyles: true,
		    extractAttributes: true
		},
		projection: new OpenLayers.Projection("EPSG:4326")
	});				
				
	// Delete contents of map div
	document.getElementById("olmap").innerHTML = "";
				
	// Create new map
	map = new OpenLayers.Map("olmap", options);

	map.addLayer(base);
	map.addLayer(kml);

	map.setCenter( new OpenLayers.LonLat(0.0, 0.0), 1 );
				
}

