
//***********************************************	
//***************** FUNCTIONS *******************
//***********************************************

// *************** ACTIVE.JS ********************

// set search tool
function setSearchTool(newTool) {
//alert("setSearchTool");
//alert(cbYear_option);

var content
//	setSearchToolImage(newTool);

	hideSearchLayers();
	if (newTool == "ADDRESS") {
		content = writeAddressForm();
		replaceLayerContent("SearchAddr", content);
		showLayer("SearchAddr");
	} else if (newTool == "INTERSECTION") {
		content = writeIntersectionForm();
		replaceLayerContent("SearchInter", content);
		showLayer("SearchInter");
	} else if (newTool == "LANDMARK") {
		showLayer("SearchLand");
	} else if (newTool == "ADVSEARCH") {
		content = writeSearchForm();
		replaceLayerContent("AdvSearch", content);
		showLayer("AdvSearch");
    } else if (newTool == "SADDRESS") {
		content = writeSAddressForm(cbYear_option);
		replaceLayerContent("SearchSAddr", content);
		showLayer("SearchSAddr");
	} else if (newTool == "SINTERSECTION") {
		content = writeSIntersectionForm(cbYear_option);
		replaceLayerContent("SearchSInter", content);
		showLayer("SearchSInter");
	} else if (newTool == "SLANDMARK") {
	showLayer("SearchSLand");
	} else if (newTool == "RESULTS") {
		showLayer("SearchResults");
	}
//	document.frmNavigation.searchtool.value = newTool;
}

//hide search layers
function hideSearchLayers(){
//	hideLayer("SearchAddr");
//	hideLayer("SearchInter");
//	hideLayer("SearchLand");
//	hideLayer("AdvSearch");
	hideLayer("SearchResults");
    hideLayer("SearchSAddr");
	hideLayer("SearchSInter");
	hideLayer("SearchSLand");
}

// do address search
function doSAddrSearch(){
	if(isNav4){
		theForm = document.SearchSAddr.document.frmAddr;
	} else {
		theForm = document.frmAddr;
	}

	HN = theForm.sHN1.value;
	Dir = theForm.sDir1.options[theForm.sDir1.options.selectedIndex].value;
	StN = theForm.sStN1.value;
	StT = theForm.sStT1.options[theForm.sStT1.options.selectedIndex].value;
	ZC = theForm.sZC1.value;
	sYR1 = theForm.sYR1.options[theForm.sYR1.options.selectedIndex].value;
	
	var add1 = HN + " " + Dir + " " + StN + " " + StT;
	var Zone = ZC;

	if((HN == "")||(StN == "")){
		alert("Please enter a street number and name.");
	} else {
		showLayer("loadLayer");
		
		document.frmNavigation.HN1.value = HN;
		document.frmNavigation.Dir1.value = Dir;
		document.frmNavigation.StN1.value = StN ;
		document.frmNavigation.StT1.value = StT;
		document.frmNavigation.ZC1.value = ZC;
		document.frmNavigation.YR1.value = sYR1;

		document.frmNavigation.Address1.value = add1;
		document.frmNavigation.Zone.value = ZC;
				
		document.frmNavigation.Cmd.value = 'ADDRESS';
		document.frmNavigation.target="";
		//document.frmNavigation.action = 'SalesMap.asp';
				
		document.frmNavigation.submit();
	}
}

// do sales intersection search
function doSInterSearch(){
	if(isNav4){
		theForm = document.SearchSInter.document.frmInter;
	} else {
		theForm = document.frmInter;
	}

	var Dir1 = theForm.STDIR1.options[theForm.STDIR1.options.selectedIndex].value;
	var StN1 = theForm.STNAME1.value;
	var StT1 = theForm.STTYPE1.options[theForm.STTYPE1.options.selectedIndex].value;

	var Dir2 = theForm.STDIR2.options[theForm.STDIR2.options.selectedIndex].value;
	var StN2 = theForm.STNAME2.value;
	var StT2 = theForm.STTYPE2.options[theForm.STTYPE2.options.selectedIndex].value;

	sYR1 = theForm.sYR1.options[theForm.sYR1.options.selectedIndex].value;

	if((StN1 == "")||(StN2 == "")){
		alert("Please enter a street name.");
	} else {
		showLayer("loadLayer");

		document.frmNavigation.Address1.value = Dir1 + " " + StN1 + " " + StT1;
		document.frmNavigation.Address2.value = Dir2 + " " + StN2 + " " + StT2;
				
		document.frmNavigation.IDir1.value = Dir1;
		document.frmNavigation.IStN1.value = StN1;
		document.frmNavigation.IStT1.value = StT1;
				
		document.frmNavigation.IDir2.value = Dir2;
		document.frmNavigation.IStN2.value = StN2;
		document.frmNavigation.IStT2.value = StT2 ;

		document.frmNavigation.YR1.value = sYR1;
				
		document.frmNavigation.Cmd.value = 'INTERSECTION';
		document.frmNavigation.target="";
		//document.frmNavigation.action = 'map.asp';
				
		document.frmNavigation.submit();
	}
}

// do sales landmark search
function doSLandSearch(){
	if(isNav4){
		theForm = document.SearchSLand.document.frmLand;
	} else {
		theForm = document.frmLand;
	}

	if (theForm.LandMark.options.selectedIndex == -1) {
		alert("Please select a landmark");
		//return;
	} else {
		showLayer("loadLayer");
		var theString = theForm.LandMark.options[theForm.LandMark.selectedIndex].value;
		var sX_COORD = theString.substring(0,13);
		var sY_COORD = theString.substring(13,26);
		var sName = theString.substring(26,theString.length);
		var fX_COORD = parseFloat(sX_COORD, 10);
		var fY_COORD = parseFloat(sY_COORD, 10);

		sYR1 = theForm.sYR1.options[theForm.sYR1.options.selectedIndex].value;

		document.frmNavigation.YR1.value = sYR1;
		document.frmNavigation.Cmd.value = 'LANDMARK';
		document.frmNavigation.LM.value = theString;
		document.frmNavigation.GeocodeLabel.value = sName;
		document.frmNavigation.GeocodePoint_X.value = sX_COORD;
		document.frmNavigation.GeocodePoint_Y.value = sY_COORD;
		document.frmNavigation.ShowWhat.value = "";
				
		document.frmNavigation.target="";
		//document.frmNavigation.action = 'map.asp';
				
		document.frmNavigation.submit();
	}
}

// do sales search
function doSale(){

	if(isNav4){
		theForm = document.SearchResults.document.frmSale;
	} else {
		theForm = document.frmSale;
	}

	showLayer("loadLayer");

	var theYear = theForm.sYR1.options[theForm.sYR1.selectedIndex].value;

	document.frmNavigation.Cmd.value = 'SNAPSHOT';
	document.frmNavigation.YR1.value = theYear;
	document.frmNavigation.ShowWhat.value = "";
				
	document.frmNavigation.target="";
	//document.frmNavigation.action = 'map.asp';
				
	document.frmNavigation.submit();
}
