<?xml version="1.0"?> 

<!--
   The contents of this file are subject to the Netscape Public
   License Version 1.1 (the "License"); you may not use this file
   except in compliance with the License. You may obtain a copy of
   the License at http://www.mozilla.org/NPL/
    
   implied. See the License for the specific language governing
   rights and limitations under the License.
    
   The Original Code is Mozilla Communicator client code, released
   March 31, 1998.
   
   The Initial Developer of the Original Code is Netscape
   Communications Corporation. Portions created by Netscape are
   Copyright (C) 1998-1999 Netscape Communications Corporation. All
   Rights Reserved.
   
   Contributor(s): 
  -->
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>
<?xml-stylesheet href="chrome://communicator/skin/dialogOverlay.css" type="text/css"?>

<!DOCTYPE window SYSTEM "chrome://communicator/locale/pref/pref-advanced.dtd" >

<window xmlns:html="http://www.w3.org/1999/xhtml"
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
        class="color-dialog"
        orient="vertical"
        onload="parent.initPanel(panel);">

  <script type="application/x-javascript">
  <![CDATA[
    var panel = "chrome://communicator/content/pref/pref-advanced.xul";
    var _elementIDs = ["advancedJavaAllow", "javascriptEnabled", "advancedMailFTP", "advancedMailFTPAddress",
		"enableTurbo"];
    
    function Startup()
    {
      ftpCheck();
	  turboCheck();
    }   
    
    function ftpCheck()
    {
      var checked = document.getElementById("advancedMailFTP").checked;
      var field = document.getElementById("advancedMailFTPAddress");
      field.disabled = !checked;
      if (checked)
        field.focus();
    }

	/* 
	 * Name: turboCheck()
	 * 
	 * Arguments: none
	 *
	 * Description: This function is called when the root advanced prefs panel
	 * is loaded. The turbo mode setting is not exactly a preference -- setting
	 * the checkbox should (on leaving the prefs with an "Ok") result in a call
	 * to the backend to do the necessary win32 registry twiddling needed for
	 * turbo mode to go into affect. Clearing it should undo this work. We need
	 * to call the backend to determine if turbo mode is enabled (since we are 
	 * required to check for it in a non-trivial way) and then explicitly set the
	 * checkbox here based on what we find. Finally, we have to hide the checkbox
	 * (and the group box that frames it) if we are not executing on a Win32 
	 * platform.
	 *
	 * Return Value: void
	 *
	 * Original Code: syd@netscape.com 6/8/2001
	 *
	*/

    function turboCheck()
    {
      var aframe = document.getElementById("perfSettings");
      var abox = document.getElementById("perfLabel");
      var alabel = document.getElementById("perfBox");
      var acheckbox = document.getElementById("enableTurbo");
  	  if ( navigator.platform != "Win32" ) {
		aframe.setAttribute( "style", "visibility: hidden" );
		return;
	  }
	  else 
		aframe.setAttribute( "style", "visibility: visible" );

	  /* find out what the setting should be and reflect it in the UI */

	  try {
		hooks = Components.classes["@mozilla.org/winhooks;1"];
		if ( hooks ) {
			hooks = hooks.getService(Components.interfaces.nsIWindowsHooks);
		}
		if ( hooks ) {
			var isEnabled = hooks.isStartupTurboEnabled();
			if ( isEnabled == true ) {
				acheckbox.setAttribute( "checked", true );
			}
			else {
				acheckbox.setAttribute( "checked", false );
			}
		}
	  } catch( ex ) {
	  }

	  parent.hPrefWindow.registerOKCallbackFunc( saveTurboSetting );
    }

	/* 
	 * Name: saveTurboSetting()
	 * 
	 * Arguments: none
	 *
	 * Description: This function is called when the user hits the OK button in
	 * the preferences panel. The function determines what the turbo "preference" 
	 * setting is and performs the appropriate action to enable or disable turbo mode.
	 *
	 * Return Value: void
	 *
	 * Original Code: syd@netscape.com 6/9/2001
	 *
	*/

	function saveTurboSetting()
	{
  	  if ( navigator.platform != "Win32" ) {
		return;   
	  }

      var acheckbox = document.getElementById("enableTurbo");
	  try {
		hooks = Components.classes["@mozilla.org/winhooks;1"];
		if ( hooks ) {
			hooks = hooks.getService(Components.interfaces.nsIWindowsHooks);
		}
		if ( hooks ) {
			var isEnabled = acheckbox.checked;
			if ( isEnabled == true ) {
				hooks.startupTurboEnable();
			}
			else {
				hooks.startupTurboDisable();
			}
		}
	  } catch( ex ) {
	  }
	}
    
  ]]>
  </script>

  <hbox class="box-smallheader" title="&lHeader;"/>

  <groupbox orient="vertical" id="advancedSettings">
    <label value="&advancedTitle.label;"/>
    <vbox autostretch="never" id="contentEnablingBox">
      <checkbox id="advancedJavaAllow" label="&enbJavaCheck.label;" accesskey="&enbJavaCheck.accesskey;"
                pref="true" preftype="bool" prefstring="security.enable_java"
                prefattribute="checked"/>
      <checkbox id="javascriptEnabled" label="&enbJsCheck.label;" accesskey="&enbJsCheck.accesskey;"
                pref="true" preftype="bool" prefstring="javascript.enabled"
                prefattribute="checked"/>
    </vbox>
    <vbox>
      <separator/>
      <html>&description.label;</html>
      <separator/>
    </vbox>
    <vbox autostretch="never">
      <checkbox id="advancedMailFTP" label="&sendAddFtpCheck.label;" accesskey="&sendAddFtpCheck.accesskey;"
                pref="true" preftype="bool" prefstring="advanced.mailftp"
                prefattribute="checked" oncommand="ftpCheck();"/>
    </vbox>
    <hbox class="indent">
      <textbox id="advancedMailFTPAddress"
                 pref="true" preftype="string" prefstring="network.ftp.anonymous_password"
                 prefattribute="value" flex="2"/>
      <spring flex="1"/>
    </hbox>
    <separator/>
  </groupbox>
  <groupbox orient="vertical" id="perfSettings">
   <label id="perfLabel" value="&perfTitle.label;"/>
    <vbox id="perfBox" autostretch="never">
      <checkbox id="enableTurbo" label="&enableTurbo.label;" accesskey="&enableTurboCheck.accesskey;"/>
    </vbox>
  </groupbox>
  
</window>


