// CivXplorer Code to support cascading tool menus

// Suzanne Fliege, Plansight, LLC

var menuItemList = new Array();
var menuItemListCount = 0;

// extension & module availability variables
var groupedlayersAvailable = false;
var advancedGroupedLayersAvailable = false;
var datalinkingAvailable = false;
var zoom2areaAvailable = false;
var zoom2areaMenuText = '';
var selectByAreaAvailable = false;
var cmdstartAvailable = false;
var pdfMapOutputAvailable = false;
var pdfMailOutputAvailable = false;
var latlongptAvailable = false;
var useCustomFunctions = false;
var dataextractAvailable = false;
var datasummaryAvailable = false;
var FEMAtoolkitAvailable = false;
var usermgmtAvailable = false;

// set layer background color
function setLayerBackgroundColor(name, color) {		
   	document.getElementById(name).style.backgroundColor = color;
}

// update content in a layer
function updateContent(name, content) {
	document.getElementById(name).innerHTML = content;	
}

// create a div with border
function createBorderedDiv(name, content, itop, ileft, iwidth, iheight, styleclass, theMouseDown, theMouseOver, theMouseOut){
	if(!isIE){
		iwidth = iwidth - (2*borderWidth);
		iheight = iheight - (2*borderWidth);
	}
	var mouseString = ""
	if (theMouseDown != "") mouseString += 'onMouseDown="JavaScript: ' + theMouseDown + '" ';
	if (theMouseOver != "") mouseString += 'onMouseOver="JavaScript: ' + theMouseOver + '" ';
	if (theMouseOut != "") mouseString += 'onMouseOut="JavaScript: ' + theMouseOut + '"';
	mouseString += 'onContextMenu="JavaScript:return false;"';
	document.writeln('<div id="' + name + '" class="' + styleclass + '" style="left:' + ileft + 'px; top:' + itop + 'px; width:' + iwidth + 'px; height:' + iheight + 'px;' + ';border-width:' + borderWidth +'px" ' + mouseString + ' >');
	document.writeln(content);
	document.writeln('</div>');
	return false;
}

// create a map layer divs (map image, zoom boxes, measure, etc)
function createUnborderedDiv(name, content, itop, ileft, iwidth, iheight, styleclass, theMouseDown, theMouseOver, theMouseOut){
	var mouseString = ""
	if (theMouseDown != "") mouseString += 'onMouseDown="JavaScript: ' + theMouseDown + '" ';
	if (theMouseOver != "") mouseString += 'onMouseOver="JavaScript: ' + theMouseOver + '" ';
	if (theMouseOut != "") mouseString += 'onMouseOut="JavaScript: ' + theMouseOut + '"';
	mouseString += 'onContextMenu="JavaScript:return false;"';
	document.writeln('<div id="' + name + '" class="' + styleclass + '" style="left:' + ileft + 'px; top:' + itop + 'px; width:' + iwidth + 'px; height:' + iheight + 'px;' + ';" ' + mouseString + '>');
	document.writeln(content);
	document.writeln('</div>');
	return false;
}

