function loadMap(controls, bounds, numZoomLevels, wmsServerURL, includeOverview, includeScalebar)
{
	if(bounds == null || bounds == undefined)
		bounds = [9960000, 3340000, 12430000, 4440000];
	if(numZoomLevels == null || numZoomLevels == undefined)
		numZoomLevels = 10;
	if(wmsServerURL == null || wmsServerURL == undefined)
		wmsServerURL = "";
		
    	//create the map
	var nt = new OpenLayers.Control.NavToolbar({'div':OpenLayers.Util.getElement('paneldiv')});
	var panel = new OpenLayers.Control.Panel({'div':OpenLayers.Util.getElement('controlPanelDiv')});
	var nav = new OpenLayers.Control.Navigation({displayClass: "controlNav", title: "Pan"}); 
	var zi = new OpenLayers.Control.ZoomBox({displayClass: "controlZoombox", title: "Zoom In"});
	var zo = new OpenLayers.Control.ZoomOut({displayClass: "controlZoomout", title: "Zoom Out"});
	var ztme = new OpenLayers.Control.ZoomToMaxExtent({displayClass: "controlZoomtomax", title: "Zoom to Extents"});
	var ztle = new OpenLayers.Control.ZoomToLastExtent({displayClass: "controlZoomtolast", title: "Zoom to Last Position"});
	var em = new OpenLayers.Control.Email({displayClass: "controlEmail", title: "Email"});
	var id = new OpenLayers.Control.Identify(identify, {displayClass: "controlIdentify", title: "Identify"});
	
	var controlArray = new Array();
	
	/*if the controls array is empty use the default list of controls*/
	if(controls == null || controls == undefined)
		controlArray = [nav,zi,zo,ztme,ztle,em,id];
	else{
	/*Match text and add the control to the array*/
		if(controls.match("nav"))
			controlArray.push(nav);
		if(controls.match("zi"))
			controlArray.push(zi);
		if(controls.match("zo"))
			controlArray.push(zo);
		if(controls.match("ztme"))
			controlArray.push(ztme);
		if(controls.match("ztle"))
			controlArray.push(ztle);
		if(controls.match("em"))
			controlArray.push(em);
		if(controls.match("id"))
			controlArray.push(id);
	}
	panel.addControls(controlArray);

    	mapoptions = {
		projection: new OpenLayers.Projection(EPSG),
		units: 'm',
		//(minx, miny, maxx, maxy)
		maxExtent: new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2], bounds[3]),
		maxResolution: 'auto',
		numZoomLevels: numZoomLevels,
		controls: [panel],
		theme: null
    	}

	map = new OpenLayers.Map('map', mapoptions);
	setupZTLE(map);
	panel.activateControl(nav);
    
	//we use FREAC LayerList class to read in XML 
	var layerlist = new LayerList(map);
	layerlist.init("layerconfig.xml");
	var wmslayers = layerlist.layers.getLayersByService("arcgis");
	var wmsparams = {
		layers: wmslayers.getLayerString(),
        	srs: EPSG,
        	transparent: true,
        	format:"image/gif"
    	}
    	var wmsoptions = {
       		isBaseLayer: true,
        	singleTile: true,
        	ratio: 1
    	}

    	var wms = new OpenLayers.Layer.WMS( imiStateCode + " WMS",
        wmsServerURL,
        wmsparams, wmsoptions);
    	map.addLayers([wms]);
  	
  	/*Overview Map*/
	/*If there is anything in the includeOverview variable, show the overview map*/
  	if(includeOverview != null || includeOverview != undefined || includeOverview != 'no')
  	{
	  	var ovparams = {
			layers: "1",
			srs: EPSG
	    	}
	    	var ovoptions = {
	       		gutter: 20,
			buffer:0
	    	}
	    	var ov = new OpenLayers.Layer.WMS( imiStateCode + " Overview", 
		wmsServerURL,
		ovparams, ovoptions);
		var overviewoptions = {
			mapOptions: {
				projection: new OpenLayers.Projection(EPSG),
				units: 'm',
				maxExtent: new OpenLayers.Bounds(bounds[0], bounds[1], bounds[2], bounds[3]),
				numZoomLevels:2,
				minRatio:16, 
				maxRatio:64
				},
			layers: [ov], 
			size: new OpenLayers.Size(150,125)
	    	}
		var overview = new OpenLayers.Control.OverviewMap(overviewoptions);      
		map.addControl( overview );
		overview.maximizeControl();	
		changeOverViewMapImg();
	}
	
	/*Scale Bar*/
	/*If there is anything in the includeScalebar variable, include the scalebar*/
	if(includeScalebar != null || includeScalebar != undefined || includeScalebar != 'no')
  	{
		
		map.addControl( new OpenLayers.Control.ScaleBar() );
	}
	
	if (!map.getCenter()) map.zoomToMaxExtent();

	_Event.addCustomEvent("layerupdate",function(e){
		wms.mergeNewParams({layers: wmslayers.getLayerString()});
	});


	map.events.register("moveend", map, rescaleWeeds);
}

//Change overview map img 
function changeOverViewMapImg()
{
	var minImg = document.getElementById('OpenLayers_Control_minimizeDiv_innerImage');
	minImg.src = "../lib/img/layer-switcher-minimize.png";
	var maxImg = document.getElementById('olControlOverviewMapMaximizeButton_innerImage');
	maxImg.src = "../lib/img/layer-switcher-maximize.png";
}
