<!--
// ==============================================================================
// File Name           : preferences.htm 
// Description         : Preferences Search area
// Author(s)           : Baskaran V
// Date created        : 2009.01.05
// Last reviewed by    : 
// Last date of review : 
// Copyright           : (c) 2008, Sharp Software Development India Pvt Ltd., All rights reserved.
//                       All rights are reserved. Reproduction or transmission in whole or in part, in
//                       any form or by an means, electronic, mechanical or otherwise, is prohibited
//                       without the prior written consent of the copyright owner.

// ==============================================================================

-->

<html xmlns:sds="">
<head>
	<title>Preferences</title>
	<style>
		@media all
		{
			  sds\:spinbox {behavior:url(spinbox.htc)}
			  sds\:checklist {behavior:url(checklist.htc)}
		}
	</style>
	<link href="style.css" rel="stylesheet" type="text/css" />
<!-- 	<script defer type="text/javascript" src="pngfix.js"></script> -->
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
	<link rel="stylesheet" href="search.css"/>
	<script language="JavaScript" src="search_errors.js"></script>
	<script language="VBScript" src="vb_utils.js"></script>
	<script language="JavaScript" src="external_io.js"></script>
	<script language="JavaScript" src="ui_utils.js"></script>
	<script language="JavaScript" src="math_utils.js"></script>
	<script type="text/javascript" src="Themes.js"></script>
	<script language="javascript" type="text/javascript">
	function Pageloading()
	{
	  try{
		  document.all.load_none.style.display = "none";
		  document.all.loadview.style.display = "inline";
		 }
	  catch(e){}	  
	}
	
	</script>
</head>

<body leftmargin="0" topmargin="0" class="Centerbg">
<script language="JavaScript" src="search_index.js"></script>
<script language="JavaScript" src="spinbox.js"></script>
<script language="JavaScript" src="preferences.js"></script>

<script language="JavaScript">
function OnAllIndexesButtonClick()
{
  SelectAllCheckListItems(document.all.index_list);
}

function OnAllFieldsButtonClick()
{
  SelectAllCheckListItems(document.all.field_list);
  
  // gray out fields not selectable for this view option
  // (currently only abstract field is not selectable
  // in summary option)
  SetFieldEnableStates(document.all.field_list,
    GetRadioButton(document.all.results_view_option));
}

function OnResultsViewRadioClick()
{
  var option = GetRadioButton(document.all.results_view_option);
  SetFieldEnableStates(document.all.field_list, option);
}

function OnFieldListClick()
{
  var doc_name = ToLocField("Document Name");
  var el = event.srcElement;
  
  if(el.id == doc_name)
  {
    alert("'Document Name' field can not be turned off.\n" +
	      "Will resume original setting.");
  
    var values = new Array();
    values[doc_name] = "true";
    SetCheckListSelections(document.all.field_list, values);
  }
}

function OnLoadPage()
{
  Pageloading();

  SetCheckListItems(document.all.index_list, GetIndexNames());
  SelectCheckListItems(document.all.index_list, GetSelectedIndexNames()); 
  SetCheckList(document.all.field_list, ToLocFields(GetAppValues("Preferences/Fields")));
  
  var values = GetAppValues("Preferences");
  SetRadioButton(document.all.stemming_option, values["StemmingOption"]);
  SetCheckBox(document.all.favorites_display, values["FavoritesDisplay"]);
  SetCheckBox(document.all.index_display, values["IndexDisplay"]);
  
  //-- DisplayTrayIcon
  SetCheckBox(document.all.index_trayicon, values["DisplayTrayIcon"]);
  //-- end of the DisplayTrayIcon
  
  SetSpinBox(document.all.num_of_matches, values["NumOfMatches"]);
  SetRadioButton(document.all.results_view_option, values["ResultsViewOption"]);
  
  // if no index exists, gray out All Button
  // in Indexes to be Searched area
  if(GetNumOfIndexes() == 0)
    document.all.all_indexes_button.disabled = true;

  SetFieldEnableStates(document.all.field_list, values["ResultsViewOption"]);
  
  // set up spinning behavior of spinbox
  SetContinuousSpin(document.all.num_of_matches);
}

function OnSavePage()
{
  var values = new Array();
  values["StemmingOption"] = GetRadioButton(document.all.stemming_option);
  values["FavoritesDisplay"] = GetCheckBox(document.all.favorites_display);
  values["IndexDisplay"] = GetCheckBox(document.all.index_display);
  
	//-- DisplayTrayIcon
    values["DisplayTrayIcon"] = GetCheckBox(document.all.index_trayicon);
   //-- end of the DisplayTrayIcon
  
  
  values["NumOfMatches"] = GetSpinBox(document.all.num_of_matches);
  values["ResultsViewOption"] = GetRadioButton(document.all.results_view_option);
  SetAppValues("Preferences", values);

  SetIndexSelections(GetCheckList(document.all.index_list));
  SetAppValues("Preferences/Fields", ToPrefFields(GetCheckList(document.all.field_list)));
}

