
//***********************************************	
//***************** FUNCTIONS *******************
//***********************************************

// *********** SWAP IMAGE FUNCTIONS *************

//swap image
function swapImage(sImg, sSrc){
	if(isNav4){
		theImg = eval("document.NavRight."+sImg);
	} else {
		theImg = eval("document."+sImg);
	}
	theImg.src = sSrc;
}


//set tool
function setTool(sTool){
	sOldTool = document.frmMain.tool.value;
	if((sOldTool == "MEASURE")){
		resetEditTool();
	}
	setToolImage(sTool);
	document.frmMain.tool.value = sTool;
}

//****************** SEARCH FUNCTIONS ***********

// do search addr
function doSearchAddr(){
	theForm = document.frmSearch;
	stnum = theForm.txtaddrnum.value;
	stdir = theForm.seladdrdir.options[theForm.seladdrdir.options.selectedIndex].value;
	stname = theForm.txtaddrname.value;
	sttype = theForm.seladdrtype.options[theForm.seladdrtype.options.selectedIndex].value;
	if((stnum == "") || (stname == "")){
		alert("Please enter a valid street address.");
	} else {
		addr = stnum + " " + stdir + " " + stname + " " + sttype;
		document.frmMain.cmd.value = "SEARCHADDR";
		document.frmMain.addr.value = addr;
		document.frmMain.submit();
		showLayer("loadLayer");
	}
}

// do search Neighborhood Association KC Made Changes on Friday
function doSearchNbhd(){
	theForm = document.frmSearch;
	nbhd = theForm.selnbhd.options[theForm.selnbhd.options.selectedIndex].value;
	if(nbhd == ""){
		alert("Please Select a Neighborhood Association.");
	}else {	
	document.frmMain.cmd.value = "SEARCHNBHD";
	document.frmMain.nbhd.value = nbhd;
	document.frmMain.submit();
	showLayer("loadLayer");
	}
}

// show panel
function showPanel(sPanel) {
	hidePanel();
	if(isNav4){
			if((sPanel  == "SEARCH") || (sPanel == "SEARCH_P")){
				document.Panelbar.T_SEARCH.src = "images/t_search_on.gif";
			}
			if(sPanel  == "REPORT"){
				document.Panelbar.T_REPORT.src = "images/t_report_on.gif";
			}
			if(sPanel  == "LAYERS"){
				document.Panelbar.T_LAYERS.src = "images/t_layers_on.gif";
			}
			if(sPanel  == "LEGEND"){
				document.Panelbar.T_LEGEND.src = "images/t_legend_on.gif";
			}
			if(sPanel  == "LAYOUT"){
				document.Panelbar.T_LAYOUT.src = "images/t_layout_on.gif";
			}
		}else{
			if((sPanel  == "SEARCH") || (sPanel == "SEARCH_P")){
				document.T_SEARCH.src = "images/t_search_on.gif";
			}
			if(sPanel  == "REPORT"){
				document.T_REPORT.src = "images/t_report_on.gif";
			}
			if(sPanel  == "LAYERS"){
				document.T_LAYERS.src = "images/t_layers_on.gif";
			}
			if(sPanel  == "LEGEND"){
				document.T_LEGEND.src = "images/t_legend_on.gif";
			}
			if(sPanel  == "LAYOUT"){
				document.T_LAYOUT.src = "images/t_layout_on.gif";
			}
		}
	showLayer(sPanel);
	document.frmMain.panel.value = sPanel;
}


