
ClimateWatch.InsecureReviewRecords = {
    map: null,
    
    init: function() {
    
	this.map = new ClimateWatch.Maps.OpenLayers("map", {});

	var url = window.location.toString();
	//get the parameters
	url.match(/\?(.+)$/);
	var params = RegExp.$1;
	// split up the query string and store in an
	// associative array
	var params = params.split("&");
	var queryStringList = {};
	var species = ""; 
	for(var i=0;i<params.length;i++) {
		var tmp = params[i].split("=");
		queryStringList[tmp[0]] = unescape(tmp[1]);
	}

	for(var i in queryStringList)
		if (i == "species")
			species = "&species=" + queryStringList[i];
        
		this.map.addKMLOverlay("/" + ClimateWatch.servletName + "/files/downloadGrid.htm?precision=2&kml=1" + species,
                               {maxResolution: 50000, minResolution: 17000, title: "Precision 2", 
                                  name: this.gridImagePrecision2Name, displayInLayerSwitcher: true, showInfo: false});
                                  
        this.map.addKMLOverlay("/" + ClimateWatch.servletName + "/files/downloadGrid.htm?precision=1&kml=1" + species,
                               {maxResolution: 17000, minResolution: 7601, title: "Precision 1", 
                                  name: this.gridImagePrecision1Name, displayInLayerSwitcher: true, showInfo: false});
                                  
        this.map.addKMLOverlay("/" + ClimateWatch.servletName + "/files/downloadGrid.htm?precision=0.5&kml=1" + species,
                               {maxResolution: 7601, minResolution: 2501, title: "Precision 0.5", 
                                  name: this.gridImagePrecision0Pt5Name, displayInLayerSwitcher: true, showInfo: false});
                                  
        this.map.addKMLOverlay("/" + ClimateWatch.servletName + "/files/downloadGrid.htm?precision=0.25&kml=1" + species,
                               {maxResolution: 2501, minResolution: 0, title: "Precision 0.25", 
                                  name: this.gridImagePrecision0Pt25Name, displayInLayerSwitcher: true, showInfo: false});
		this.map.recenter();
    }
}

Event.observe(window, 'load', ClimateWatch.InsecureReviewRecords.init.bind(ClimateWatch.InsecureReviewRecords));

