<html>
<head>
<title>Local Folder Selection</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<link rel="stylesheet" href="search.css"/>

<style type="text/css">
	HTML {width:300px; height:240px;}
</style>

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
var bclose = false;
var bcancel = false;
function document_onkeydown()
{
	// Check "Escape" key down
	if(event.keyCode == 0x1B)
	{
		bclose = false;
		window.close();
	}
	// Check "Enter" key down
	else if( (event.keyCode == 0x0D) && (bcancel == false))
	{
		var dir = document.all.folder_tree;
		var dir_obj = new VBArray(dir.paths);
		var dir_array = dir_obj.toArray();
		if(MATH_Gt(dir_array.length, 0))
		{
			var num_ch_to_keep = dir_array[0].length - 1;
			var dir_sel = dir_array[0].slice(0, num_ch_to_keep);
			window.returnValue = dir_sel;
			bclose = true;
		}
		else
		{
		  bclose = false;
		}
		window.close();
	}
}
//-->
</SCRIPT>
<SCRIPT LANGUAGE=javascript FOR=document EVENT=onkeydown>
<!--
 document_onkeydown()
//-->
</SCRIPT>
</head>

<body bgcolor="#cccccc">
<script language="JavaScript" src="search_errors.js"></script>
<script language="VBScript" src="vb_utils.js"></script>
<script language="JavaScript" src="math_utils.js"></script>
<script language="JavaScript" src="support_ie_old.js"></script>

<script language="JavaScript" for="ok_button" event="onclick()">
// get index number for selected item in the folder tree
// Note: selected folder is not necessarily 'opened' folder
var dir = document.all.folder_tree;

// safearray to java script array
var dir_obj = new VBArray(dir.paths);
var dir_array = dir_obj.toArray();

// check to see if there is any selection
// (single selection assumed)
if(MATH_Gt(dir_array.length, 0))
{
  var num_ch_to_keep = dir_array[0].length - 1;
  var dir_sel = dir_array[0].slice(0, num_ch_to_keep);

  // get corresponding path
  window.returnValue = dir_sel;
  bclose = true;
}
else
  bclose = false;

window.close();
</script>

<script language="JavaScript" for="cancel_button" event="onkeydown()">
// If the user press Enter or Space bar key on cancel button, then no selection is made, indicate it in bclose 
if(event.keyCode == 0X0D || event.keyCode == 0X20)
{
    bcancel = true;
    bclose = false;
    window.close();
}
</script>


<script language="JavaScript" for="cancel_button" event="onclick()">
// no selection is made, indicate it in bclose 
bclose = false;
window.close();
</script>

<script language="JavaScript" for="window" event="onload()">
var sf_array = VBCreateArray(1);
sf_array = VBSetElement(sf_array, 0, window.dialogArguments + "\\");
document.all.folder_tree.paths = sf_array;
</script>

<script language="JavaScript" for="window" event="onunload()">
// if no selection is made, return empty string to parent window
if(bclose  == false)
  window.returnValue = "noselection";
</script>

<table width="50%" border="0" height="200" cellpadding="2" cellspacing="2">
  <tr>
    <td rowspan="2" width="65%">
      <P>

      <OBJECT id=folder_tree style="LEFT: 1px; TOP: 3px" height=200 width=300
      					classid=CLSID:574B123E-F15A-11D4-BC75-006008C79300>
      <PARAM NAME="MultiSelect" VALUE="0">
      <PARAM NAME="FixedDrives" VALUE="-1">
      <PARAM NAME="RemoteDrives" VALUE="0">
      <PARAM NAME="CDROMDrives" VALUE="0">
      <PARAM NAME="RemovableDrives" VALUE="0">
      <PARAM NAME="ExpandRootOneLevel" VALUE="0">
      <PARAM NAME="DTSTYPEPATHS" VALUE="1">
      <PARAM NAME="_cx" VALUE="5292">
      <PARAM NAME="_cy" VALUE="5292">
      <PARAM NAME="Appearance" VALUE="0">
      <PARAM NAME="AutoSize" VALUE="0">
      <PARAM NAME="BackColor" VALUE="16777215">
      <PARAM NAME="ForeColor" VALUE="0">
      </OBJECT>

      </P>
	</td>
	    <td width="35%" height="100">
      <div align="center">
        <input type="button" name="ok_button" value="OK" style="WIDTH: 60px">
      </div>
    </td>
  </tr>

  <tr>
    <td width="35%" height="100">
      <div align="center">
        <input type="button" name="cancel_button" value="Cancel" style="WIDTH: 60px">
      </div>
    </td>
  </tr>

</table>

</body>
</html>
