// JavaScript Document
	
	


function ITool() {
	this.setTool;
	//this.defaultImage;
	//this.mouseOverImage;
	//this.mouseDownImage;
//	this.toolType; 	// button | tool
//	this.cursor; 	// css cursor name (move, crosshair, pointer....)
	this.toolTip;
	this.spaceAfter = false; //Bool
	this.showInToolBar = true;
	this.bottomToolBar = false;
	this.isButton = false;
}

var mainMapTools = new Array();
 
//**********************************************
// Navigation Tools
//**********************************************	
mainMapTools["Zoom In Step"] = new ITool();
mainMapTools["Zoom In Step"].setTool = "zoomin";
mainMapTools["Zoom In Step"].toolTip = "Zoom into an area on the map.";
mainMapTools["Zoom In Step"].spaceAfter = false;
mainMapTools["Zoom In Step"].isButton = true;
mainMapTools["Zoom In Step"].showInToolBar = false;

mainMapTools["Zoom Out Step"] = new ITool();
mainMapTools["Zoom Out Step"].setTool ="zoomout";
mainMapTools["Zoom Out Step"].toolTip = "Zoom out from the map.";
mainMapTools["Zoom Out Step"].isButton = true;
mainMapTools["Zoom Out Step"].spaceAfter =true;
mainMapTools["Zoom Out Step"].showInToolBar = false;

mainMapTools["Zoom In"] = new ITool();
mainMapTools["Zoom In"].setTool = "zoominbox";
mainMapTools["Zoom In"].toolTip = "Zoom In using a box";
mainMapTools["Zoom In"].isButton = false;
mainMapTools["Zoom In"].spaceAfter = false;


mainMapTools["Zoom Out"] = new ITool();
mainMapTools["Zoom Out"].setTool = "zoomoutbox";
mainMapTools["Zoom Out"].toolTip = "Zoom Out using a box";
mainMapTools["Zoom Out"].isButton = false;
mainMapTools["Zoom Out"].spaceAfter = false;

mainMapTools["Pan"] = new ITool();
mainMapTools["Pan"].setTool = "pan";
mainMapTools["Pan"].toolTip = "Move side to side on the map";
mainMapTools["Pan"].isButton = false;
mainMapTools["Pan"].spaceAfter = false;

mainMapTools["Full Map"] = new ITool();
mainMapTools["Full Map"].setTool = "fullextent";
mainMapTools["Full Map"].toolTip = "Zoom to original Map";
mainMapTools["Full Map"].isButton = true;
mainMapTools["Full Map"].spaceAfter = true;




//**********************************************
// ID TOOLS
//**********************************************
mainMapTools["Identify"] = new ITool();
mainMapTools["Identify"].setTool = "identify";
mainMapTools["Identify"].toolTip = "Identify a feature on the map";
mainMapTools["Identify"].isButton = false;
mainMapTools["Identify"].spaceAfter = false;

//ID A Parcel Tool
mainMapTools["ID Parcel"] = new ITool();
mainMapTools["ID Parcel"].setTool = "parcelId";
mainMapTools["ID Parcel"].toolTip = "View a Parcels Information";
mainMapTools["ID Parcel"].isButton = false
mainMapTools["ID Parcel"].spaceAfter = false

/*
mainMapTools["Pictometry"] = new ITool();
mainMapTools["Pictometry"].setTool = "pictometry";
mainMapTools["Pictometry"].toolTip = "Pictometry Image of the area";
mainMapTools["Pictometry"].isButton = true;
mainMapTools["Pictometry"].spaceAfter = true;*/

mainMapTools["Coordinates"] = new ITool();
mainMapTools["Coordinates"].setTool = "latlong";
mainMapTools["Coordinates"].toolTip = "Get a lat and long coordinate of a given area";
mainMapTools["Coordinates"].isButton = false
mainMapTools["Coordinates"].spaceAfter = true;

//**********************************************
// Advanced Tools
//**********************************************
mainMapTools["Measure"] = new ITool();
mainMapTools["Measure"].setTool = "measure";
mainMapTools["Measure"].toolTip = "Measure a distance on the map";
mainMapTools["Measure"].isButton = false;
mainMapTools["Measure"].spaceAfter = false;

mainMapTools["Select"] = new ITool();
mainMapTools["Select"].setTool = "select";
mainMapTools["Select"].toolTip = "Select a feature on the map";
mainMapTools["Select"].isButton = false;
mainMapTools["Select"].spaceAfter = false;