// create tool menus
function createToolMenus() {
	// background color
	document.writeln('<DIV id="menuBlankSpace" class="subToolMenu" onContextMenu="JavaScript:return false;" onMouseOver="JavaScript:setMenus(\'nothing\');" style="left:' + sidebarWidth + 'px; top:' + headerHeight + 'px; width:' + (winWidth-sidebarWidth) + 'px; height:' + toolmenuHeight + 'px;"></DIV>');
	// create main menu bar items
	document.writeln('<DIV Id="toolMenus" class="mainToolMenu">');
	document.writeln(createMenuBar("toolLayers","blankmenu","showSidebar(\'cxTOC\');",0,headerHeight,sidemenubarWidth,"Map Layers"));
	document.writeln(createMenuBar("toolLegend","blankmenu","showSidebar(\'cxLegend\');",sidemenubarWidth,headerHeight,sidemenubarWidth,"Legend"));
	// custom tool menus (in sidebar)
	if (useCustomFunctions) addCustomToolItems();
	document.writeln(createMenuBar("toolCurrentSelection","blankmenu","showSidebar(\'cxCurrentSelection\');",0,(headerHeight+toolmenuHeight*(CustomSidebarMenuCount+1)),(sidemenubarWidth*2),"Current Selection"));
	document.writeln(createMenuBar("toolNav","menuNav","",sidebarWidth,headerHeight,menubarWidth,"Navigation"));
	document.writeln(createMenuBar("toolFind","menuFind","",(sidebarWidth+menubarWidth),headerHeight,menubarWidth,"Find a Location"));
	document.writeln(createMenuBar("toolQuery","menuQuery","",(sidebarWidth+menubarWidth*2),headerHeight,menubarWidth,"Query/Select"));
	document.writeln(createMenuBar("toolReports","menuReports","",(sidebarWidth+menubarWidth*3),headerHeight,menubarWidth,"Maps/Reports"));
	document.writeln(createMenuBar("toolMisc","menuMisc","",(sidebarWidth+menubarWidth*4),headerHeight,menubarWidth,"Other Tools"));
	document.writeln(createQuickTools());
	document.writeln('</DIV>');
	// navigation dropdown
	document.writeln(createDropdown("menuNav",sidebarWidth+5,headerHeight+toolmenuHeight));
	if (useHome) document.writeln(createMenuItem("menuItem_Home","clickFunction('home');","<img src='images/CXhome.gif' align='middle'>&nbsp;&nbsp;&nbsp;"+txtHome));
	if (useZoomIn) document.writeln(createMenuItem("menuItem_ZoomIn","clickFunction('zoomin');","<img src='images/CXzoomin.gif' align='middle'>&nbsp;&nbsp;&nbsp;Zoom In"));
	if (useZoomOut) document.writeln(createMenuItem("menuItem_ZoomOut","clickFunction('zoomout');","<img src='images/CXzoomout.gif' align='middle'>&nbsp;&nbsp;&nbsp;Zoom Out"));
	if (usePan) document.writeln(createMenuItem("menuItem_Pan","clickFunction('pan');","<img src='images/CXpan.gif' align='middle'>&nbsp;&nbsp;&nbsp;Pan"));
	if (useFullExtent) document.writeln(createMenuItem("menuItem_ZoomAll","clickFunction('zoomall');","<img src='images/CXzoomall.gif' align='middle'>&nbsp;&nbsp;&nbsp;View Entire Map"));
	if (useZoomPrevious) document.writeln(createMenuItem("menuItem_ZoomPrevious","clickFunction('zoomlast');","<img src='images/CXzoomlast.gif' align='middle'>&nbsp;&nbsp;&nbsp;Previous View"));
	if (useZoomSelected) document.writeln(createMenuItem("menuItem_ZoomSelected","clickFunction('zoomselected');","<img src='images/CXzoomselect.gif' align='middle'>&nbsp;&nbsp;&nbsp;Zoom To Selected"));
	if (useMeasure) document.writeln(createMenuItem("menuItem_Measure","clickFunction(\'measure\');","<img src='images/CXmeasure.gif' align='middle'>&nbsp;&nbsp;&nbsp;Measure on Map"));
	if (useCustomFunctions) addCustomMenuItems("menuNav");
	document.writeln('</DIV>');
	// find location dropdown
	document.writeln(createDropdown("menuFind",sidebarWidth+menubarWidth+5,headerHeight+toolmenuHeight));
	if (useFindByID) document.writeln(createMenuItem("menuItem_FindByID","writePINQueryForm();",txtFindByID));
	if (useFindByAddress) document.writeln(createMenuItem("menuItem_FindByAddress","writeAddressQueryForm();",txtFindByAddress));
	if (useFindByOwner) document.writeln(createMenuItem("menuItem_FindByOwner","writeOwnerQueryForm();",txtFindByOwner));
	if (useFindIntersection) document.writeln(createMenuItem("menuItem_FindByIntersection","writeIntersectionQueryForm();",txtFindIntersection));
	if (selectByAreaAvailable) addSelectByAreaMenus();
	if (zoom2areaAvailable) addZoomAreaMenuItems();
	if (useCustomFunctions) addCustomMenuItems("menuFind");
	if (latlongptAvailable) document.writeln(createMenuItem("menuItem_LatLongPtZoom","writeLatLongPtForm();","Put a Point on Map by Lat/Long"));
	if (latlongptAvailable) document.writeln(createMenuItem("menuItem_LatLongPtClear","isALatLongPt=false;sendMapRequest();hideAllDropdowns();","Clear Lat/Long Point"));
	if (latlongptAvailable) document.writeln(createMenuItem("menuItem_LatLongPtCoord","clickFunction(\'latlongcoord\');","Click on Map for Lat/Long Coords"));
	document.writeln('</DIV>');
	// query/select dropdown
	document.writeln(createDropdown("menuQuery",sidebarWidth+menubarWidth*2+5,headerHeight+toolmenuHeight));
	if (useIdentify) document.writeln(createMenuItem("menuItem_Identify","clickFunction(\'identify\');","<img src='images/CXidentify.gif' align='middle'>&nbsp;&nbsp;&nbsp;Identify"));
	if (useSelect) document.writeln(createMenuItem("menuItem_Select","clickFunction(\'select\');","<img src='images/CXselect.gif' align='middle'>&nbsp;&nbsp;&nbsp;Select"));
	if (useHotlink) document.writeln(createMenuItem("menuItem_Hotlink","clickFunction(\'hotlink\');",txtHotlink));
	if (useSelectByAttribute) document.writeln(createMenuItem("menuItem_QueryBuilder","clickFunction(\'querybyattribute\');",txtSelectByAttribute));
	if (useSelectByLocation) document.writeln(createMenuItem("menuItem_Buffer","writeBufferForm(false);","<img src='images/CXbuffer.gif' align='middle'>&nbsp;&nbsp;&nbsp;"+txtSelectByLocation));
	if (useCustomFunctions) addCustomMenuItems("menuQuery");
	if (useClearSelect) document.writeln(createMenuItem("menuItem_ClearSelect","clickFunction(\'clearsel\');","<img src='images/CXclearselect.gif' align='middle'>&nbsp;&nbsp;&nbsp;Clear All Selections"));
	if (useAttributeDisplay) document.writeln(createMenuItem("menuItem_AttributeDisplay","clickFunction(\'showattribute\');","Display Current Selection"));
	document.writeln('</DIV>');
	// maps/reports
	document.writeln(createDropdown("menuReports",sidebarWidth+menubarWidth*3+5,headerHeight+toolmenuHeight));
	if (useMapDisplay) document.writeln(createMenuItem("menuItem_Map","clickFunction(\'printmap\');","Create a Printable Map"));
	if ((useReportDisplay) || (useMailingDisplay)) document.writeln(createMenuItem("menuItem_Report","clickFunction(\'printreport\');",txtReportAndLabelDisplay));
	if (useCustomFunctions) addCustomMenuItems("menuReports");
	if (datasummaryAvailable) document.writeln(createMenuItem("menuItem_DataSummaryParams","showDataSummaryDialog();","Data Summary - Set Parameters"));
	if (datasummaryAvailable) document.writeln(createMenuItem("menuItem_DataSummaryReport","createDataSummaryReport();","Data Summary - Report (Pop-up)"));
	if (dataextractAvailable) document.writeln(createMenuItem("menuItem_DataExtract","initializeDataExtract();","Data Extraction"));
	document.writeln('</DIV>');
	// miscellaneous/custom
	document.writeln(createDropdown("menuMisc",sidebarWidth+menubarWidth*4+5,headerHeight+toolmenuHeight));
	if (useHelp) {
		if (showUserHelp) {
			document.writeln(createMenuItem("menuItem_Help","clickFunction(\'help\');","Turn Off Help Notes"));
		} else {
			document.writeln(createMenuItem("menuItem_Help","clickFunction(\'help\');","Turn On Help Notes"));			
		}
	}
	// printing in-frame available?
	if (((useReportDisplay) || (useMailingDisplay) || (useMapDisplay))) {
		if (showReportsInFrame) {
			document.writeln(createMenuItem("menuItem_PrintDisplay","clickFunction(\'printdisplay\');","Show Maps/Reports<br>&nbsp;&nbsp;&nbsp;in Pop-Up Window"));
		} else {
			document.writeln(createMenuItem("menuItem_PrintDisplay","clickFunction(\'printdisplay\');","Show Maps/Reports<br>&nbsp;&nbsp;&nbsp;in Current Window"));			
		}
	}
	// attribute display as row/column?
	if (showSelectedAttributesAsRows) {
		document.writeln(createMenuItem("menuItem_AttributeDisplayType","clickFunction(\'attributedisplaytype\');","Show Data in Columns"));
	} else {
		document.writeln(createMenuItem("menuItem_AttributeDisplayType","clickFunction(\'attributedisplaytype\');","Show Data in Rows"));			
	}
	if (useDisclaimer) document.writeln(createMenuItem("menuItem_Disclaimer","showSidebar(\'cxDisclaimer\');","Show Disclaimer"));
	if (useSources) document.writeln(createMenuItem("menuItem_Sources","showSidebar(\'cxSources\');","Show Sources"));
	if (useFAQ) document.writeln(createMenuItem("menuItem_FAQ","clickFunction(\'faq\');",txtFAQ));
	if ((useMetadata) && (MetaDataURL != "")) document.writeln(createMenuItem("menuItem_Metadata","clickFunction(\'metadata\');",txtMetadata));
	if (useCustomFunctions) addCustomMenuItems("menuMisc");
	document.writeln('</DIV>');
	return false;
}

