<html>
<head>
<title>Image Web Server Sample Web Site</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK REL="stylesheet" HREF="css/SampleStyle.css" TYPE="text/css">
<LINK REL="icon" HREF="/ecwplugins/lib/bitmaps/logo16.gif" TYPE="image/gif">
<LINK REL="SHORTCUT ICON" HREF="/ecwplugins/lib/bitmaps/logo32.ico">

<!-- --- see Note 1 for discussion of Javascript Include files  -->

<SCRIPT LANGUAGE=javascript src="scripts/Util.js"></SCRIPT>
<SCRIPT LANGUAGE=javascript src="/ecwplugins/lib/scripts/NCSConstants.js"></SCRIPT>
<SCRIPT LANGUAGE=vbscript	src="/ecwplugins/lib/scripts/NCSCheckActiveX.vbs"></SCRIPT>
<SCRIPT LANGUAGE=javascript src="/ecwplugins/lib/scripts/NCSCheck.js"></SCRIPT>
<SCRIPT LANGUAGE=javascript src="/ecwplugins/lib/scripts/NCSCreateView.js"></SCRIPT>

<SCRIPT LANGUAGE=javascript src="/ecwplugins/lib/scripts/NCSControl.js"></SCRIPT>
<SCRIPT LANGUAGE=javascript src="/ecwplugins/lib/scripts/NCSToolbar.js"></SCRIPT>
<SCRIPT LANGUAGE=javascript src="/ecwplugins/lib/scripts/NCSProgressbar.js"></SCRIPT>

</head>

<SCRIPT LANGUAGE=javascript>
<!--
// check for older browser versions no longer supported 
if (parseFloat(navigator.appVersion) < 4.0) {
	document.location = "/ecwplugins/sorry.htm";
}
/* ---- see note 2 for discussion of version checking ------ */
ECWCheckPlugin();

/* ---- see note 3 for discussion of creating an image array as part of the toolbar object*/
var imageArray = new Array(
	"ecwp://demo.ermapper.com/images/geodetic/world/landsat742.ecw",
	"ecwp://" + document.location.host + "/sampleiws/images/usa/sandiego3i.ecw",
	"ecwp://" + document.location.host + "/sampleiws/images/usa/1metercalif.ecw",
	"ecwp://" + document.location.host + "/sampleiws/images/australia/parramatta.ecw",
	"ecwp://demo.ermapper.com/images/usa/1metercalif.ecw");

// There is a major bug in Mozilla where the onLoad event for the body gets called before the
// plugins on the page are loaded, this seems to work around it.
var tOnLoadTimer = null;
var ECWProgressBar = null;

/* ----- see note 4 for discussion of initial load handler ------ */
function onLoadCB() {
	tOnLoadTimer = setTimeout("LoadHandler()", 500);
}

function onUnloadCB() {
	deleteCookie("NCSPluginInstallMethod");
}

function LoadHandler() {
/* ------ see note 5 at end for discussion of AddLayer --------- */
	clearTimeout(tOnLoadTimer);
	if (document.ECWView1.AddLayer("ECW", 
		   "ecwp://demo.ermapper.com/images/geodetic/world/landsat742.ecw", 
		   "RasterLayer", "") < 0 ) {
		alert(document.ECWView1.GetLastErrorText());
	}
	document.ECWView1.SetBackGroundColor("#DDDDDD"); //sets background color of the View
}

/* ----- see note 6 at end for discussion of the Toolbar Handler function ------ */
function ECWToolbarCB(uid, value)
{
	if (uid == "UID_VIEW_PAN")
	{
		document.ECWView1.SetPointerMode(0);
	}
	else if (uid == "UID_VIEW_ZOOM")
	{
		document.ECWView1.SetPointerMode(1);
	}
	else if (uid == "UID_VIEW_ZOOMBOX")
	{
		document.ECWView1.SetPointerMode(3);
	}
	else if (uid == "UID_VIEW_POINTER")
	{
		document.ECWView1.SetPointerMode(2);
	}
	else if (uid == "UID_VIEW_RESET")
	{
		document.ECWView1.SetExtentsAll();
	}
	// see Note 7 for discussion of switching images in the View Control
	else if (uid == "UID_IMAGE_COMBO")
	{
		document.ECWView1.DeleteAllLayers();
		if (document.ECWView1.AddLayer("ECW", value, "RasterLayer", "") < 0 ) {
			alert(document.ECWView1.GetLastErrorText());
		}
	}
}

/* --- see Note 8 for discussion for how cookies
 are used to control the type of control that gets installed. */
// Force the native plugin (ActiveX/NetscapePlugin)
setCookie("NCSPluginInstallMethod", "NATIVE");

