<?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_value(value) ?>
  <?cs if:modify ?>value="<?cs var:value ?>"<?cs /if ?>
<?cs /def ?>




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




<?cs def:print_color() ?>
  <?cs if:modify ?>value="<?cs var:data.steps_bgcolor ?>" <?cs else ?>value="#FFFFFF" <?cs /if ?>
<?cs /def ?>




<?cs def:print_form_action() ?>
  <?cs if:modify ?>
    <form  method="post" action="survey_title_modify"  onsubmit="return alertfunc('<?cs var:lang.survey_new_form.no_blank_fields ?>', '<?cs var:lang.survey_new_form.color_warn ?>', '<?cs var:lang.survey_new_form.only_letters_allowed ?>')">
   <?cs else ?>
    <form  method="post" action="survey_title_save"  onsubmit="return alertfunc('<?cs var:lang.survey_new_form.no_blank_fields ?>', '<?cs var:lang.survey_new_form.color_warn ?>', '<?cs var:lang.survey_new_form.only_letters_allowed ?>')">
    <?cs /if ?>
<?cs /def ?>





<?cs def:print_back_button() ?> 
 <?cs if:modify ?>
 <div>
  <a href="javascript:history.back()" title="back"><img src="<?cs var:image_path ?>back_arrow.gif" width="50" height="34" alt="Go Back" /></a>
</div>
 <?cs /if ?>
<?cs /def ?>


<?cs def:print_instructions() ?>
<hr />
<div class="menu_entry">
  <span class="regheading"><?cs var:lang.survey_new_form.survey_name_label ?></span>
  </div>

  <div class="menu_entry_desc">
  <span class="menu_desc"><?cs var:lang.survey_new_form.survey_name_instructions ?></span>
  </div>

<p/>

<div class="menu_entry">
  <span class="regheading"><?cs var:lang.survey_new_form.survey_heading_label ?></span>
  </div>

  <div class="menu_entry_desc">
  <span class="menu_desc"><?cs var:lang.survey_new_form.survey_heading_instructions ?></span>
  </div>

<p />
<div class="menu_entry">
  <span class="regheading"><?cs var:lang.survey_new_form.bg_color_label ?></span>
  </div>

  <div class="menu_entry_desc">
  <span class="menu_desc"><?cs var:lang.survey_new_form.bg_color_instructions ?></span>
  </div>


<?cs /def ?>


<?cs call:html_heading() ?> 
<head>
   <title><?cs var:lang.survey_new_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>
   <script type="text/javascript">

   function alertfunc(alertstring, color_alert, only_letters_allowed)
   {
     var link_value = document.getElementById('link').value;
     var title_value = document.getElementById('title').value;
     var color_value = document.getElementById('color').value;
     if( is_whitespace(link_value) || is_whitespace(title_value) || is_whitespace(color_value))
     {
         window.alert(alertstring);
            return false;
     }
     else if(bad_char(link_value) == false) 
     {
         window.alert(only_letters_allowed);
            return false;
     } 
     else if(!check_color(color_value))
     {
         window.alert(color_alert);
            return false;
     }

    else 
       return true;
   }
   </script>
   <script type="text/javascript" src="<?cs var:image_path ?>ColorPicker2.js"></script>
   <script type="text/javascript" src="<?cs var:image_path ?>AnchorPosition.js"></script>
   <script type="text/javascript" src="<?cs var:image_path ?>PopupWindow.js"></script>
   <script type="text/javascript">
     var cp = new ColorPicker('window');
   </script>
   <?cs call:print_spelling() ?>
  </head>

<?cs call:define_onload_body("link") ?>  <?cs # util.cs # ?> 
<?cs call:print_back_button() ?> 
 <div>
   <?cs call:print_form_action() ?>  
   <div>
       <input type="hidden" name="admin" value="<?cs var:Query.admin ?>" />
       <input type="hidden" name="id" value="<?cs var:Query.id ?>" />
       <?cs if:modify ?>
       <input type="hidden" name="count" value="<?cs var:Query.count ?>" />
       <input type="hidden" name="pre_id" value="<?cs var:Query.pre_id ?>" />
       <?cs /if ?>
   </div>

<fieldset style="width:75%">
<legend class="fieldset_legend">
   <?cs var:lang.survey_new_form.page_title ?>
</legend>

<table border="0" cellpadding="5" cellspacing="3">
   <tr>
    <td align="right" class="regheading"><?cs var:lang.survey_new_form.survey_name_label ?></td>

 
    <?cs # note that the maxlength of the next text input area has been set to '50' rather than
           max_link_title (i.e. 200) supplied by the hdf data set
     ?>

          
    <td><input type="text" name="link" id="link" maxlength="50" title="<?cs var:lang.survey_new_form.survey_name_help ?>" <?cs call:print_value(data.left_cols) ?> /></td>
  </tr>
  <tr>
    <td align="right" class="regheading">
       <?cs var:lang.survey_new_form.survey_heading_label ?> <span class="normal"></span>:
   </td>
  <td>
   <table>
    <tr><td>&nbsp;&nbsp;</td>
     <?cs if:check_spelling ?>
    <td align="right">
      <input type="button" value="<?cs var:lang.survey_new_form.check_spelling ?>" title="<?cs var:lang.survey_new_form.check_spelling_help ?>" onclick="openSpellChecker( document.forms[0].title );" />
    </td>
    <?cs else ?>
     <td>&nbsp;</td>
    <?cs /if ?>
   </tr>
    <tr><td colspan="2">
    <?cs call:print_text_value(data) ?>
    </td></tr>
   </table>
  </td>
  </tr> 
  <tr>
  <td align="right" class="regheading"><?cs var:lang.survey_new_form.bg_color_label ?></td>
  <td>
    <input type="text" size="8" name="color" id="color" maxlength="8" title="<?cs var:lang.survey_new_form.bg_color_help ?>" <?cs call:print_color() ?> />
    <a href="#" onclick="cp.select(document.forms[0].color, 'pick'); return false;" name="pick" id="pick"  title="<?cs var:lang.survey_new_form.color_chooser_help ?>" ><?cs var:lang.survey_new_form.color_chooser ?></a>
  </td>
 </tr>
 <tr><td colspan="2" align="center">
 <input type="submit" value="<?cs var:lang.survey_new_form.submit_button ?>" title="<?cs var:lang.survey_new_form.submit_button_help ?>" />
 </td></tr>
  </table>
</fieldset>
  </form>
</div>
<?cs call:print_instructions() ?>
</body>
</html>
<?cs call:runtime() ?>    <?cs # util.cs ?>