// functions to create menu parts
function createMenuBar(theID,theMenu,theMouseDown,theLeft,theTop,theWidth,theText) {
	var theString = '<DIV id="' + theID + '" class="subToolMenu" menu="' + theMenu +'" onContextMenu="JavaScript:return false;" onMouseDown="JavaScript: ' + theMouseDown + '" onMouseOver="JavaScript:setMenus(\'' + theID + '\');if (showUserHelp) showHelp(\'' + theID + '\');" onMouseOut="" style="left:' + theLeft + 'px; top:' + theTop + 'px; width:' + theWidth + 'px; height:' + toolmenuHeight + 'px;">';
	theString += theText //'<table cellpadding="0" cellspacing="0" width="100%"><tr><td class="subToolMenu">' + theText + '</td></tr></table>';
	theString += '</DIV>';
	return theString;
}
function createDropdown(theID,theLeft,theTop) {
	var theString = '<DIV id="' + theID + '" class="dropdownMenu" style="left:' + theLeft + 'px; top:' + theTop + 'px;">';
	return theString;
}
function createMenuItem(theID,theMouseDown,theContent) {
	var theString = '<DIV id="' + theID + '" class="menuItem" onContextMenu="JavaScript:return false;" onMouseDown="JavaScript: ' + theMouseDown + '" onMouseOver="JavaScript:highlightItem(\'' + theID + '\');if (showUserHelp) showHelp(\'' + theID + '\');" onMouseOut="" >' + theContent + '</DIV>'
	// add to list of active menu items for color control
	menuItemList[menuItemListCount] = theID;
	menuItemListCount += 1;
	return theString;
}
function createQuickTools() {
	var theString = '<table cellpadding="0" cellspacing="0">';
	theString += '<tr><td><img src="images/CXmailboxbutton.gif" name="addresspic" onmousedown="writeAddressQueryForm();" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_FindByAddress\');" ></td></tr>';
	if (useHome) theString += '<tr><td><img src="images/CXhome.gif" name="homepic" onmousedown="clickFunction(\'home\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_Home\');" ></td></tr>';
	if (useZoomIn) theString += '<tr><td><img src="images/CXzoomin.gif" name="zoominpic" onmousedown="clickFunction(\'zoomin\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_ZoomIn\');" ></td></tr>';
	if (useZoomOut) theString += '<tr><td><img src="images/CXzoomout.gif" name="zoomoutpic" onmousedown="clickFunction(\'zoomout\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_ZoomOut\');" ></td></tr>';	
	if (usePan) theString += '<tr><td><img src="images/CXpan.gif" name="panpic" onmousedown="clickFunction(\'pan\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_Pan\');" ></td></tr>';
	if (useFullExtent) theString += '<tr><td><img src="images/CXzoomall.gif" name="zoomallpic" onmousedown="clickFunction(\'zoomall\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_ZoomAll\');" ></td></tr>';
	if (useZoomPrevious) theString += '<tr><td><img src="images/CXzoomlast.gif" name="zoomlastpic" onmousedown="clickFunction(\'zoomlast\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_ZoomPrevious\');" ></td></tr>';
	if (useIdentify) theString += '<tr><td><img src="images/CXidentify.gif" name="identifypic" onmousedown="clickFunction(\'identify\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_Identify\');" ></td></tr>';
	if (useSelect) theString += '<tr><td><img src="images/CXselect.gif" name="selectpic" onmousedown="clickFunction(\'select\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_Select\');" ></td></tr>';
	if (useSelectByLocation) theString += '<tr><td><img src="images/CXbuffer.gif" name="bufferpic" onmousedown="writeBufferForm(false);" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_Buffer\');" ></td></tr>';
	if (useClearSelect) theString += '<tr><td><img src="images/CXclearselect.gif" name="clearselectpic" onmousedown="clickFunction(\'clearsel\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_ClearSelect\');" ></td></tr>';
	if (useZoomSelected) theString += '<tr><td><img src="images/CXzoomselect.gif" name="zoomlastpic" onmousedown="clickFunction(\'zoomselected\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_ZoomSelected\');" ></td></tr>';
	if (useMeasure) theString += '<tr><td><img src="images/CXmeasure.gif" name="measure" onmousedown="clickFunction(\'measure\');" class="quickToolNoBorder" onmouseover="setMenus(\'nothing\');if (showUserHelp) showHelp(\'menuItem_Measure\');" ></td></tr>';
	theString += '</table>';
	var fullString = createUnborderedDiv("menuQuickTools",theString,(headerHeight+toolmenuHeight),sidebarWidth,toolmenuHeight,(winHeight-headerHeight-toolmenuHeight),"quickToolMenu","","","");
	return fullString;
}