mainMapTools["Clear"] = new ITool();
mainMapTools["Clear"].setTool = "clear";
mainMapTools["Clear"].toolTip = "Restore to default map";
mainMapTools["Clear"].isButton = true;
mainMapTools["Clear"].spaceAfter = true;

mainMapTools["Back"] = new ITool();
mainMapTools["Back"].setTool = "back";
mainMapTools["Back"].toolTip = "Previous Map";
mainMapTools["Back"].isButton = true;
mainMapTools["Back"].spaceAfter = false;

/*

//RAMAPO TOOLS
mainMapTools["Election Print"] = new ITool();
mainMapTools["Election Print"].setTool = "elections";
mainMapTools["Election Print"].toolTip = "Print a map of a selected elections district";
mainMapTools["Election Print"].isButton = true;
mainMapTools["Election Print"].spaceAfter = false;



mainMapTools["CofO"] = new ITool();
mainMapTools["CofO"].setTool = "CofO";
mainMapTools["CofO"].toolTip = "Hyperlink to C of O PDF's";
mainMapTools["CofO"].isButton = false;
mainMapTools["CofO"].spaceAfter = false;


mainMapTools["Dedications"] = new ITool();
mainMapTools["Dedications"].setTool = "roadDedications";
mainMapTools["Dedications"].toolTip = "Hyperlink to Road Dedications PDF's";
mainMapTools["Dedications"].isButton = false;
mainMapTools["Dedications"].spaceAfter = false;



//OnCor Only
//ADD a new tool to the toobar for the new Parcel Search
//Addition information added to setTools.js (remove if not OnCor)
mainMapTools["New"] = new ITool();
mainMapTools["New"].setTool = "newParcelSearch";
mainMapTools["New"].toolTip = "Select a Parcel to view its Real Property Information";
mainMapTools["New"].isButton = false
mainMapTools["New"].spaceAfter = false;
*/







//**********************************************
// Odd Balls
//**********************************************

mainMapTools["Link"] = new ITool();
mainMapTools["Link"].setTool = "link";
mainMapTools["Link"].toolTip = "Get a link your current view";
mainMapTools["Link"].isButton = true;
mainMapTools["Link"].spaceAfter = false;
mainMapTools["Link"].bottomToolBar = true;

mainMapTools["Email Link"] = new ITool();
mainMapTools["Email Link"].setTool = "emailLink";
mainMapTools["Email Link"].toolTip = "Send This Maps Link through Email";
mainMapTools["Email Link"].isButton = true;
mainMapTools["Email Link"].spaceAfter = false;
mainMapTools["Email Link"].bottomToolBar = true;

mainMapTools["Refresh"] = new ITool();
mainMapTools["Refresh"].setTool = "refresh";
mainMapTools["Refresh"].toolTip = "Refresh Map";
mainMapTools["Refresh"].isButton = true;
mainMapTools["Refresh"].spaceAfter = false;
mainMapTools["Refresh"].bottomToolBar = true;

mainMapTools["Print"] = new ITool();
mainMapTools["Print"].setTool = "print";
mainMapTools["Print"].toolTip = "Print a Map";
mainMapTools["Print"].isButton = true;
mainMapTools["Print"].spaceAfter = false;
mainMapTools["Print"].bottomToolBar = true;

mainMapTools["Help"] = new ITool();
mainMapTools["Help"].setTool = "help";
mainMapTools["Help"].toolTip = "Help Using these tools";
mainMapTools["Help"].isButton = true;
mainMapTools["Help"].spaceAfter = false;
mainMapTools["Help"].bottomToolBar = true;



//public vars needed for setting text tool bar bg Color
var currentToolBarTool = null;
var previousToolBarTool = '';

var borderNormalStyle = '1px solid #38A800';
var borderOverStyle = '1px inset #FFF';
var borderDownStyle = '1px inset #38A800';