// hide panel
function hidePanel() {
	sPanel = document.frmMain.panel.value;
	if(sPanel != ""){
		if(isNav4){
			if((sPanel  == "SEARCH") || (sPanel == "SEARCH_P")){
				document.Panelbar.T_SEARCH.src = "images/t_search_off.gif";
			}
			if(sPanel  == "REPORT"){
				document.Panelbar.T_REPORT.src = "images/t_report_off.gif";
			}
			if(sPanel  == "LAYERS"){
				document.Panelbar.T_LAYERS.src = "images/t_layers_off.gif";
			}
			if(sPanel  == "LEGEND"){
				document.Panelbar.T_LEGEND.src = "images/t_legend_off.gif";
			}
			if(sPanel  == "LAYOUT"){
				document.Panelbar.T_LAYOUT.src = "images/t_layout_off.gif";
			}
		}else{
			if((sPanel  == "SEARCH") || (sPanel == "SEARCH_P")){
				document.T_SEARCH.src = "images/t_search_off.gif";
			}
			if(sPanel  == "REPORT"){
				document.T_REPORT.src = "images/t_report_off.gif";
			}
			if(sPanel  == "LAYERS"){
				document.T_LAYERS.src = "images/t_layers_off.gif";
			}
			if(sPanel  == "LEGEND"){
				document.T_LEGEND.src = "images/t_legend_off.gif";
			}
			if(sPanel  == "LAYOUT"){
				document.T_LAYOUT.src = "images/t_layout_off.gif";
			}
		}
		hideLayer(sPanel);
	}
	document.frmMain.panel.value = "";
}

// ************** LAYER LIST FUNCTIONS **********

// set layer list
function setLayerList(iLayer){
	var theLayers = document.frmMain.layerlist.value;
	theImg = eval('document.L'+iLayer);
	theSrc = theImg.src;
	if(theSrc.indexOf("on")!= -1){
		theImg.src = "images/c_box_off.gif";
		theNewLayers = theLayers.substring(0,iLayer-1) + "0" + theLayers.substring(iLayer, theLayers.length);
	} else {
		theImg.src = "images/c_box_on.gif";
		theNewLayers = theLayers.substring(0,iLayer-1) + "1" + theLayers.substring(iLayer, theLayers.length);
	}
	//document.frmMain.cmd.value = "REFRESH";
	document.frmMain.layerlist.value = theNewLayers;
	document.frmMain.submit();
	showLayer("loadLayer");
} 


// *************** MAP SIZE FUNCTIONS ***********

// set map size
function setMapSize(s){
	document.frmMain.cmd.value = "REFRESH";
	document.frmMain.msize.value = s;
	document.frmMain.submit();
	showLayer("loadLayer");
}  


//****************** HELP FUNCTIONS ************

// show help
function showHelp(sTopic){
	helpURL = "help.htm"+"#"+sTopic;
	if (typeof helpWin == 'undefined'){
		helpWin = window.open(helpURL, "Help", "width=500,height=400,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=340,top=0");
		helpWin.opener = self;
	} else {
		if (helpWin.closed){
			helpWin = window.open(helpURL, "Help", "width=500,height=400,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=340,top=0");
			helpWin.opener = self;
		} else {
			helpWin = window.open(helpURL, "Help", "width=500,height=400,toolbar=0,menubar=0,scrollbars=1,resizable=1,left=340,top=0");			
			helpWin.focus();
		}
	}
}


//****************** PRINT FUNCTIONS ***********

// do layout
function doLayout() {
	if(isNav4){
		theForm = document.LAYOUT.document.frmLayout;
	} else {
		theForm = document.frmLayout;
	}

    if(theForm.orient[0].checked){
		orient = "LANDSCAPE";
	}else {
		orient = "PORTRAIT";
}
//KC changed the following line after making changes to the header, css and overall page fee on 20111212
//KC also changed the variable to "printtitle" from simply "title".  This may have been the issue?

    //title = theForm.printtitle.value;

	paper = theForm.paper.options[theForm.paper.options.selectedIndex].value;
	mscale = theForm.scale.value;
	startnum = document.frmMain.startnum.value;
	minX = document.frmMain.minX.value;
	minY = document.frmMain.minY.value;
	maxX = document.frmMain.maxX.value;
	maxY = document.frmMain.maxY.value;
	layerlist = document.frmMain.layerlist.value;
	theURL = "map_print.asp?startnum="+startnum+"&minX="+minX+"&minY="+minY+"&maxX="+maxX+"&maxY="+maxY+"&layerlist="+layerlist+"&title="+title+"&orient="+orient+"&paper="+paper+"&scale="+mscale;
	printWin = window.open(theURL, "Print", "width=600,height=400,toolbar=0,menubar=1,scrollbars=1,resizable=1,left=20,top=0");
}

