/**
function returns a base map with NOAA/NSSL overlays and controls; saves
center point for later use
Arguments:
	container :DOM element where the map is going (html <div> tag)
	width     :width of map
	height    :height of map
	myCenter  :GLatLng of map center (optional)
	zoomLevel :starting zoom level (int; optional)
	clickZoom :allow for double clicks for zoom (bool; optional)
	contZoom  :allow for mouse wheel zoom (bool; optional)
	otherMaps :allow for other maps (satellite, hybrid, custom) to be
		   selected (bool; optional)
*/
function createBaseMap(container,width,height,myCenter,zoomLevel,clickZoom,contZoom,otherMaps) {
  //check inputs
  if (typeof myCenter == "undefined") {
    myCenter = new GLatLng(35.18,-97.44);
  }
  if (typeof zoomLevel == "undefined") {
    zoomLevel = 4;
  }
  if (typeof clickZoom == "undefined") {
    clickZoom = true;
  }
  if (typeof contZoom == "undefined") {
    contZoom = true;
  }
  if (typeof otherMaps == "undefined") {
    otherMaps = false;
  }
  var map = new GMap2(container); //make the map
  map.setCenter(myCenter,zoomLevel); //set center and start zoom
  map.savePosition(); //save center for later use
  map.addControl(new GLargeMapControl()); //basic map controls
  map.addControl(new GScaleControl()); //add map scale
  map.addControl(new GOverviewMapControl()); //add overview map
  if (clickZoom) {
    map.enableDoubleClickZoom(); //enable zoom by dbl click
  }
  if (contZoom) {
    map.enableContinuousZoom(); //enable mouse wheel zoom
    GEvent.addListener(map,"mousemove", mouseMove);
    GEvent.addDomListener(container,"DOMMouseScroll",wheelZoom);
    GEvent.addDomListener(container,"mousewheel",wheelZoom);
  }
  if (otherMaps) {
    map.addControl(new GMenuMapTypeControl()); //drop down menu (small footprint)
  }
  //icon overlays
  var noaaX = 0;
  if (otherMaps) {
    var noaaY = 395;
  } else {
    var noaaY = height - 122;
  }
  var noaa = new GScreenOverlay("http://wdssii.nssl.noaa.gov/geotiff/colormaps/noaa.gif", new GScreenPoint(noaaX,noaaY), new GScreenPoint(0, 0), new GScreenSize(120,120));
  var nsslY = noaaY - 122;
  var nssl = new GScreenOverlay("http://wdssii.nssl.noaa.gov/geotiff/colormaps/nssl.gif", new GScreenPoint(noaaX,nsslY), new GScreenPoint(0, 0), new GScreenSize(120,120));
  map.addOverlay(noaa);
  map.addOverlay(nssl);
  GEvent.addListener(map,"clearoverlays",function() {
    map.addOverlay(noaa);
    map.addOverlay(nssl);
  });
  return map;
}
/**
MOUSE ZOOM FUNCTIONS/VARIABLES
Copy these variables and functions into your java script if you want
continuous zooming

//mouse wheel zooming variables
var wheelZooming = false; //is the user currently zooming?
var mouseLatLng; //current LatLng of the mouse

/**
gets the current LatLng of the mouse; the event that calls function passes in
the LatLng
Arguments:
	mousePt :current GLatLng of the mouse
function mouseMove(mousePt) {
  mouseLatLng = mousePt;
}

/**
zoom in/out at current mouse LatLng
Arguments:
	event :the mouse wheel event
function wheelZoom(event) {
  if (wheelZooming) { return; } //don't try to zoom when already zooming
  wheelZooming = true; //let me know I am zooming
  //can I cancel the event?  if so, prevent the action
  if (event.cancelable) { 
    event.preventDefault();
  }
  map.closeInfoWindow(); //close an open info window (if open)
  //zoom appropiately depending on wheel action
  if ((event.detail || -event.wheelDelta) < 0) {
    window.setTimeout(function() {
      map.zoomIn(mouseLatLng,true,true);
      wheelZooming = false;
    },200);
  } else {
    window.setTimeout(function() {
      map.zoomOut(mouseLatLng,true,true);
      wheelZooming = false;
    },200);
  }
}
END MOUSE FUNCTIONS
*/