// quick tool image border reset
function resetQuickTools() {
	if (useZoomIn) document.zoominpic.className = "quickToolNoBorder";
	if (useZoomOut) document.zoomoutpic.className = "quickToolNoBorder";
	if (usePan) document.panpic.className = "quickToolNoBorder";
	if (useIdentify) document.identifypic.className = "quickToolNoBorder";
	if (useSelect) document.selectpic.className = "quickToolNoBorder";
	if (useMeasure) document.measure.className = "quickToolNoBorder";
	return false;
}

// set menu & dropdown visibility on mouseovers
function setMenus(theMenu) {
	// reset everything
	resetAllMenus();
	resetDropdownItems();
	hideAllDropdowns();
	hideHelp();
	// set menu visible (if not nothing)
	if (!(theMenu == "nothing")) {
		document.getElementById(theMenu).className = "subToolMenuOver";
	}
	switch(theMenu) {
	// make corresponding dropdown visible and reset colors
	case "toolNav":
		document.getElementById('menuNav').style.visibility = "visible";
		hideSelectIDDialog();
		break
	case "toolFind":
		document.getElementById('menuFind').style.visibility = "visible";
		hideSelectIDDialog();
		break
	case "toolQuery":
		document.getElementById('menuQuery').style.visibility = "visible";
		hideSelectIDDialog();
		break
	case "toolReports":
		document.getElementById('menuReports').style.visibility = "visible";
		hideSelectIDDialog();
		break
	case "toolMisc":
		document.getElementById('menuMisc').style.visibility = "visible";
		hideSelectIDDialog();
		break
	default:
		//alert("Not a valid menu item");
	}
	return false;
}
// turn highlight off all menus
function resetAllMenus() {
	document.getElementById('toolNav').className = "subToolMenu";
	document.getElementById('toolFind').className = "subToolMenu";
	document.getElementById('toolQuery').className = "subToolMenu";	
	document.getElementById('toolReports').className = "subToolMenu";
	document.getElementById('toolMisc').className = "subToolMenu";
	document.getElementById('toolLayers').className = "subToolMenu";
	document.getElementById('toolLegend').className = "subToolMenu";	
	document.getElementById('toolCurrentSelection').className = "subToolMenu";
	if (useCustomFunctions) resetCustomToolItems();
	return false;
}
// hide all dropdowns
function hideAllDropdowns() {
	document.getElementById('menuNav').style.visibility = "hidden";
	document.getElementById('menuFind').style.visibility = "hidden";
	document.getElementById('menuQuery').style.visibility = "hidden";	
	document.getElementById('menuReports').style.visibility = "hidden";
	document.getElementById('menuMisc').style.visibility = "hidden";
	return false;
}
// show needed dropdown
function showDropdown(theDropdown) {
	if (theDropdown == "toolNav") document.getElementById('menuNav').style.visibility = "visible";
	if (theDropdown == "toolFind") document.getElementById('menuFind').style.visibility = "visible";
	if (theDropdown == "toolQuery") document.getElementById('menuQuery').style.visibility = "visible";
	if (theDropdown == "toolReports") document.getElementById('menuReports').style.visibility = "visible";
	if (theDropdown == "toolMisc") document.getElementById('menuMisc').style.visibility = "visible";
	return false;
}

