// 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;




// 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) {
	var mp = parent.MapFrame;
	switch (XMLMode) {
		case 1001:
			break;
		case 1002:
			// retorno del pedido del tipo XMLMode = 1001, pedido de busqueda
			// de padrones
			//alert("Reply 1002:"+theReply);
			laRespuesta = theReply;
			// displayAttributeData(theReply);

			//DEBUG: mostrar cuantos elementos devuelve la consulta.
			// Ej.: I-6489;I-691;I-277;I-1526 devuelve poco mas de 200.
			//alert('Cantidad de poligonos encontrados = ' + justGetFeatureCount(theReply));
			//FIN_DEBUG

			if (justGetFeatureCount(theReply)<1) {
				//alert("NO EXISTEN ELEMENTOS EN SU CONSULTA");
				alert("No se encontraron datos geográficos");
			} else {
				resultQueryPadConeatForm(theReply);
			}
			break;
		case 1003:
			// retorno de solicitud de desplegar el acetato de poligonos con
			// el zoom adecuado
			// alert("Reply 1003:"+theReply);

			var imsMapURLPR = getURL(theReply);
			// actualizo el envelope de lo seleccionado
			// alert(envPadConeat.toString());
			getXYs(theReply);
			document.theImage.src = imsMapURLPR;

			crearPagConeatForm();
			break;
		case 1004:
			// retorno de solicitud de desplegar el acetato de poligonos con
			// el zoom adecuado
			// --alert("Reply 1004:"+theReply);

			mp.imsMapImpURLPR = getURL(theReply);
			// alert("imsMapURL:"+imsMapURLPR );
			// alert(envPadConeat.toString());
			// --document.theImage.src = mp.imsMapImpURLPR;
			makeShowConeatPageImp1();
			break;
		case 1005:
			// retorno de solicitud de desplegar el acetato de poligonos con
			// el zoom adecuado para el OVMAP
			// --alert("Reply 1005:"+theReply);

			mp.imsOVMapImpURLPR = getURL(theReply);
			// alert("imsMapURL:"+imsMapURLPR );
			// alert(envPadConeat.toString());
			// document.theImage.src = mp.imsOVMapImpURLPR;
			makeShowConeatPageImp2();
			break;
		case 1006:
			// retorno de solicitud de leyenda con solo el catcon prendido
			// --alert("Reply 1006:"+theReply);

			mp.imsLegendImpURL = getLegendURL(theReply);
			// alert("imsMapURL:"+imsMapURLPR );
			// alert(envPadConeat.toString());
			// document.theImage.src = mp.imsOVMapImpURLPR;
			// makeShowConeatPageImp3();
			finCreateConeatPageImp(mp.indProdPadConeat, mp.totPads)
			break;
		case 1007:
			// retorno de solicitud de pedir el acetato con el norte
			alert("Reply 1007:"+theReply);

			mp.imsNorteImpURL = getURL(theReply);
			// alert("imsMapURL:"+imsMapURLPR );
			// alert(envPadConeat.toString());
			// document.theImage.src = mp.imsOVMapImpURLPR;
			finCreateConeatPageImp();
			break;
		case 1008:
			// retorno de solicitud de pedir el acetato con el norte
			alert("Reply 1008:"+theReply);

			var imagenes = getURL(theReply);
			// alert("imsMapURL:"+imsMapURLPR );
			// alert(envPadConeat.toString());
			document.theImage.src = imagenes;
			break;
		default:
			alert("Modo desconocido:" + XMLMode + "\nImposible de ejecutar el pedido.");
			break;
	}

	hideLayer("LoadData");
	mp = null;
}

// 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.");
}



