<div id="primary_header">
  <h1><?php print $this->translate('Mail Options')?></h1>
	<div id="back_button">
		<a href="#">
			<span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span>
		</a>
	</div>
</div>

<div id="back_button" class="savecontact">
	<a href="#">
		<span class="stronglastword"><?php print $this->translate('Save Settings')?></span>
	</a>
</div>


<div id="primary_content">
  <div id="primary_content_inner">
  <div id="Flash" class="flash_notice"><?php echo $this->translate('The settings have been updated') ?></div>

  <form id="settingsForm" method="post" action="<?php echo $this->moduleBaseUrl ?>/settings/mailsave">
    <input type="hidden" name="save" value="1" id="save" />
    <table class="settings">

      <tr>
        <td class="label"><label for="forwardCheckbox"><?php print $this->translate('Enable Forward')?></label></td>
        <td>
          <input type="checkbox" id='forwardCheckbox' name="enableForward" <?php echo ($this->UserSettings['Forward'] != '' ? 'checked' : '') ?> value="enabled">
          <small><?php print $this->translate('Check to forward your emails to another email address')?>.  <?php print $this->translate('Note that activating this feature will forward messages without storing them.')?></small>
        </td>
      </tr>

      <tr>
        <td class="label"><label id="forwardMailLabel" for="Forward"><?php print $this->translate('Forward mail')?></label></td>
        <td>
          <input type="text" class="medium" id="Forward" name="Forward" value="<?php echo $this->UserSettings['Forward'] ?>" />
          <small><?php print $this->translate('Optionally forward your email to another email account')?></small>
        </td>
      </tr>

	  </table>
	
	<div class='divider'/>

	<table class="settings">
      <tr>
        <td class="label"><label for="enableAutoReply"><?php print $this->translate('Enable Autoreply')?></label></td>
        <td>
          <input type="checkbox" id='enableAutoReply' name="enableAutoReply" <?php echo ($this->UserSettings['AutoReply'] != '' ? 'checked' : '') ?> value="enabled">
          <small><?php print $this->translate('Check to enable sending the Autoreply')?></small>
        </td>
      </tr>

      <tr>
        <td class="label"><label id="AutoReplyLabel" for="AutoReply"><?php print $this->translate('Autoreply message')?></label></td>
        <td>
          <textarea name="AutoReply" id="AutoReply"><?php echo $this->UserSettings['AutoReply'] ?></textarea>
          <small><?php print $this->translate('Optionally define an auto-reply / vacation message for your email account')?></small>
        </td>
      </tr>

    </table>
    <div class="bottomFormMainButtonArea" style="display:none;">
		<div id="back_button"><a href="#"><span class="stronglastword"><?php echo $this->translate('Save Settings') ?></span></a></div>
	</div>
	<br />
	<br />
	<br />
	
  </div>
  </form>


</div>

<script type="text/javascript">

$(function() 
{

	function editForward()	{
		if($("#forwardCheckbox", "#mailoptions").attr('checked') == true)	{
			$("#forwardMailLabel", "#mailoptions").fadeTo("slow", 1);
			$("#Forward", "#mailoptions").removeAttr("disabled");	
			$("#Forward", "#mailoptions").focus();
		} else {
			$("#forwardMailLabel", "#mailoptions").fadeTo("fast", 0.5);
			$("#Forward", "#mailoptions").attr("disabled","disabled");
			$("#save", "#mailoptions").focus();
		}
	}
	
	function editAutoReply()	{
		if($("#enableAutoReply", "#mailoptions").attr('checked') == true)	{
			$("#AutoReplyLabel", "#mailoptions").fadeTo("slow", 1);
			$("#AutoReply", "#mailoptions").removeAttr("disabled");	
			$("#AutoReply", "#mailoptions").focus();
		} else {
			$("#AutoReplyLabel", "#mailoptions").fadeTo("fast", 0.5);
			$("#AutoReply", "#mailoptions").attr("disabled","disabled");
			$("#save", "#mailoptions").focus();
		}
	}

	$("#forwardCheckbox", "#mailoptions").change( function() { editForward() });
	$("#enableAutoReply", "#mailoptions").change( function() { editAutoReply() });
	
	// bind to the form's submit event and cancel legacy submit 
    $('#settingsForm', "#mailoptions").submit(function() {   
	    $("#Flash", "#mailoptions").hide();
		$.php($("#settingsForm", '#mailoptions').attr("action"),$("#settingsForm", "#mailoptions").serializeArray());
		return false; 
    });

    $('#back_button a', '#mailoptions').bind("click", function() { return $('#settingsForm', "#mailoptions").submit()})

	editAutoReply();
	editForward();
    
    $('#Settings :checkbox').iphoneStyle();

	$('.stronglastword').each( function() { $(this).stronglastword() });

});

</script>