// reset menu dropdown
function resetDropdownItems() {
	for (var i=0;i<menuItemListCount;i++) {
		var tempMenuItem = document.getElementById(menuItemList[i]);
		tempMenuItem.className = "menuItem";
	}
	return false;
}

// highlight menu item
function highlightItem(menuItemName) {
	resetDropdownItems();
	document.getElementById(menuItemName).className = "menuItemMouseOver";
	return false;
}

// controls for the Sidebar (Layers, Legend, Disclaimer, Sources area)
function hideAllSidebars() {
	document.getElementById('cxTOC').style.visibility = "hidden";
	document.getElementById('cxLegend').style.visibility = "hidden";
	document.getElementById('cxDisclaimer').style.visibility = "hidden";	
	document.getElementById('cxSources').style.visibility = "hidden";
	document.getElementById('cxAttributeTop').style.visibility = "hidden";
	document.getElementById('cxAttributeBottom').style.visibility = "hidden";
	legendVisible = false;
	return false;
}

function showSidebar(theSidebar) {
	hideAllDropdowns();
	if (theSidebar == "cxCurrentSelection") {
		hideAllSidebars();
		document.getElementById('LoadData').style.visibility = "visible";
		attDisplayMaxed = false;
		displayAttributeData(false);
		clickFunction("showattribute");
	} else {
		hideAllSidebars();
		document.getElementById(theSidebar).style.visibility = "visible";
		if (theSidebar == "cxLegend") {
			legendVisible = true;
			getLegend();
		}
	}
	return false;
}

