  <section class="section">
    <div class="step">
      <ul>
        <li class="on"><em>1</em>检测环境</li>
        <li class="current"><em>2</em>创建数据</li>
        <li><em>3</em>完成安装</li>
      </ul>
    </div>
    <form  action="?r=install&step=4" method="post">
      <input type="hidden" name="force" value="0" />
      <div class="server">
        <table width="100%">
          <tr>
            <td class="td1" width="100">数据库信息</td>
            <td class="td1" width="200">&nbsp;</td>
            <td class="td1">&nbsp;</td>
          </tr>
		  <tr>
            <td class="tar">数据库服务器：</td>
            <td><input type="text" name="dbhost" id="dbhost" value="localhost" class="input"></td>
            <td><div id="dbhost_tip"><span class="gray">数据库服务器地址，一般为localhost</span></div></td>
          </tr>
		  <tr>
            <td class="tar">数据库端口：</td>
            <td><input type="text" name="dbport" id="dbport" value="3306" class="input"></td>
            <td><div id="dbport_tip"><span class="gray">数据库服务器端口，一般为3306</span></div></td>
          </tr>
          <tr>
            <td class="tar">数据库用户名：</td>
            <td><input type="text" name="dbuser" id="dbuser" value="root" class="input"></td>
            <td><div id="dbuser_tip"></div></td>
          </tr>
          <tr>
            <td class="tar">数据库密码：</td>
            <td><input type="text" name="dbpw" id="dbpw" value="root" class="input" autoComplete="off" onblur="testdbpwd(1)"></td>
            <td><div id="dbpw_tip" style="display:none"><img src="<?php echo INS_TPL; ?>/images/pop_loading.gif"></div></td>
          </tr>
          <tr>
            <td class="tar">数据库名：</td>
            <td><input type="text" name="dbname" id="dbname" value="magic" class="input" onblur="testdbpwd(2)"></td>
            <td><div id="dbname_tip" style="display:none"><img src="<?php echo INS_TPL; ?>/images/pop_loading.gif"></div></td>
          </tr>
          <tr>
            <td class="tar">数据库表前缀：</td>
            <td><input type="text" name="dbprefix" id="dbprefix" value="mac_" class="input"></td>
            <td><div id="dbprefix_tip"><span class="gray">建议使用默认，同一数据库安装多个Magic CMS时需修改</span></div></td>
          </tr>
        </table>
        <table width="100%">
          <tr>
            <td class="td1" width="100">创始人信息</td>
            <td class="td1" width="200">&nbsp;</td>
            <td class="td1">&nbsp;</td>
          </tr>
          <tr>
            <td class="tar">管理员帐号：</td>
            <td><input type="text" name="username" value="admin" class="input"></td>
            <td><div id="username_tip"></div></td>
          </tr>
          <tr>
            <td class="tar">密码：</td>
            <td><input type="text" name="password" id="J_manager_pwd" value="admin888" class="input" autoComplete="off"></td>
            <td><div id="password_tip"></div></td>
          </tr>
          <tr>
            <td class="tar">重复密码：</td>
            <td><input type="text" name="repassword" class="input"  value="admin888" autoComplete="off"></td>
            <td><div id="repassword_tip"></div></td>
          </tr>
        </table>
        <div id="response_tips" style="display:none;"></div>
      </div>
      <div class="bottom tac">
		<a href="?r=install&step=2" class="btn">上一步</a>
        <button type="submit" id="install_submit" disabled class="btn btn_submit btn_old">创建数据</button>
      </div>
    </form>
  </section>
  <script src="<?php echo INS_TPL; ?>/images/jquery.js"></script>
  <script>
  function testdbpwd(type){
        var dbhost = $('#dbhost').val();
        var dbuser = $('#dbuser').val();
        var dbpwd  = $('#dbpw').val();
        var dbname = $('#dbname').val();
        var dbport = $('#dbport').val();
		if (type==1){
			var obj = '#dbpw';
		}else if(type==2){
			var obj = '#dbname';
		}
        $.ajax({
            type: "POST",
            url: "?r=install&step=3",
            data: {'type':type,'dbhost':dbhost,'dbuser':dbuser,'dbpwd':dbpwd,'dbname':dbname,'dbport':dbport},
			dataType: "json",
			beforeSend:function(){
				$(obj+'_tip').show();
            },
            success: function(json){
                if(json.status==1){
					$('#install_submit').attr('disabled',false);
					$('#install_submit').removeClass('btn_old');
					$(obj+'_tip').html('<span class="tips_success">'+json.content+'</span>');
                }else{
				    $('#dbpw').val("");
					$('#install_submit').attr('disabled',true);
					$('#install_submit').addClass('btn_old');
                    $(obj+'_tip').html('<span class="tips_error">'+json.content+'</span>');
                }
            },error:function(){
                $('#dbpw_tip').html('<span class="tips_error">数据库链接失败</span>');
				$('#dbpw').val("");
            }
        });
    }
	testdbpwd(1);
</script>