// aimsCustom.js
/*
*  JavaScript template file for ArcIMS HTML Viewer
*		dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
*		aimsLayers.js, aimsDHTML.js
*		aimsClick.js, aimsNavigation.js,
*/

// global variables
	aimsCustomPresent=true;
	// change these to send XML response to custom function.
	// use numbers >= 1000 and match in useCustomFunction()
	// defaults are defined in aimsXML.js and use standard functions
	
	// xml response mode for selection
	selectXMLMode = 6;
	// xml response mode for identify
	identifyXMLMode = 7;
	// xml response mode for query
	queryXMLMode = 8;
	// xml response mode for find
	findXMLMode = 14;
	// xml response mode hyperlink
	hyperlinkXMLMode = 15;
	// variable designating if the mapservice has just been loaded.
	var firstTime = true;




// custom function for handling clicks 
// 		flow redirected here when
//		toolMode set to >=1000
function customMapTool(e) {
	if (toolMode == 1001) {
		// insert code here
		return false;		
	}
	if (toolMode == 1002) {
		// insert code here

	}

}

// send  XML response to custom function
//		flow  redirected here when
//		XMLMode >=1000
function useCustomFunction(theReply) {
	if (XMLMode==1001) {
		// insert code here
	} else if (XMLMode==1002) {
		// insert code here
	} else {
		alert("Unknown Mode:" + XMLMode + "\nUnable to execute request.");
	}
	hideLayer("LoadData");
}

//routines and checks to run the first time a mapservice is loaded only
function oneTime(){
	//set ModeFrame here so it doesn't trigger errors earlier on
	parent.TopFrame.document.location = "http://" + hostName + "/website/KCRC/top.htm";
	//if (parent.ToolFrame!=null) parent.ToolFrame.document.location = appDir + "toolbar.htm";
 	if (isPublic) {
		if (loadThisService == "Public_Bus_Info") {
			clickFunction("busfind");
			parent.ToolFrame.setToolPic("BusFind");
		} else if (loadThisService == "Public_Parcel_Find" && findPPN == false) {
			clickFunction("geocode");
			parent.ToolFrame.setToolPic("Geocode");
		} else if (loadThisService == "Public_Voting") {
			clickFunction("votingfind");
			parent.ToolFrame.setToolPic("VotingFind");
		} else if (loadThisService == "Public_Parcel_Find" && findPPN == true) {
			clickFunction("zoomin");
			fullSetActiveLayer("Parcels");
			publicSelCleared = false;
			searchValue = findThisPPN;
			searchType = "ppn";
			getFind(findThisPPN);
		} else {
			//Removed per Roger B. - 1/29/04
			//clickFunction("geocode");
		}
	} else {
		clickFunction("geocode");
		parent.ToolFrame.setToolPic("Geocode");
	}
	if ((isPublic == false) && (isPartner == false)){
		var parcelIndex = -1;
		var streetIndex = -1;
		for (var i=0;i<LayerName.length;i++) {
			if (LayerName[i] == "Parcels") parcelIndex = i;
			if (LayerName[i] == "Street Centerlines") streetIndex = i;
		}
		var useThisIndex = 0;
		if (parcelIndex > -1) useThisIndex = parcelIndex;
		else useThisIndex = streetIndex;
		ActiveLayer = LayerID[useThisIndex];
		ActiveLayerType = LayerType[useThisIndex];
		ActiveLayerIndex = useThisIndex;
		setActiveLayer(useThisIndex);
		legendShowing = true;
		topLayerActiveTab = 1;
		parent.TOCFrame.document.location = "http://" + hostName + "/website/testparticipant/legend.htm";
		parent.LayerFrame.document.location = "http://" + hostName + "/website/testparticipant/toplayer.htm";
		parent.ModeFrame.document.location = "http://" + hostName + "/website/testparticipant/ModeFrame.htm";
	} else {
		if (loadThisService == "Public_Bus_Info") {
			topLayerActiveTab = 2;
			parent.TOCFrame.document.location = "http://" + hostName + "/website/KCRC/routeList.htm";
		} else {
			if (loadThisService != "Public_Parcel_Find") {
				legendShowing = true;
				if (loadThisService == "KCRC_TruckOperator" || loadThisService == "KCRC_OfficialMap") {
					parent.TOCFrame.document.location = "http://" + hostName + "/website/KCRC/legendFrame.htm";
				} else {
					parent.TOCFrame.document.location = "http://" + hostName + "/website/KCRC/legend.htm";
				}
				topLayerActiveTab = 1;
			}
		}
		if (isPartner) {
			parent.LayerFrame.document.location = "http://" + hostName + "/website/testpartner/toplayer.htm";
			var parcelIndex = -1;
			var streetIndex = -1;
			for (var i=0;i<LayerName.length;i++) {
				if (LayerName[i] == "Parcels") parcelIndex = i;
				if (LayerName[i] == "Street Centerlines") streetIndex = i;
			}
			var useThisIndex = 0;
			if (parcelIndex > -1) useThisIndex = parcelIndex;
			else useThisIndex = streetIndex;
			ActiveLayer = LayerID[useThisIndex];
			ActiveLayerType = LayerType[useThisIndex];
			ActiveLayerIndex = useThisIndex;
			setActiveLayer(useThisIndex);
			//parent.TOCFrame.document.location = "http://" + hostName + "/website/testpartner/toc.htm";
		} else {
			parent.LayerFrame.document.location = "http://" + hostName + "/website/KCRC/toplayer.htm";
		}
	}
	firstTime = false;
}

// add custom stuff to Map XML request. . . between selection and geocode
function addCustomToMap1(){
	var customString = "";
	
	return customString;
}

// add custom stuff to Map XML request. . . between clickpoints and copyright
function addCustomToMap2(){
	var customString = "";
	
	return customString;
}

// add custom stuff to Map XML request. . . under modeOnMap
function addCustomToMap3(){
	var customString = "";
	
	return customString;
}

// add custom stuff to Map XML request. . . on top of everything
function addCustomToMap4(){
	var customString = "";
	
	return customString;
}

// extract layers to download
function extractIt() {
	hideLayer("measureBox");
	alert("Function not yet enabled.");
}