// hide (reset) on-map dialogs
function hideAllDialogs() {
	document.getElementById('cxSelectIDDialog').style.visibility = "hidden";
	return false;
}

// pan bar creation
function createPanBars() {
	var panFrameWidth = winWidth - sidebarWidth - toolmenuHeight;
	var panFrameHeight = winHeight - headerHeight - toolmenuHeight;
	// background color
	createUnborderedDiv("panBarBackground","",(headerHeight+toolmenuHeight),(sidebarWidth+toolmenuHeight),panFrameWidth,panFrameHeight,"panBars","","","");
	// place the arrows
	var content = '<a href="#" onmousedown="panButton(2);"><img src="images/CXpanN_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanN_2.gif\';" onmouseout="src=\'images/CXpanN_1.gif\';"/></a>';
	createUnborderedDiv("panBarN",content,(headerHeight+toolmenuHeight+3),(sidebarWidth+toolmenuHeight+iWidth/2-15),30,15,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(4);"><img src="images/CXpanS_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanS_2.gif\';" onmouseout="src=\'images/CXpanS_1.gif\';"/></a>';
	createUnborderedDiv("panBarS",content,(headerHeight+toolmenuHeight+panFrameHeight-18),(sidebarWidth+toolmenuHeight+iWidth/2-15),30,15,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(1);"><img src="images/CXpanW_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanW_2.gif\';" onmouseout="src=\'images/CXpanW_1.gif\';"/></a>';
	createUnborderedDiv("panBarW",content,(headerHeight+toolmenuHeight+iHeight/2-15),(sidebarWidth+toolmenuHeight+2),15,30,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(3);"><img src="images/CXpanE_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanE_2.gif\';" onmouseout="src=\'images/CXpanE_1.gif\';"/></a>';
	createUnborderedDiv("panBarE",content,(headerHeight+toolmenuHeight+iHeight/2-15),(sidebarWidth+toolmenuHeight+panFrameWidth-18),15,30,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(6);"><img src="images/CXpanNW_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanNW_2.gif\';" onmouseout="src=\'images/CXpanNW_1.gif\';"/></a>';
	createUnborderedDiv("panBarNW",content,(headerHeight+toolmenuHeight+6),(sidebarWidth+toolmenuHeight+6),20,20,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(7);"><img src="images/CXpanNE_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanNE_2.gif\';" onmouseout="src=\'images/CXpanNE_1.gif\';"/></a>';
	createUnborderedDiv("panBarNE",content,(headerHeight+toolmenuHeight+6),(sidebarWidth+toolmenuHeight+panFrameWidth-26),20,20,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(5);"><img src="images/CXpanSW_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanSW_2.gif\';" onmouseout="src=\'images/CXpanSW_1.gif\';"/></a>';
	createUnborderedDiv("panBarSW",content,(headerHeight+toolmenuHeight+panFrameHeight-26),(sidebarWidth+toolmenuHeight+6),20,20,"panBars","","","");
	content = '<a href="#" onmousedown="panButton(8);"><img src="images/CXpanSE_1.gif" galleryimg="no" onmouseover="src=\'images/CXpanSE_2.gif\';" onmouseout="src=\'images/CXpanSE_1.gif\';"/></a>';
	createUnborderedDiv("panBarSE",content,(headerHeight+toolmenuHeight+panFrameHeight-26),(sidebarWidth+toolmenuHeight+panFrameWidth-26),20,20,"panBars","","","");
	return false;
}

function createMainMap() {
	// map backdrop
	createUnborderedDiv("theMapBackdrop","",iTop,iLeft,iWidth,iHeight,"mapLayers","","","");
	document.getElementById('theMapBackdrop').style.visibility = "visible";
	setLayerBackgroundColor("theMapBackdrop","#FFFFFF");
	// map image
	var content = '<img id="theMapImage" src="images/CXmap.gif" galleryimg="no" />';
	createUnborderedDiv("theMap",content,iTop,iLeft,iWidth,iHeight,"mapLayers","","setMenus(\'nothing\');","");
	document.getElementById('theMap').style.visibility = "visible";
	// zoom/select box
	createUnborderedDiv("theZoomBox","",iTop,iLeft,iWidth,iHeight,"zoomBox","","","");
	// select/measure shape graphics
	createUnborderedDiv("thePolyline","",iTop,iLeft,iWidth,iHeight,"mapLayers","","","");
	document.getElementById('thePolyline').style.zindex = 100;
	createUnborderedDiv("theRubberband","",iTop,iLeft,iWidth,iHeight,"mapLayers","","","");
	document.getElementById('theRubberband').style.zindex = 101;
	// loading map splash
	document.getElementById('LoadProgram').style.visibility = "hidden";
	content = '<table width="100%" height="100%"><tr><td align="center" valign="middle" class="mapSplashes"><img name="LoadingMap" src="images/loadMap.gif" galleryimg="no"></td></tr></table>';
	createUnborderedDiv("LoadMap",content,iTop,iLeft,iWidth,iHeight,"mapLayers","","","");
	document.getElementById('LoadMap').style.visibility = "visible";
	// loading data splash
	content = '<table width="100%" height="100%"><tr><td align="center" valign="middle" class="mapSplashes"><img name="LoadingData" src="images/loadData.gif" galleryimg="no"></td></tr></table>';
	createUnborderedDiv("LoadData",content,iTop,iLeft,iWidth,iHeight,"mapLayers","","","");
	document.getElementById('LoadData').style.visibility = "hidden";
	// help layer
	createBorderedDiv("cxHelp","",iTop,iLeft,iWidth,iHeight,"mapLayers","","","");
	document.getElementById('cxHelp').style.visibility = "hidden";
	return false;
}

// overview map creation
function createOVMap() {
	// title bar
	var content = 'Reference Map:&nbsp;&nbsp;';
	content += '<select name="ovOptions" class="ovInput" onchange="ovClickAction=this.options[this.selectedIndex].value"><option value="Center">Center<option value="Zoom">Zoom</select>'
	createUnborderedDiv("ovHeader",content,(headerHeight+toolmenuHeight*(CustomSidebarMenuCount+2)+sidebarHeight),0,sidebarWidth,toolmenuHeight,"ovHeader","","","");
	// map image
	var content = '<img id="ovMapImage" src="images/CXmap.gif" galleryimg="no" onmousedown="ovMapClick(event)"/>';
	createUnborderedDiv("ovMap",content,(headerHeight+toolmenuHeight*(CustomSidebarMenuCount+3)+sidebarHeight),0,ovWidth,ovHeight,"mapLayers","","if (showUserHelp) showHelp('overviewMap');","")
	document.getElementById('ovMap').style.visibility = "visible";
	// zoom box
	createUnborderedDiv("ovZoomBox","",(headerHeight+toolmenuHeight*(CustomSidebarMenuCount+3)+sidebarHeight),0,sidebarWidth,ovHeight,"ovzoomBox","","","");
	document.getElementById('ovZoomBox').style.visibility = "visible";
	return false;
}

function updateSidebarsBasedOnMapExtents() {
	ovHeight = parseInt(limitHeight/limitWidth*sidebarWidth);
	sidebarHeight = winHeight - headerHeight - toolmenuHeight*(CustomSidebarMenuCount+3) - ovHeight;
	// overview image size
	i2Width = ovWidth-5;
	i2Height = ovHeight-5;
	document.getElementById('ovMap').style.top = (headerHeight+toolmenuHeight*(CustomSidebarMenuCount+3)+sidebarHeight) + "px";
	document.getElementById('ovMap').style.height  = ovHeight + "px";
	document.getElementById('ovZoomBox').style.top = (headerHeight+toolmenuHeight*(CustomSidebarMenuCount+3)+sidebarHeight) + "px";
	document.getElementById('ovZoomBox').style.height  = ovHeight + "px";
	document.getElementById('ovHeader').style.top = (headerHeight+toolmenuHeight*(CustomSidebarMenuCount+2)+sidebarHeight) + "px";
	document.getElementById('cxTOC').style.height = sidebarHeight + "px";
	document.getElementById('cxLegend').style.height = sidebarHeight + "px";
	document.getElementById('cxDisclaimer').style.height = sidebarHeight + "px";	
	document.getElementById('cxSources').style.height = sidebarHeight + "px";
	// put in intial content to top (to prevent hide display error)
	theString = '<table width="100%" cellpadding=0 cellspacing=0>';
	theString += '<tr><td class="header1" width="100%" align="right"><a href="#" onmousedown="resizeAttributeDisplay();"><img name="AttDisplaySizePic" src="images/CXmaxAttDisplay.gif" align="top" alt="Expand Attribute Display"></a><a href="#" onmousedown="hideAttributeDisplay();"><img src="images/CXclose.gif" align="top"></a></td></tr>';
	theString += '<tr><td class="header1" align="center">Selections Cleared!</td></tr>';
	theString += '<tr><td class="toolInfo2" align="center">No Features are Selected</td></tr>';
	theString += '</table>';
	updateContent("cxAttributeTop",theString);
	return false;	
}

