function NewMap(hasOVMap) {
	if (arguments.length == 0)
		var hasOVMap = false;
     var dataObj = document.datalist.data;

     var numtheme = 0
     var datalist = ",";

     for (var i=0; i<dataObj.length; i++) {
		if(dataObj[i].checked) {
			numtheme = numtheme + 1
			datalist = datalist + dataObj[i].value + ","
		}
     }

     if (numtheme == 0) { 
		alert("Please select data layers for your map.");
		return;
     }

     var maparea = document.datalist.maparea.value;

	//Add datasets that always visible.
	switch (maparea) {
	case "canada":
		datalist += "0,";
		break;
	case "russia_siberia":
		datalist += "grid1,grid2,grid3,country,country1k,russia,russia1k,russiabnd,";
		break
	}

     var swidth = 800;
     var sheight = 600;
     if (window.screen) {
		swidth = screen.width - 10
		sheight = screen.height - 100
     }
	swidth = Math.min(swidth,1280);
	sheight = Math.min(sheight,1024);

	if (hasOVMap)
		var maploc = "http://ims.missouri.edu/gfw/common/html/viewerOV.htm?MAP=" + maparea + "&DATALIST=" + datalist;     	
	else
		var maploc = "http://ims.missouri.edu/gfw/common/html/viewer.htm?MAP=" + maparea + "&DATALIST=" + datalist;

     var gfwMap = window.open(maploc,"gfwMap","width="+swidth+",height="+sheight+",left=0,top=0,resizable=1,status=1,menubar=1");
     gfwMap.focus();
}



function popupWin(theURL, popW, popH) {
	var w = 480;
	var h = 340;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var leftPos = (w-popW)/2;
	var topPos = (h-popH)/2;
	var popWin = window.open(theURL,"popup","width=" + popW + ",height="+popH+",top="+topPos+",left="+leftPos);
	popWin.focus();
	return popWin;
}

function popupWin2(theURL, popW, popH) {
	var w = 480;
	var h = 340;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var leftPos = (w-popW)/2;
	var topPos = (h-popH)/2;
	var popWin2 = window.open(theURL,"popup","width=" + popW + ",height="+popH+",top="+topPos+",left="+leftPos);
	popWin2.focus();
}

function metadataWin(theURL, popW, popH) {
	var w = 480;
	var h = 340;

	if (document.all || document.layers) {
		w = screen.availWidth;
		h = screen.availHeight;
	}

	var leftPos = w-popW-10;
	popWin = window.open(theURL,"popup","width=" + popW + ",height="+popH+",menubar=1,toolbar=1,resizable=1,scrollbars=1,top=0,left="+leftPos);
	popWin.focus();
}
