<?cs include:"util.cs" ?>

<?cs def:print_spelling() ?>
   <?cs if:check_spelling ?>
   <script type="text/javascript" src="<?cs var:server_name ?><?cs var:image_path ?>spellChecker.js"></script>
   <script type="text/javascript">
     function openSpellChecker(txt) {
     var speller = new spellChecker( txt,'<?cs var:server_name ?><?cs var:image_path ?>spellchecker.html','<?cs var:server_name ?>/<?cs var:bin_alias ?>/spellchecker' );
    speller.openChecker();
    }
  </script>
 <?cs /if ?>
<?cs /def ?>


<?cs def:print_text_value(data) ?>
  <?cs if:modify || delete ?>
   <textarea name="caption" id="caption" cols="40" rows="4" title="<?cs var:lang.shared_survey_form.question_help ?>" ><?cs var:data.caption ?></textarea>
  <?cs else ?>
   <textarea name="caption" id="caption" cols="40" rows="4" title="<?cs var:lang.shared_survey_form.question_help ?>"></textarea>
  <?cs /if ?>
<?cs /def ?>


<?cs def:print_action(m_action, s_action) ?>
  <?cs if:modify ?>
    <form  method="post" action="<?cs var:m_action ?>"  onsubmit="return alertfunc('<?cs var:lang.shared_survey_form.warning_msg ?>')">
   <?cs elif:delete ?>
    <form  method="post" action="survey_delete_tag"  onsubmit="return window.confirm('<?cs var:lang.shared_survey_form.delete_warning ?>')">
   <?cs else ?>
    <form  method="post" action="<?cs var:s_action ?>"  onsubmit="return alertfunc('<?cs var:lang.shared_survey_form.warning_msg ?>')">
    <?cs /if ?>
<?cs /def ?>


<?cs def:print_back_button() ?> 
 <div>
  <a href="survey_new?admin=<?cs var:Query.admin ?>&amp;id=<?cs var:Query.id ?>&amp;count=<?cs var:Query.count ?><?cs if:data.id ?>&amp;target=<?cs var:data.id ?>#<?cs var:data.id ?><?cs elif:Query.pre_id ?>&amp;target=<?cs var:Query.pre_id ?>#<?cs var:Query.pre_id ?><?cs /if ?>" title="<?cs var:lang.shared_survey_form.back_button_title ?>"><img src="<?cs var:image_path ?>back_arrow.gif" width="50" height="34" alt="<?cs var:lang.shared_survey_form.back_button_title ?>" /></a>
</div>
<?cs /def ?>


<?cs def:print_fade_button(tag) ?>
  <div class="button_fade">[<?cs var:tag ?>]</div>
<?cs /def ?>


<?cs def:print_real_button(tag_name, action) ?> 
  <form method="post" action="<?cs var:action ?>"  onsubmit="return abandonfunc()">
     <div><input type="hidden" name="admin" value="<?cs var:Query.admin ?>" /> 
      <input type="hidden" name="id" value="<?cs var:Query.id ?>" /> 
      <input type="hidden" name="count" value="<?cs var:Query.count ?>" /> 
      <input type="hidden" name="pre_id" value="<?cs var:Query.pre_id ?>" /> 
      <input type="submit" name="submit" value="<?cs var:tag_name ?>" title="<?cs var:tag_name ?>" />
    </div>
  </form>
<?cs /def ?>

<?cs def:print_buttons() ?>
<table width="100%">
<tr><td align="center">

  <div class="center_msg"><?cs var:lang.shared_survey_form.select_question_prompt ?></div>
  <table><tr>
    <td><?cs call:print_real_button(lang.shared_survey_form.custom_button, "survey_custom_form") ?></td> 
    <td><?cs call:print_real_button(lang.shared_survey_form.likert_button, "survey_likert_form") ?></td>
    <td><?cs call:print_real_button(lang.shared_survey_form.choice_button, "survey_choice_form") ?></td> 
    <td><?cs call:print_real_button(lang.shared_survey_form.text_button, "survey_text_form") ?></td> 
    <td><?cs call:print_fade_button(lang.shared_survey_form.memo_button) ?></td>
  </tr></table>

</td></tr>
</table>
<?cs /def ?>

