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

<?cs def:button_layout(element) ?>
  <form action="<?cs var:element.modify_program ?>">
  <div class="button_block">
   <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:element.id ?>" /> 
  </div>
  <div class="button_block">
   <input type="submit" name="modify"  value="<?cs var:lang.survey_new.modify_button ?>" title="<?cs var:lang.survey_new.modify_button_help ?>"  />
   <input type="submit" name="add" value="<?cs var:lang.survey_new.add_below_button ?>" title="<?cs var:lang.survey_new.add_below_button_help ?>" />
   <?cs if:element.type != "heading" ?>
   <input type="button" name="delete" value="<?cs var:lang.survey_new.delete_button ?>" title="<?cs var:lang.survey_new.delete_button_help ?>" onclick="confirm_delete(<?cs var:element.id ?>)"   />
   <input type="submit" name="copy" value="<?cs var:lang.survey_new.copy_button ?>" title="<?cs var:lang.survey_new.copy_button_help ?>" />
   <input type="submit" name="cut" value="<?cs var:lang.survey_new.cut_button ?>" title="<?cs var:lang.survey_new.cut_button_help ?>" />
  <?cs /if ?>
  <?cs if:has_clipboard ?>
    <input type="submit" name="paste" value="<?cs var:lang.survey_new.paste_button ?>" title="<?cs var:lang.survey_new.paste_button_help ?>" />
  <?cs else ?>
    [<span class="button_fade"><?cs var:lang.survey_new.paste_button ?></span>]
  <?cs /if ?>
  </div>
 </form>
<?cs /def ?>
  


<?cs def:set_background_color(id) ?>
 <?cs if:id == Query.target ?>style="background-color:#FFFFCC" <?cs /if ?>
<?cs /def ?>


<?cs def:print_title(element) ?>
 <fieldset <?cs call:set_background_color(element.id) ?> >
 <legend class="fieldset_legend" >
     <?cs var:lang.survey_new.heading_legend ?>
 </legend>
 <div >
   <div><?cs var:element.content ?></div>
   <div><b><?cs var:lang.survey_new.bgcolor_label ?></b>
    <span  style="background-color:<?cs var:element.chosen_bgcolor ?>"><?cs var:element.chosen_bgcolor ?></span>
   </div>
   <div> <?cs call:button_layout(element) ?></div>
 </div>
 </fieldset>
<?cs /def ?>





<?cs def:print_likert(element) ?>
 <a name="<?cs var:element.id ?>"></a>
 <fieldset <?cs call:set_background_color(element.id) ?>>
 <legend class="fieldset_legend" >
     <?cs var:lang.survey_new.likert_legend ?>
 </legend>
 <div>
   <div><?cs var:element.content ?></div>
   <div>
    <form action="">
    <div>
     <?cs var:element.left_value ?>
       <?cs loop:x = #1, element.steps, #1 ?>
         <input type="radio" />
       <?cs /loop ?>
     <?cs var:element.right_value ?>
    </div>
    </form>
   </div>
   <?cs call:button_layout(element) ?>
</div>
</fieldset >
<?cs /def ?>





<?cs def:print_memo(element) ?>
  <a name="<?cs var:element.id ?>"></a>
 <fieldset <?cs call:set_background_color(element.id) ?>>
 <legend class="fieldset_legend" >
     <?cs var:lang.survey_new.memo_legend ?>
 </legend>
 <div>
   <div><?cs var:element.content ?></div>
   <div>
    <form action="">
     <div><textarea cols="<?cs var:element.cols ?>" rows="<?cs var:element.rows ?>"></textarea></div>
    </form>
   </div>
   <?cs call:button_layout(element) ?>
 </div>
</fieldset>
<?cs /def ?>





<?cs def:print_text(element) ?>
 <a name="<?cs var:element.id ?>"></a>
 <fieldset <?cs call:set_background_color(element.id) ?>>
 <legend class="fieldset_legend" >
     <?cs var:lang.survey_new.text_legend ?>
 </legend>
 <div>  
   <div><?cs var:element.content ?></div>
   <div>
    <form action="">
     <div><input type="text" /></div>
    </form>
   </div>
   <div> <?cs call:button_layout(element) ?></div>
 </div>
</fieldset>
<?cs /def ?>





<?cs def:print_custom(element) ?>
  <a name="<?cs var:element.id ?>"></a>
 <fieldset <?cs call:set_background_color(element.id) ?>>
 <legend class="fieldset_legend" >
     <?cs var:lang.survey_new.custom_legend ?>
 </legend>
 <div>
   <div><?cs var:element.content ?></div>
   <div> <?cs call:button_layout(element) ?></div>
 </div>
</fieldset>
<?cs /def ?>




<?cs def:print_multi_choice(element) ?>
  <a name="<?cs var:element.id ?>"></a>
 <fieldset <?cs call:set_background_color(element.id) ?>>
 <legend class="fieldset_legend" >
     <?cs var:lang.survey_new.multi_choice_legend ?>
 </legend>
 <div>
   <div><?cs var:element.content ?></div>
   <form action="">
      <table>
     <?cs each:mychoice = element.choice ?>
       <?cs if:element.multi == "yes" ?> 
        <tr><td><input type="checkbox" /></td><td><?cs var:mychoice ?></td></tr>
       <?cs else ?>
        <tr><td><input type="radio" /></td><td><?cs var:mychoice ?></td></tr>
       <?cs /if ?>
     <?cs /each ?>
     </table>
  </form>
   <?cs call:button_layout(element) ?>
 </div>
</fieldset>
<?cs /def ?>






<?cs def:print_end_session() ?>
   <div><form action="">
    <div><input type="button" onclick="reload_parent_and_close()"  value="<?cs var:lang.survey_new.end_session ?>" title="<?cs var:lang.survey_new.end_session_help ?>" /></div>
   </form>
   </div>
<?cs /def ?>
 



<?cs call:html_heading() ?>
   <head>
      <title><?cs var:lang.survey_new.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">

   function confirm_delete(id)
   {
     if(window.confirm('<?cs var:lang.survey_new.delete_confirm ?>'))
      {
      var delete_program = "survey_delete_tag?admin=<?cs var:Query.admin ?>&id=<?cs var:Query.id ?>&count=<?cs var:Query.count ?>&pre_id=" + id ;
      window.location = delete_program;
      }
   }


   function reload_parent_and_close()
   {
      opener.location.reload();
      window.close();
      opener.focus();
   }
   </script>
</head>

<?cs call:define_body() ?>

<?cs call:print_end_session() ?>

 <?cs each element = item ?>
    <?cs if:element.type == "heading" ?> 
      <?cs call:print_title(element) ?>
    <?cs elif:element.type == "multi-choice" ?>
      <?cs call:print_multi_choice(element) ?>
    <?cs elif:element.type == "likert" ?>
      <?cs call:print_likert(element) ?>
    <?cs elif:element.type == "memo" ?>
      <?cs call:print_memo(element) ?>
    <?cs elif:element.type == "short-answer" ?>
      <?cs call:print_text(element) ?>
    <?cs elif:element.type == "custom" ?>
      <?cs call:print_custom(element) ?>
   <?cs /if ?>
 <?cs /each ?>
</body>
</html>
<?cs call:runtime() ?>
