<div class="wrap">
  <div id="icon-options-general" class="icon32"><br/></div>

  <h2>CloudSwipe Settings</h2>

  <form action="" method="post">
    <?php wp_nonce_field('save_settings', 'cs_nonce'); ?>
    <input type="hidden" name="cs_task" value="admin_save_settings">

    <table class="form-table">
      <tr valign="top">
        <th scope="row"><label for="cs_public_key"><?php _e('CloudSwipe Public Key', 'cloudswipe'); ?></label></th>
        <td><input name="cs_settings[cs_public_key]" type="text" id="cs_public_key" value="<?php echo get_site_option('cs_public_key'); ?>" class="regular-text" /></td>
      </tr>
      <tr valign="top">
        <th scope="row"><label for="cs_secret_key"><?php _e('CloudSwipe Secret Key', 'cloudswipe'); ?></label></th>
        <td><input name="cs_settings[cs_secret_key]" type="text" id="cs_secret_key" value="<?php echo get_site_option('cs_secret_key'); ?>" class="regular-text" /></td>
      </tr>
      <tr valign="top">
        <th scope="row"><label for="cs_redirect_type"><?php _e('Add to cart redirect', 'cloudswipe'); ?></label></th>
        <td>
          <fieldset><legend class="screen-reader-text"><span><?php _e('After adding a product to the cart', 'cloudswipe'); ?></span></legend>
            <label title="stay">
              <input type="radio" name="cs_settings[cs_redirect_type]" id="cs_redirect_type_stay" value="stay" <?php echo $redirect_type  == 'stay' ? 'checked="checked"' : ''; ?>>
              <span><?php _e('Stay on same page', 'cloudswipe'); ?></span>
            </label>
            <br/>
            <label title="stay on same page with ajax add to cart">
              <input type="radio" name="cs_settings[cs_redirect_type]" id="cs_redirect_type_stay_ajax" value="stay_ajax" <?php echo $redirect_type  == 'stay_ajax' ? 'checked="checked"' : ''; ?>>
              <span><?php _e('Stay on same page with ajax add to cart', 'cloudswipe'); ?></span>
            </label>
            <br/>
            <label title="view cart">
              <input type="radio" name="cs_settings[cs_redirect_type]" id="cs_redirect_type_view_cart" value="view_cart" <?php echo $redirect_type  == 'view_cart' ? 'checked="checked"' : ''; ?>>
              <span><?php _e('Go to view cart page', 'cloudswipe'); ?></span>
            </label>
            <br/>
            <label title="checkout page">
              <input type="radio" name="cs_settings[cs_redirect_type]" id="cs_redirect_type_checkout" value="checkout" <?php echo $redirect_type  == 'checkout' ? 'checked="checked"' : ''; ?>>
              <span><?php _e('Go to checkout page', 'cloudswipe'); ?></span>
            </label>
          </fieldset>
          <p class="description"><?php _e('Where to direct the buyer after adding a product to the shopping cart', 'cloudswipe'); ?></p>
        </td>
      </tr>

      <tr>
        <th scope="row"><label for="cs_selected_page_template"><?php _e('Page template for CloudSwipe', 'cloudswipe'); ?></label></th>
        <td>
          <select name="cs_settings[cs_selected_page_template]" id="cs_settings_cs_selected_page_template">
            <?php foreach($templates as $file => $description): ?>
              <?php CS_Log::write('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Comparing file to selected page: file = $file :: $selected_page_template"); ?>
              <option value="<?php echo $file; ?>" <?php echo $file == $selected_page_template ? 'selected="selected"' : ''; ?>><?php echo $description; ?></option>
            <?php endforeach; ?>
          </select>
          <p class="description"><?php _e('Which page template would you like to use on CloudSwipe', 'cloudswipe'); ?></p>
        </td>
      </tr>

      <tr valign="top">
        <th scope="row"><label for="cs_logging"><?php _e('Enable logging', 'cloudswipe'); ?></label></th>
        <td>
          <fieldset><legend class="screen-reader-text"><span><?php _e('Enable logging', 'cloudswipe'); ?></span></legend>
            <label title="yes">
              <input type="radio" name="cs_settings[cs_logging]" id="cs_logging_yes" value="1" <?php echo $logging  == 1 ? 'checked="checked"' : ''; ?>>
              <span><?php _e('Yes', 'cloudswipe'); ?></span>
            </label>
            &nbsp;
            <label title="no">
              <input type="radio" name="cs_settings[cs_logging]" id="cs_logging_no" value="0" <?php echo $logging  == 0 ? 'checked="checked"' : ''; ?>>
              <span><?php _e('No', 'cloudswipe'); ?></span>
            </label>
          </fieldset>
          <p class="description"><?php _e('Enable logging of debug and error messages in the log.txt file of the cloudswipe plugin.', 'cloudswipe'); ?></p>
        </td>
      </tr>
    </table>

    <p class="submit"><input type="submit" name="submit" id="submit" class="button-primary" value="Save Changes"></p>
  </form>
</div>