function designMainMapToolBar(useToolImages) {
	
	var spacerImageURL = toolsPath +'/spacer.gif';
	
	
	var toolBarWidth = 650;
	var toolBarCellWidth = 45;
	var topToolBarLayer = document.getElementById("topToolBar");
	var bottomToolBarLayer = document.getElementById("bottomToolBar");
	var topToolBarHTML = '';
	var bottomToolBarHTML = '';
	
	topToolBarHTML+='<table  border="0" cellspacing="1" cellpadding="0">\n';
	topToolBarHTML+='<tr>\n';
	
	
	bottomToolBarHTML+='<table border="0" cellspacing="0" cellpadding="0">\n';
	bottomToolBarHTML+='<tr>\n';
	
	
	//add the image into the tool bar
	for(tool in mainMapTools) {
	
	toolImageName = mainMapTools[tool].setTool + ".gif";
	
	if (mainMapTools[tool].showInToolBar && mainMapTools[tool].bottomToolBar) {
	
		bottomToolBarHTML +='<td width=33px>\n'
		bottomToolBarHTML +='<img src="'+toolsPath+'/'+toolImageName+'" border="0" style="cursor:pointer;" title="'+tool+'" onClick="setToolActiveColor(this,true); setTool(\''+mainMapTools[tool].setTool+'\'); return false;">';	
		bottomToolBarHTML +='</td>\n'
		
	}
	
	
	
		if (mainMapTools[tool].showInToolBar && !mainMapTools[tool].bottomToolBar) {
			topToolBarHTML+='<td>';
				//topToolBarHTML+='<table  border="0" cellspacing="0" cellpadding="0" style="border: 1px solid #D6D7E7">\n';
				
				
				topToolBarHTML+='<table border="0" cellspacing="0" cellpadding="0" style="border: '+borderNormalStyle+'" title="'+mainMapTools[tool].toolTip+'" class="toolBarText" id="'+mainMapTools[tool].setTool+'" width="'+toolBarCellWidth+'" align="center" ';
				
				//topToolBarHTML +='onMouseOver="this.style.background=\''+activeToolColor+' \'; " ';
				topToolBarHTML +='onMouseOver="this.style.border=\''+borderOverStyle+'\'; " ';
				topToolBarHTML +='onMouseDown="this.style.border=\''+borderDownStyle+'\'; " ';
				topToolBarHTML +='onMouseUp="this.style.border=\''+borderOverStyle+'\'; " ';
				topToolBarHTML +='onMouseOut="setToolActiveColor(this,false); " ';
				topToolBarHTML +='onClick="setToolActiveColor(this,true); setTool(\''+mainMapTools[tool].setTool+'\'); ';
				topToolBarHTML +=' return false;">';
	
				
				
				topToolBarHTML+='<tr><td align="center">\n';
				
				
				
				topToolBarHTML +='<div style="width:22px; height:20px;"><img src="'+toolsPath+'/'+toolImageName+'" border="0" style="cursor:pointer;"></div>';	
			
				topToolBarHTML +='</td>';
				topToolBarHTML+='</tr>\n';
				
				
				topToolBarHTML +='<tr><td width="'+toolBarCellWidth+'" align="center" class="toolBarText">';
				//replace a space so nothing is never on a new line
				toolName = tool.replace(/ /,'&nbsp\;');
				
				topToolBarHTML +='&nbsp;'+toolName;	
				topToolBarHTML +='&nbsp;</td>';
				
				topToolBarHTML+='</tr></table>\n';
				
				
			if (mainMapTools[tool].spaceAfter)
			{
				topToolBarHTML +='<td>&nbsp;<img src="'+spacerImageURL+'">&nbsp;</td>';
			}
			
			topToolBarHTML+='</td>';
		}
	}
	

	
	topToolBarHTML+='</tr>\n';
	topToolBarHTML+='</table>\n';
	
	
	bottomToolBarHTML+='</tr>\n';
	bottomToolBarHTML+='<table>\n';
	
	
	bottomToolBarLayer.innerHTML = bottomToolBarHTML;
	topToolBarLayer.innerHTML = topToolBarHTML;
	
	currentToolBarTool =document.getElementById(currentToolName)
	//currentToolBarTool.className = "toolBarTextMouseOver";
	currentToolBarTool.style.border =borderOverStyle
	previousToolBarTool =currentToolBarTool;
	setToolActiveColor(currentToolBarTool,true)
	
}






function setToolActiveColor(that,isCurrentTool) {
	
	if (isCurrentTool) {
	toolObj = findToolObject(that.id)
	if (!toolObj.isButton) {
		previousToolBarTool = currentToolBarTool;
		currentToolBarTool = that
	}
	}
	else { 
			if (that.id != currentToolBarTool.id) 
			{
			//that.className = "toolBarText" ;
			that.style.border=borderNormalStyle
			}
		}
		
		if (previousToolBarTool.id != currentToolBarTool.id)
		{
			//previousToolBarTool.className ="toolBarText" ;
			previousToolBarTool.style.border=borderNormalStyle
		}
}





function findToolObject(toolToFind) {
	var ourToolObject = new Object();
		for (var x in mainMapTools)
		{
			if (mainMapTools[x].setTool == toolToFind)
			{
				ourToolObject = mainMapTools[x]
			}
		}
		return ourToolObject;
}