<?cs def:print_submit_button() ?>
      <?cs if:modify ?>
      <input type="submit" value="<?cs var:lang.shared_survey_form.modify_button ?>" title="<?cs var:lang.shared_survey_form.modify_button_help ?>" />
      <?cs elif:delete ?>
      <input type="submit" value="<?cs var:lang.shared_survey_form.delete_button ?>" title="<?cs var:lang.shared_survey_form.delete_button_help ?>" />
      <?cs else ?>
      <input type="submit" value="<?cs var:lang.shared_survey_form.submit_button ?>" title="<?cs var:lang.shared_survey_form.submit_button_help ?>" />
      <?cs /if ?>
<?cs /def ?>

<?cs def:print_select(name, start, step, end, set_value) ?>
 <select name="<?cs var:name ?>" title="<?cs var:lang.survey_memo_form.select_value ?>" >
   <?cs loop:x = start, end, step ?>
     <?cs if:x == end && !set_value ?>
       <option value="<?cs var:x ?>" selected="selected" ><?cs var:x ?></option>
     <?cs elif:x == set_value ?>
       <option value="<?cs var:x ?>" selected="selected" ><?cs var:x ?></option>
    <?cs else ?>
       <option value="<?cs var:x ?>" ><?cs var:x ?></option>
     <?cs /if ?>
   <?cs /loop ?>
 </select>
<?cs /def ?>

      
<?cs call:html_heading() ?> 
   <head>
      <title><?cs var:lang.survey_memo_form.page_title ?></title>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <link rel="StyleSheet" href="<?cs var:image_path ?>common.css" type="text/css"  />
   <link rel="StyleSheet" href="<?cs var:image_path ?>survey.css" type="text/css"  />
   <script type="text/javascript" src="<?cs var:image_path ?>form_validation.js"></script>
   <?cs if:!delete ?>
   <script type="text/javascript">
   function alertfunc(alertstring)
   {
     var value = document.getElementById('caption').value;
     if( is_whitespace(value) )
     {
         window.alert(alertstring);
            return false;
     }
    else 
       return true;
   }
    function  abandonfunc()
    {
       var value= document.getElementById('caption').value;
       if( is_whitespace(value) )
         return true;
       else
          return  window.confirm('<?cs var:lang.shared_survey_form.discard  ?>');
   }

   </script>
   <?cs /if ?>
   <?cs call:print_spelling() ?>
  </head>

<?cs call:define_onload_body("caption") ?>
 <?cs call:print_back_button() ?> 
<?cs if:!delete && !modify ?>
  <?cs call:print_buttons() ?>
<?cs /if ?>

<fieldset>
<legend class="fieldset_legend"><?cs var:lang.shared_survey_form.memo_button ?></legend>
<div class="instructions">
    <?cs var:lang.survey_memo_form.description ?>
</div>
</fieldset>





<table width="100%">
<tr><td align="center">
   <div>
   <?cs call:print_action("survey_memo_modify", "survey_memo_save") ?>  
   <div>
       <input type="hidden" name="admin" value="<?cs var:Query.admin ?>" />
       <input type="hidden" name="id" value="<?cs var:Query.id ?>" />
       <input type="hidden" name="count" value="<?cs var:Query.count ?>" />
       <input type="hidden" name="pre_id" value="<?cs var:Query.pre_id ?>" />
   </div>

  <table>
  <tr>
    <td class="regheading"><?cs var:lang.shared_survey_form.question_label ?></td>
    <?cs if:check_spelling ?>
          <td align="right"><input type="button" value="<?cs var:lang.shared_survey_form.check_spelling_button ?>" onclick="openSpellChecker( document.forms[<?cs if:modify ?>0<?cs else ?>4<?cs /if ?>].caption );" title="<?cs var:lang.shared_survey_form.check_spelling ?>" /></td>
     <?cs else ?>
          <td>&nbsp;</td>
     <?cs /if ?>
  </tr>
  <tr><td colspan="2">
      <?cs call:print_text_value(data) ?>
  </td></tr>
  <tr>
     <td class="regheading"><?cs var:lang.survey_memo_form.cols ?></td>
     <td><?cs call:print_select("cols", 30, 10, 70, data.left_cols) ?></td>
   </tr>
   <tr>
     <td class="regheading"><?cs var:lang.survey_memo_form.rows ?></td>
     <td><?cs call:print_select("rows", 3, 1, 7, data.right_rows) ?></td>
   </tr> 
  <tr><td colspan="2" align="center">
     <?cs call:print_submit_button() ?>
    </td></tr>
  </table>
 </form>
</div>
</td></tr></table>
</body></html>
<?cs call:runtime() ?>
