// 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
					
				}
				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(msgList[55] + XMLMode + msgList[56]);
	}
	hideLayer("LoadData");
}

// add custom stuff to Map XML request. . . between selection and geocode
function addCustomToMap1(){
	var customString = "";
	/*
		customString += '<LAYER type="ACETATE" name="theMode">\n';
		customString += '<OBJECT units="PIXEL">\n<TEXT coord="5,' + (iHeight-10) + '" label="This is a test">\n';
		customString += '<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="' + modeMapColor + '" ';
		customString += 'threed="TRUE" glowing="' + modeMapGlow + '" />\n</TEXT>\n</OBJECT>';
		customString += '\n</LAYER>\n';
	*/
	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 = "";
		/*
		customString += '<LAYER type="ACETATE" name="theMode">\n';
		customString += '<OBJECT units="PIXEL">\n<TEXT coord="5,' + (iHeight-10) + '" label="This is a test">\n';
		customString += '<TEXTMARKERSYMBOL fontstyle="BOLD" fontsize="12" font="ARIAL" fontcolor="' + modeMapColor + '" ';
		customString += 'threed="TRUE" glowing="' + modeMapGlow + '" />\n</TEXT>\n</OBJECT>';
		customString += '\n</LAYER>\n';
		alert(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(msgList[51]);
}

function showWindowStatus(buttontype)
{
	var buttontype;
	switch (buttontype)
	{
	case "help":
		window.status = "Tip sheet";
	break;
	case "close":
		window.status = "Close viewer";
	break;
	case "home":
		window.status = "ConservationMapper home";
	break;
	case "town":
		window.status = "Zoom to a town";
	break;
	case "watershed":
		window.status = "Zoom to a watershed";
	break;
	}
	return false;
}

function popUp(wintype)
{
	var wintype;
        var tipWindow;
	var homeWindow;
	switch (wintype)
	{
	case "home":
		homeWindow = window.open("http://www.conservationmapper.org","homeWindow");
		homeWindow.focus();
	break;
	case "help":
		tipWindow = window.open(appDir + "help/tipsheet.htm","TipSheet","width=620,height=600,top=20,left=20,scrollbars=yes,resizable=yes");
		tipWindow.focus();
	break;
	}
	return false;
}

function openActiveDefn()
{
	var windowFeatures = "width=400,height=515,top=20,left=20,scrollbars=no,resizable=yes";
	if (navigator.appName=="Netscape") windowFeatures = "width=400,height=560,top=20,left=20,scrollbars=no,resizable=yes";
	activeWindow = window.open(appDir + "help/activelayer.htm","ActiveLayerDefn",windowFeatures);
	theFrame = "opener";
	if (parent.MapFrame!=null) theFrame = "opener.parent.MapFrame";
	activeWindow.focus();
}

function openVisibleDefn()
{
	visibleWindow = window.open(appDir + "help/visiblelayers.htm","VisibleLayerDefn","width=400,height=225,top=20,left=20,scrollbars=no,resizable=yes");
	theFrame = "opener";
	if (parent.MapFrame!=null) theFrame = "opener.parent.MapFrame";
	visibleWindow.focus();
}

function openLayerMeta(j)
{
	var theURL;
	theURL = appDir + layerMetadata[j];
	metaWindow = window.open(theURL,"LayerMetadata","width=600,height=400,top=20,left=20,scrollbars=yes,resizable=yes");
	theFrame = "opener";
	if (parent.MapFrame!=null) theFrame = "opener.parent.MapFrame";
	metaWindow.focus();
}

function zoomToTown()
{
	parent.TextFrame.document.location = appDir + "zoomtownForm.htm";
}
	
function zoomToWatershed()
{
	parent.TextFrame.document.location = appDir + "zoomwatershedForm.htm";
}


