<mt:setvarblock name="page_title"><__trans phrase="Create Your First Website"></mt:setvarblock>
<mt:setvar name="complete" value="1">
<mt:include name="include/chromeless_header.tmpl">

<div class="upgrade">
  <div id="warning_gone"<mt:if name="version_warning"> style="display:none;"</mt:if>>
    <p class="intro"><__trans phrase="In order to properly publish your website, you must provide Movable Type with your website's URL and the filesystem path where its files should be published."></p>
  <mt:if name="error">
    <mtapp:statusmsg
       id="setup-website-error"
       class="error"
       can_close="0">
      <mt:var name="error">
    </mtapp:statusmsg>
  </mt:if>

    <form id="website_form" method="post" action="<mt:var name="script_url">">
      <input type="hidden" name="__mode" value="init_website" />
      <input type="hidden" name="finish" value="0" />
      <input type="hidden" name="back" value="0" />
      <input type="hidden" name="config" value="<mt:var name="config" escape="html">" />

      <mtapp:setting
         id="website_name"
         label="<__trans phrase="Website Name">"
         label_class="top-label">
        <input type="text" id="website_name" class="text full required" name="website_name" value="<mt:if name="website_name"><mt:var name="website_name" escape="html"><mt:else><__trans phrase="My First Website"></mt:if>" />
      </mtapp:setting>

      <mtapp:setting
         id="website_url"
         label="<__trans phrase="Website URL">"
         label_class="top-label">
        <input type="text" id="website_url" class="text full required" name="website_url" value="<mt:if name="website_url"><mt:var name="website_url" escape="html"></mt:if>" />
      </mtapp:setting>

      <mtapp:setting
         id="website_path"
         label="<__trans phrase="Website Root">"
         label_class="top-label">
        <input type="text" id="website_path" class="text full required" name="website_path" value="<mt:if name="website_path"><mt:var name="website_path" escape="html"></mt:if>" />
        <p class="hint"><__trans phrase="The 'Website Root' is the directory in your web server's filesystem where Movable Type will publish the files for your website. The web server must have write access to this directory."></p>
      </mtapp:setting>

    <mt:if name="theme_index">
      <mtapp:setting
         id="website_theme"
         label="<__trans phrase="Theme">"
         hint="<__trans phrase="Select the theme you wish to use for this new website.">"
         label_class="top-label">
        <select name="website_theme">
        <mt:loop name="theme_loop">
          <option value="<mt:var name="key" escape="html">"<mt:if name="website_theme"><mt:if name="key" eq="$website_theme"> selected="selected"</mt:if><mt:else><mt:if name="key" eq="$config.DefaultWebsiteTheme"> selected="selected"</mt:if></mt:if>><mt:var name="label" escape="html"></option>
        </mt:loop>
        </select>
      </mtapp:setting>
    </mt:if>

      <mtapp:setting
         id="website_timezone"
         label="<__trans phrase="Time Zone">"
         label_class="top-label"
         hint="<__trans phrase="Select your timezone from the pulldown menu.">">
        <select name="website_timezone" id="website_timezone" class="se">
          <option value=""><__trans phrase="Time zone not selected"></option>
          <option value="13"<mt:if name="WEBSITE_TIMEZONE_13"> selected="selected"</mt:if>><__trans phrase="UTC+13 (New Zealand Daylight Savings Time)"></option>
          <option value="12"<mt:if name="WEBSITE_TIMEZONE_12"> selected="selected"</mt:if>><__trans phrase="UTC+12 (International Date Line East)"></option>
          <option value="11"<mt:if name="WEBSITE_TIMEZONE_11"> selected="selected"</mt:if>><__trans phrase="UTC+11"></option>
          <option value="10"<mt:if name="WEBSITE_TIMEZONE_10"> selected="selected"</mt:if>><__trans phrase="UTC+10 (East Australian Time)"></option>
          <option value="9.5"<mt:if name="WEBSITE_TIMEZONE_9_5"> selected="selected"</mt:if>><__trans phrase="UTC+9.5 (Central Australian Time)"></option>
          <option value="9"<mt:if name="WEBSITE_TIMEZONE_9"> selected="selected"</mt:if>><__trans phrase="UTC+9 (Japan Time)"></option>
          <option value="8"<mt:if name="WEBSITE_TIMEZONE_8"> selected="selected"</mt:if>><__trans phrase="UTC+8 (China Coast Time)"></option>
          <option value="7"<mt:if name="WEBSITE_TIMEZONE_7"> selected="selected"</mt:if>><__trans phrase="UTC+7 (West Australian Time)"></option>
          <option value="6.5"<mt:if name="WEBSITE_TIMEZONE_6_5"> selected="selected"</mt:if>><__trans phrase="UTC+6.5 (North Sumatra)"></option>
          <option value="6"<mt:if name="WEBSITE_TIMEZONE_6"> selected="selected"</mt:if>><__trans phrase="UTC+6 (Russian Federation Zone 5)"></option>
          <option value="5.5"<mt:if name="WEBSITE_TIMEZONE_5_5"> selected="selected"</mt:if>><__trans phrase="UTC+5.5 (Indian)"></option>
          <option value="5"<mt:if name="WEBSITE_TIMEZONE_5"> selected="selected"</mt:if>><__trans phrase="UTC+5 (Russian Federation Zone 4)"></option>
          <option value="4"<mt:if name="WEBSITE_TIMEZONE_4"> selected="selected"</mt:if>><__trans phrase="UTC+4 (Russian Federation Zone 3)"></option>
          <option value="3.5"<mt:if name="WEBSITE_TIMEZONE_3_5"> selected="selected"</mt:if>><__trans phrase="UTC+3.5 (Iran)"></option>
          <option value="3"<mt:if name="WEBSITE_TIMEZONE_3"> selected="selected"</mt:if>><__trans phrase="UTC+3 (Baghdad Time/Moscow Time)"></option>
          <option value="2"<mt:if name="WEBSITE_TIMEZONE_2"> selected="selected"</mt:if>><__trans phrase="UTC+2 (Eastern Europe Time)"></option>
          <option value="1"<mt:if name="WEBSITE_TIMEZONE_1"> selected="selected"</mt:if>><__trans phrase="UTC+1 (Central European Time)"></option>
          <option value="0"<mt:if name="WEBSITE_TIMEZONE_0"> selected="selected"</mt:if>><__trans phrase="UTC+0 (Universal Time Coordinated)"></option>
          <option value="-1"<mt:if name="WEBSITE_TIMEZONE__1"> selected="selected"</mt:if>><__trans phrase="UTC-1 (West Africa Time)"></option>
          <option value="-2"<mt:if name="WEBSITE_TIMEZONE__2"> selected="selected"</mt:if>><__trans phrase="UTC-2 (Azores Time)"></option>
          <option value="-3"<mt:if name="WEBSITE_TIMEZONE__3"> selected="selected"</mt:if>><__trans phrase="UTC-3 (Atlantic Time)"></option>
          <option value="-3.5"<mt:if name="WEBSITE_TIMEZONE__3_5"> selected="selected"</mt:if>><__trans phrase="UTC-3.5 (Newfoundland)"></option>
          <option value="-4"<mt:if name="WEBSITE_TIMEZONE__4"> selected="selected"</mt:if>><__trans phrase="UTC-4 (Atlantic Time)"></option>
          <option value="-5"<mt:if name="WEBSITE_TIMEZONE__5"> selected="selected"</mt:if>><__trans phrase="UTC-5 (Eastern Time)"></option>
          <option value="-6"<mt:if name="WEBSITE_TIMEZONE__6"> selected="selected"</mt:if>><__trans phrase="UTC-6 (Central Time)"></option>
          <option value="-7"<mt:if name="WEBSITE_TIMEZONE__7"> selected="selected"</mt:if>><__trans phrase="UTC-7 (Mountain Time)"></option>
          <option value="-8"<mt:if name="WEBSITE_TIMEZONE__8"> selected="selected"</mt:if>><__trans phrase="UTC-8 (Pacific Time)"></option>
          <option value="-9"<mt:if name="WEBSITE_TIMEZONE__9"> selected="selected"</mt:if>><__trans phrase="UTC-9 (Alaskan Time)"></option>
          <option value="-10"<mt:if name="WEBSITE_TIMEZONE__10"> selected="selected"</mt:if>><__trans phrase="UTC-10 (Aleutians-Hawaii Time)"></option>
          <option value="-11"<mt:if name="WEBSITE_TIMEZONE__11"> selected="selected"</mt:if>><__trans phrase="UTC-11 (Nome Time)"></option>
        </select>
      </mtapp:setting>

      <div class="actions-bar">
        <button
           id="finish_button"
           name="finish_button"
           value="finish"
           type="submit"
           accesskey="s"
           title="<__trans phrase="Finish install (s)">"
           class="action primary button">
          <__trans phrase="Finish install">
        </button>
        <button
           id="back_button"
           name="back_button"
           value="back"
           type="submit"
           accesskey="x"
           title="<__trans phrase="Back (x)">"
           class="goback action button">
          <__trans phrase="Back">
        </button>
      </div>

    </form>
  </div>
