// 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
	if (isPublic) parent.TopFrame.document.location = "http://" + hostName + "/website/transportation/top.htm";
	else if (isPartner) parent.TopFrame.document.location = "http://" + hostName + "/website/partner/top.htm";
	else {
		if (isIE) parent.TopFrame.document.location = "http://" + hostName + "/website/participant/top.htm";
		else parent.TopFrame.document.location = "http://" + hostName + "/website/participant/top.htm";
	}
	if (isPublic) {
		if (loadThisService == "Public_Bus_Info") {
			clickFunction("busfind");
			parent.ToolFrame.setToolPic("BusFind");
		} else if (loadThisService == "Public_Parcel_Find") {
			clickFunction("geocode");
			parent.ToolFrame.setToolPic("Geocode");
		} else if (loadThisService == "TIP_Projects") {
			clickFunction("TIPfind");
			parent.ToolFrame.setToolPic("TIPFind");
		} else if (loadThisService == "Transpo_TrafficCounts") {
			clickFunction("countfind");
			parent.ToolFrame.setToolPic("CountFind");
		} else {
			clickFunction("zoomcommunity");
		}
	} 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;
		if (isIE) {
			parent.TOCFrame.document.location = "http://" + hostName + "/Website/participant/legend.htm";
			parent.LayerFrame.document.location = "http://" + hostName + "/Website/participant/toplayer.htm";
			parent.ModeFrame.document.location = "http://" + hostName + "/Website/participant/ModeFrame.htm";
		} else {
			parent.TOCFrame.document.location = "http://" + hostName + "/website/participant/legend.htm";
			parent.LayerFrame.document.location = "http://" + hostName + "/website/participant/toplayer.htm";
			parent.ModeFrame.document.location = "http://" + hostName + "/website/participant/ModeFrame.htm";
		}
	}
	else {
		if (loadThisService == "Public_Bus_Info") {
			topLayerActiveTab = 2;
			parent.TOCFrame.document.location = "http://" + hostName + "/website/transportation/routeList.htm";
		} else {
			legendShowing = true;
			parent.TOCFrame.document.location = "http://" + hostName + "/website/transportation/legend.htm";
			topLayerActiveTab = 1;
		}
		if (isPartner) {
			parent.LayerFrame.document.location = "http://" + hostName + "/website/partner/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);
		} else {
			parent.LayerFrame.document.location = "http://" + hostName + "/website/transportation/toplayer.htm";
		}
	parent.ModeFrame.document.location = "http://" + hostName + "/website/transportation/ModeFrame.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.");
}