//-->
</SCRIPT>
</head>
<!-- -- see Note 9 for discussion of onload and onUnload events ------------------ -->
<body onLoad="onLoadCB();" onUnload="onUnloadCB();" border=20>
<table width ="90%" align = "center" border = 1 bordercolor = gray>
  <tr>
     <th>
	<font color=gray face=verdana size=2>HELLO WORLD EXAMPLE 2</font>
    </th>
 </tr>
 <tr>
    <td>
	<font face = arial size = 2 color = black>
	This simple example shows how to view ECW imagery from an Image Web Server, 
	using the <b>native ECW plug-in</b>, and connect it to a toolbar using JavaScript.
	You must be connected to the Internet to use the demo.ermapper.com images in this example page.
	</font>
    </td>
 </tr>
 <tr bgcolor='#dddddd'>
   <form name = "form1">
   <!-- This code adds the Toolbar object to the page.
	 This object is used to control the pointer mode for pan, zoom, zoombox and pointer -->
   <TD>
      <SCRIPT LANGUAGE=javascript>
/*----- see note 10 for discussion of the Toolbar Object creation ---*/
	var ECWToolbar1 = new NCSToolbar("UID_VIEW_TOOLBAR", null, false, -1);
/* ---- see note 11 for discussion of adding a toolbar button -------*/
	ECWToolbar1.addButton("Pan around the image by click-dragging the hand on the image",
	     "/ecwplugins/lib/bitmaps/buttons/roam.png",
		 "/ecwplugins/lib/bitmaps/buttons/roamSelect.png", true, ECWToolbarCB, "UID_VIEW_PAN");
	ECWToolbar1.addButton("Zoom in or out of the image interactively by click-dragging the magnifier on the image",
	     "/ecwplugins/lib/bitmaps/buttons/zoom.png",
		 "/ecwplugins/lib/bitmaps/buttons/zoomSelect.png", true, ECWToolbarCB, "UID_VIEW_ZOOM");
	ECWToolbar1.addButton("Zoom into the image by click-dragging a zoom box over the image",
	     "/ecwplugins/lib/bitmaps/buttons/zoombox.png",
		 "/ecwplugins/lib/bitmaps/buttons/zoomboxSelect.png", true, ECWToolbarCB, "UID_VIEW_ZOOMBOX");
	ECWToolbar1.addButton("Select pointer mode to profile or select image features",
	     "/ecwplugins/lib/bitmaps/buttons/pointer.png",
		 "/ecwplugins/lib/bitmaps/buttons/pointerSelect.png", true, ECWToolbarCB, "UID_VIEW_POINTER");
	ECWToolbar1.addSpace ("SPACE", "UID_VIEW_SPACE1");
	ECWToolbar1.addButton("Reset the image to maxiumum extents",
	     "/ecwplugins/lib/bitmaps/buttons/reset.png",
		 "/ecwplugins/lib/bitmaps/buttons/resetSelect.png", false, ECWToolbarCB, "UID_VIEW_RESET");
	ECWToolbar1.addSpace ("SPACE", "UID_VIEW_SPACE1");
/* ---- see note 12 for discussion of the image dropdown menu --------------*/
	ECWToolbar1.addPopdownCombo ("Image : ", imageArray, ECWToolbarCB, "UID_IMAGE_COMBO");
		
	//ECWToolbar1.addPopdownCombo ("Image : ", imageArray, ECWToolbarCB, "UID_IMAGE_COMBO");
				
/* ---- see note 13 for discussion of the build process for the toolbar -----------*/
	document.writeln(ECWToolbar1.rebuild());
	ECWToolbar1.setCurrentItem("UID_VIEW_PAN");
	ECWToolbar1.getTable().border=0;
	ECWToolbar1.getTable().cellSpacing=2;
	ECWToolbar1.getTable().cellPadding=0;
	</SCRIPT>
   </TD>		
 </tr> 
</form>
<tr>
<!-- This code adds the NCS Layered View object to the page. 
This object is used to display the map images and is controlled 
by Javascript calls to load the image layers, set tranparency,
 handle callback events and so on.
-->
  <TD>
     <SCRIPT LANGUAGE=javascript>
/*-------- See Note 14 for discussion of creating the Layered View Control Object -------*/
	NCSCreateView("ECWView1", "100%", "400",
		 PARAM_VIEW_ONPERCENTCOMPLETE, "ECWProgressBar.setProgress(value);");
     </SCRIPT>
  </TD>
</tr>
<tr>
   <TD class="NCSTableHeading" bgcolor='#dddddd'>
     <SCRIPT LANGUAGE=javascript>
/*---- See Note 15 for discussion of creating the Progress Bar Object ----*/
	ECWProgressBar = new NCSProgressbar("NCS_UID_PROGRESS", null, 60, true);
	ECWProgressBar.label = "Progress : ";
	document.writeln(ECWProgressBar.build());
     </SCRIPT>
   </TD>
</table>
</body>
</html>