</div>

<script type="text/javascript">
/* <![CDATA[ */
<mt:if name="website_timezone" eq="">
function init() {
    var tz = jQuery('#website_timezone')[0];
    if (tz) {
        // The options ignore DST, so check at a specific time when no one was on DST.
        var offset = (new Date(2008, 0, 1, 0, 0, 0, 0)).getTimezoneOffset();
        tz.value = 0 - offset / 60;
    }
}
</mt:if>

function dismiss(id) {
    jQuery('#'+id).hide();
}

function show(id) {
    jQuery('#'+id).show();
}

jQuery(function() {
<mt:if name="website_timezone" eq="">
    init();
</mt:if>
    jQuery('button#finish_button').click(function() {
        jQuery('#website_form > input[name=back]').val('0');
        jQuery('#website_form > input[name=finish]').val('1');
        jQuery('#website_form').submit();
    });
    jQuery('button#back_button').click(function() {
        jQuery('#website_form > input[name=back]').val('1');
        jQuery('#website_form > input[name=finish]').val('0');
        jQuery('#website_form').submit();
    });
    jQuery('#website_form').submit( function () {
        if ( jQuery('#website_form > input[name=back]').val() > 0 ) return true;
        return jQuery(this).find('input, select').mtValidate('simple') ? true : false;
    });

    function is_valid_url(url_){
        if (url_.indexOf(' ') != -1) {
            return false;
        }
        return url_.match( /^https?:\/\/[A-Za-z0-9!$%()=_.:,;@~-]+/ );
    }

    function is_valid_path(path_){
        var str = path_.replace(/[ "%<>\[\\\]\^`{\|}~]/g, "");
        str = encodeURI(str);
        if (str.indexOf('%') != -1) {
            return false;
        }
        if (str.match(/\.\./)) {
            return false;
        }
        return true;
    }

    jQuery.mtValidateAddRules({
        '#website_url': function ($e) {
            return is_valid_url($e.val()) ? true : false;
        },
        '#website_path': function ($e) {
            return is_valid_path($e.val()) ? true : false;
        },
        '#website_timezone': function ($e) {
            return $e.val() !== '';
        }
    });

    jQuery.mtValidateAddMessages({
        '#website_name': '<__trans phrase="The website name is required." escape="singlequotes">',
        '#website_url.required': '<__trans phrase="The website URL is required." escape="singlequotes">',
        '#website_url#website_url': '<__trans phrase="Your website URL is not valid." escape="singlequotes">',
        '#website_path.required': '<__trans phrase="The publishing path is required." escape="singlequotes">',
        '#website_path#website_path': '<__trans phrase="You must set a valid Local Site Path." escape="singlequotes">',
        '#website_timezone': '<__trans phrase="The timezone is required." escape="singlequotes">'
    });

});
/* ]]> */
</script>
<mt:include name="include/chromeless_footer.tmpl">