function SetFieldEnableStates(check_list, view_option)
{
  var abs_field = ToLocField("Abstract");
  
  if(view_option == "summary")
  {
    var values = new Array();
	values[abs_field] = "false";	
    SetCheckListEnableStates(check_list, values);
	SetCheckListSelections(check_list, values);
  }
  else if(view_option == "detail")
  {
    var values = new Array();
	values[abs_field] = "true";	
    SetCheckListEnableStates(check_list, values);	
	//SetCheckListSelections(check_list, values);
  }
  else
    alert("SetFieldEnableStates : invalid view option specified.");
}
</script>

<script language="JavaScript" for="all_indexes_button" event="onclick()">
OnAllIndexesButtonClick();
</script>

<script language="JavaScript" for="all_fields_button" event="onclick()">
OnAllFieldsButtonClick();
</script>

<script language="JavaScript" for="results_view_option" event="onclick()">
OnResultsViewRadioClick();
</script>

<script language="JavaScript" for="field_list" event="onclick()">
OnFieldListClick();
</script>

<script language="JavaScript" for="window" event="onload()">
OnLoadPage();
</script>

<script language="JavaScript" for="save_button" event="onclick()">
OnSavePage();
//window.location = "default.htm";
GoToPage('default')
</script>


<script language="JavaScript" for="cancel_button" event="onclick()">
//window.location = "default.htm";
GoToPage('default')
</script>

<div style="display:inline" id="load_none" align="center" ><img src="Images/loading.gif" />... </div>
<div style="display:none" id="loadview">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="53" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="Default_top" height="53">
  <tr> 
    <td width="6%" align="center">
	  <a id="home_link" onClick="GoToPage('default')" class="Normaltext">
	    <img src="Images/search_home.png" border="0" title="Back to Search Home" width="32" height="32" style="position:relative; top:2;"/> 
      </a>
	</td>
    <td> 
      <div id="page_title_area" align="center">
	  <b> Preferences </b>
	  </div>
    </td>
    <td width="180"> 
      <div id="page_link_area" align="right">
	  </div>
    </td>
  </tr>
</table></td>
  </tr>
  <tr>
      <td class="bgcolor_3" height="1" align="left" valign="top"></td>
  </tr>
  <tr>
    <td height="5" align="left" valign="top"></td>
  </tr>
  <tr>
    <td height="46" align="left" valign="top"><blockquote> 
  <blockquote>
    <b>Search Options</b><br/><br/>
    <fieldset><legend>Find matches based on</legend> 
      <table width="100%" border="0" cellspacing="5" cellpadding="5">
        <tr> 
          <td width="50%"> 
            <div align="left"> 
              <input type="radio" name="stemming_option" value="off"/>
              Exact word</div>
          </td>
          <td width="50%"> 
            <input type="radio" name="stemming_option" value="on"/>
            Variation of word endings</td>
        </tr>
      </table>
    </fieldset> <br/>
    <fieldset><legend>Indexes to be Searched</legend>       
    <table width="100%" border="0" cellspacing="5" cellpadding="5">
      <tr> 
        <td width="50%"><sds:checklist id="index_list" height="80" width="200" /></td>
        <td width="50%"> 
          <div align="center"> 
            <input type="button" class="button_style" name="all_indexes_button" value="   All   "/>
          </div>
        </td>
      </tr>
    </table>
    </fieldset>
    <br/>
    <input type="checkbox" name="favorites_display" value="checkbox"/>
	Display list of Favorite Search Terms in Search Area.
	<br/>
    <input type="checkbox" name="index_display" value="checkbox"/>
	Display Indexes to be Searched in Search Area.
	<br>
	<input type="checkbox" name="index_trayicon" value="checkbox"/>
	Display Indexing Tray Icon in system tray.	
	<br/><br/>
    Retrieve first  <sds:spinbox id="num_of_matches" minvalue="1" maxvalue="1000" size="6" />  matches. </blockquote>
</blockquote>
<br/>
<blockquote>
  <blockquote>
    <b>Results Display Options</b><br/><br/>
    <fieldset><legend>First display in</legend> 
      <table width="100%" border="0" cellspacing="5" cellpadding="5">
        <tr> 
          <td width="50%"> 
            <div align="left"> 
              <input type="radio" name="results_view_option" value="summary"/>
              Summary View</div>
          </td>
          <td width="50%"> 
            <input type="radio" name="results_view_option" value="detail"/>
            Detail View </td>
        </tr>
      </table>
      </fieldset> <br/>
      <fieldset><legend>Fields to be Displayed</legend> 
      <table width="100%" border="0" cellspacing="5" cellpadding="5">
        <tr> 
          <td width="50%">
		    <sds:checklist id="field_list" height="100" width="200" />
          </td>
          <td width="50%"> 
            <div align="center"> 
              <input type="button" class="button_style" name="all_fields_button" value="   All   "/>
            </div>
          </td>
        </tr>
      </table>
    </fieldset></blockquote>
</blockquote>
<hr/>
<table width="100%" border="0" cellspacing="5" cellpadding="5">
  <tr> 
    <td width="47%"> 
      <div align="right"> 
        <input type="button" class="button_style" name="save_button" value="  Save  "/>
      </div>
    </td>
	<td width="6%">
	</td>
    <td width="47%"> 
      <div align="left"> 
        <input type="button" class="button_style" name="cancel_button" value="Cancel"/>
      </div>
    </td>
  </tr>
</table>
</td>
  </tr>
</table>
</div>
</body>
</html>
