<?php defined('APP_NAME') || exit('Access Denied'); 
?><!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="Author" content="QQ:401421567" />
<link rel="stylesheet" href="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/css/bootstrap.min.css" />
<link rel="stylesheet" href="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/css/me.css" />
<script>var admin_static = "<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>" , cookie_pre = "<?php echo(isset($C['cookie_pre']) ? $C['cookie_pre'] : ''); ?>",_vip_key = "<?php echo(isset($vip['_key']) ? $vip['_key'] : ''); ?>",api_url = "<?php echo(isset($vip['api_url']) ? $vip['api_url'] : ''); ?>",_control = "<?php echo(isset($_GET['control']) ? $_GET['control'] : ''); ?>",_action = "<?php echo(isset($_GET['action']) ? $_GET['action'] : ''); ?>",version = '<?php echo(isset($vip['version']) ? $vip['version'] : ''); ?>',release = '<?php echo(isset($vip['release']) ? $vip['release'] : ''); ?>',vip_key = _vip_key;</script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/jquery.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/bootstrap.min.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>js/layer/layer.js"></script>
<script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/global.js"></script>
<!--[if lt IE 9]>
  <script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/html5.js"></script>
  <script src="<?php echo(isset($C['admin_static']) ? $C['admin_static'] : ''); ?>admin/js/respond.min.js"></script>
<![endif]-->
<script type="text/javascript">
	var webdir = '<?php echo(isset($pp['webdir']) ? $pp['webdir'] : ''); ?>';
	layer.config({
		extend: 'extend/layer.ext.js',
		shift: -1
	});
	var pKey = "<?php echo(isset($_pkey) ? $_pkey : ''); ?>", urlKey = "<?php echo(isset($_ukey) ? $_ukey : ''); ?>", place = "<?php echo(isset($_place) ? $_place : ''); ?>";
	//全选与全不选
	function selectall(name,obj) {
		if ($(obj).is(':checked')) {
			$("input[name='"+name+"']").each(function() {
				$(this).prop('checked', true);
			});
		} else {
			$("input[name='"+name+"']").each(function() {
				$(this).prop('checked', false);
			});
		}
	}
</script>
<title><?php echo(isset($_title) ? $_title : ''); ?></title>
</head>
<body>
<div class="container-fluid">
	<ul class="nav nav-tabs" role="tablist">
		<li role="presentation" <?php if ($do == 0) { ?> class="active"<?php } ?>><a href="#tab_1" aria-controls="tab_1" role="tab" data-toggle="tab">基本设置</a></li>
		<li role="presentation" <?php if ($do == 1) { ?> class="active"<?php } ?>><a href="#tab_2" aria-controls="tab_2" role="tab" data-toggle="tab">评价设置</a></li>
		<li role="presentation" <?php if ($do == 2) { ?> class="active"<?php } ?>><a href="#tab_3" aria-controls="tab_3" role="tab" data-toggle="tab">支付接口</a></li>
		<li role="presentation" <?php if ($do == 3) { ?> class="active"<?php } ?>><a href="#tab_4" aria-controls="tab_4" role="tab" data-toggle="tab">用户配置</a></li>
		<li role="presentation" <?php if ($do == 4) { ?> class="active"<?php } ?>><a href="#tab_5" aria-controls="tab_5" role="tab" data-toggle="tab">第三方登陆</a></li>
	</ul>
	<div class="panel panel-default" style="margin-top:-2px;">
		<form action="index.php?u=setting-index-ajax-1" method="post" class="form-horizontal mt10">
			<div class="tab-content">
				<div id="tab_1" role="tabpanel" class="tab-pane <?php if ($do == 0) { ?> active<?php } ?>">
					<div class="form-group">
						<label class="col-xs-2 control-label">站点标题</label>
						<div class="col-xs-3"><?php echo(isset($input['webname']) ? $input['webname'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">站点域名</label>
						<div class="col-xs-3"><?php echo(isset($input['webdomain']) ? $input['webdomain'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">所在目录</label>
						<div class="col-xs-3"><?php echo(isset($input['webdir']) ? $input['webdir'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">模板主题</label>
						<div class="col-xs-3">
							<select class="form-control" name="theme">
							<?php if(isset($templates) && is_array($templates)) { foreach($templates as &$v) { ?>
								<option <?php if ($v==$theme) { ?>selected="selected"<?php } ?> value="<?php echo(isset($v) ? $v : ''); ?>"><?php echo(isset($v) ? $v : ''); ?></option>
							<?php }} ?>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">统计代码</label>
						<div class="col-xs-3"><?php echo(isset($input['tongji']) ? $input['tongji'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">备案号</label>
						<div class="col-xs-3"><?php echo(isset($input['beian']) ? $input['beian'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">电子邮箱</label>
						<div class="col-xs-3"><?php echo(isset($input['webmail']) ? $input['webmail'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">QQ</label>
						<div class="col-xs-3"><?php echo(isset($input['qq']) ? $input['qq'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">开启Gzip压缩</label>
						<div class="col-xs-3">
							<label class="checkbox-inline"><input type="checkbox" name="gzip" value="1" <?php if ($input['gzip']) { ?> checked="checked"<?php } ?> /> &nbsp;</label>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">百度推送地址</label>
						<div class="col-xs-3"><?php echo(isset($input['bdts']) ? $input['bdts'] : ''); ?></div>
						<div class="col-xs-6"><p class="form-control-static small"><a href="http://zhanzhang.baidu.com/linksubmit/index" target="_blank">去百度站长平台获取</a><br />请填写完整的接口调用地址，如：<font color="red">http://data.zz.baidu.com/urls?site=www.baidu.com&token=LQ8TJI6YORAd9uxN&type=original</font></p></div>
					</div>
					<div class="form-group">
						<div class="col-xs-offset-2 col-xs-10">
							<input type="submit" value="&#20445;&#23384;" class="btn btn-info" />
						</div>
					</div>
				</div>
				<div id="tab_2" role="tabpanel" class="tab-pane <?php if ($do == 1) { ?> active<?php } ?>">
					<div class="form-group">
						<label class="col-xs-2 control-label">关闭全站评价</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="dis_comment" value="1" <?php if ($input['dis_comment']) { ?> checked="checked"<?php } ?> /> &nbsp;</label></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">仅限登陆后评价</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="user_comment" value="1" <?php if ($input['user_comment']) { ?> checked="checked"<?php } ?>> &nbsp;</label></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">评价是否审核</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="comment_status" value="1" <?php if ($input['comment_status']) { ?> checked="checked"<?php } ?>> &nbsp;</label></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">评价敏感词过滤</label>
						<div class="col-xs-4"><?php echo(isset($input['comment_filter']) ? $input['comment_filter'] : ''); ?></div>
						<div class="col-xs-6"><p class="form-control-static small">多个词用“半角逗号”隔开，例如：三级,裸体</p></div>
					</div>
					<div class="form-group">
						<div class="col-xs-offset-2 col-xs-10">
							<input type="submit" value="&#20445;&#23384;" class="btn btn-info" />
						</div>
					</div>
				</div>
				<div id="tab_3" role="tabpanel" class="tab-pane <?php if ($do == 2) { ?> active<?php } ?>">
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">支付宝即时到帐</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="alipay[off]" value="1" <?php if ($input['alipay']['off']) { ?> checked="checked"<?php } ?>> 是否开启</label></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">收款帐号</label>
						<div class="col-xs-3"><?php echo(isset($input['alipay']['id']) ? $input['alipay']['id'] : ''); ?></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">合作者身份ID</label>
						<div class="col-xs-3"><?php echo(isset($input['alipay']['partner']) ? $input['alipay']['partner'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">以2088开头的16位纯数字</p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">安全检验码</label>
						<div class="col-xs-3">
							<?php echo(isset($input['alipay']['key']) ? $input['alipay']['key'] : ''); ?>
							<input type="hidden" name="alipay[sign_type]" value="MD5">
							<input type="hidden" name="alipay[input_charset]" value="utf-8">
							<input type="hidden" name="alipay[cacert]" value="../cacert.pem">
							<input type="hidden" name="alipay[transport]" value="http">
						</div>
						<div class="col-xs-4"><p class="form-control-static small">数字和字母组成的32位字符</p></div>
					</div>
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">微信支付</label>
						<div class="col-xs-3"><p class="form-control-static">NATIVE/模式2</p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label text-info"></label>
						<div class="col-xs-3"><label class="checkbox-inline"><input type="checkbox" name="weixin[off]" value="1" <?php if ($input['weixin']['off']) { ?> checked="checked"<?php } ?>> 是否开启</label></div>
						<div class="col-xs-4"><p class="form-control-static small"><a href="https://pay.weixin.qq.com/index.php/account" target="_blank">商户平台登陆</a></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">APPID</label>
						<div class="col-xs-3"><?php echo(isset($input['weixin']['APPID']) ? $input['weixin']['APPID'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">绑定支付的APPID（开户邮件中可查看）</p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">MCHID</label>
						<div class="col-xs-3"><?php echo(isset($input['weixin']['MCHID']) ? $input['weixin']['MCHID'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">商户号</p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">KEY</label>
						<div class="col-xs-3"><?php echo(isset($input['weixin']['KEY']) ? $input['weixin']['KEY'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">商户支付密钥，<a href="https://pay.weixin.qq.com/index.php/account/api_cert" target="_blank">登录商户平台自行设置</a></p></div>
					</div>
					<div class="form-group" style="display:none;">
						<label class="col-xs-2 control-label noweight">APPSECRET</label>
						<div class="col-xs-3"><?php echo(isset($input['weixin']['APPSECRET']) ? $input['weixin']['APPSECRET'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small"><a href="https://mp.weixin.qq.com/advanced/advanced?action=dev&t=advanced/dev&token=2005451881&lang=zh_CN" target="_blank">公众帐号secert（仅JSAPI支付的时需配置， 登录公众平台开发者中心可设置）</a></p></div>
					</div>
					<div class="form-group" style="display:none;">
						<div class="col-xs-8 col-xs-offset-2"><p class="form-control-static small">另外两个文件，私钥及公钥及apiclient_cert.pem和apiclient_key.pem直接放到网站根目录即可。</p></div>
					</div>
					
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight"></label>
						<div class="col-xs-3"><p class="form-control-static text-red">以下第三方支付接口支持个人申请，请酌情使用！</p></div>
					</div>
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">铭翼支付(聚合接口)</label>
						<div class="col-xs-3"><label class="checkbox-inline"><input type="checkbox" name="mingyi[off]" value="1" <?php if ($input['mingyi']['off']) { ?> checked="checked"<?php } ?>> 是否开启 <code>基础费率：0.2% 支付宝实时结算到账</code></label></div>
						<div class="col-xs-4"><p class="form-control-static small text-warning">交易即时扣除手续费，扣除后不足0.01元时直接忽略</p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">会员ID</label>
						<div class="col-xs-3"><?php echo(isset($input['mingyi']['id']) ? $input['mingyi']['id'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">申请地址：<a href="http://www.mingyipay.com" target="_blank">http://www.mingyipay.com</a> </p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">密钥</label>
						<div class="col-xs-3">
							<?php echo(isset($input['mingyi']['key']) ? $input['mingyi']['key'] : ''); ?>
						</div>
					</div>
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">云通付</label>
						<div class="col-xs-3"><label class="checkbox-inline"><input type="checkbox" name="passpay[off]" value="1" <?php if ($input['passpay']['off']) { ?> checked="checked"<?php } ?>> 是否开启 <code>接口开通费：99元</code></label></div>
						<div class="col-xs-4"><p class="form-control-static small text-warning"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">商户号</label>
						<div class="col-xs-3"><?php echo(isset($input['passpay']['user_seller']) ? $input['passpay']['user_seller'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">申请地址：<a href="http://www.passpay.net/user/register.html" target="_blank">http://www.passpay.net/</a></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">身份者PID</label>
						<div class="col-xs-3"><?php echo(isset($input['passpay']['partner']) ? $input['passpay']['partner'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">签约账号，由16位纯数字组成的字符串，请登录商户后台查看</p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">MD5密钥</label>
						<div class="col-xs-3"><?php echo(isset($input['passpay']['key']) ? $input['passpay']['key'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small">安全检验码，由数字和字母组成的32位字符串，请登录商户后台查看</p></div>
					</div>
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight"></label>
						<div class="col-xs-3"><p class="form-control-static text-red">以下方式需手动处理用户充值！</p></div>
					</div>
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">支付宝转帐设置</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="lifealipay[off]" value="1" <?php if ($input['lifealipay']['off']) { ?> checked="checked"<?php } ?>> 是否开启</label></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">收款帐号</label>
						<div class="col-xs-3"><?php echo(isset($input['lifealipay']['id']) ? $input['lifealipay']['id'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label noweight">转帐提示</label>
						<div class="col-xs-3"><?php echo(isset($input['lifealipay']['notice']) ? $input['lifealipay']['notice'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<hr/>
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">线下充值</label>
						<div class="col-xs-8">
							<table class="table" id="bank_list">
								<thead>
								<tr class="info">
									<td>ID</td><td>银行名称</td><td>收款人</td><td>收款帐号</td><td>开户地址</td><td>删除</td>
								</tr>
								</thead>
								<tbody id="link_cont">
								<?php if(isset($input['offbank']) && is_array($input['offbank'])) { foreach($input['offbank'] as $i=>&$v) { ?>
								<tr id="bank_<?php echo(isset($i) ? $i : ''); ?>">
									<td><?php echo(isset($i) ? $i : ''); ?></td><td><input class="form-control" type="text" value="<?php echo(isset($v['bank']) ? $v['bank'] : ''); ?>" name="offbank[<?php echo(isset($i) ? $i : ''); ?>][bank]"></td><td><input class="form-control" type="text" value="<?php echo(isset($v['name']) ? $v['name'] : ''); ?>" name="offbank[<?php echo(isset($i) ? $i : ''); ?>][name]"></td><td><input class="form-control" type="text" value="<?php echo(isset($v['card']) ? $v['card'] : ''); ?>" name="offbank[<?php echo(isset($i) ? $i : ''); ?>][card]"></td><td><input class="form-control" type="text" value="<?php echo(isset($v['addr']) ? $v['addr'] : ''); ?>" name="offbank[<?php echo(isset($i) ? $i : ''); ?>][addr]"></td><td><a onclick="delBank(<?php echo(isset($i) ? $i : ''); ?>)" href="javascript:void(0);" class="btn btn-danger">删除</a></td>
								</tr>
								<?php }} ?>
								</tbody>
								<tfoot>
								<tr>
									<th class="text-right"></th>
									<td colspan="5"><a class="btn btn-default" href="javascript:void(0);" onclick="addBank();">添加</a></td>
								</tr>
								</tfoot>
							</table>
						</div>
					</div>
					<div class="form-group">
						<div class="col-xs-offset-2 col-xs-10">
							<input type="submit" value="&#20445;&#23384;" class="btn btn-info" />
						</div>
					</div>
				</div>
				<div id="tab_4" role="tabpanel" class="tab-pane <?php if ($do == 3) { ?> active<?php } ?>">
					<div class="form-group">
						<label class="col-xs-2 control-label">开启用户模块</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="user[open_user_model]" value="1" <?php if ($input['user']['open_user_model']) { ?> checked="checked"<?php } ?>>&nbsp;</label></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">允许新会员注册</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="user[open_user_reg]" value="1" <?php if ($input['user']['open_user_reg']) { ?> checked="checked"<?php } ?>>&nbsp;</label></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">新用户赠送</label>
						<div class="col-xs-2">
							<div class="input-group">
								<?php echo(isset($input['user']['gift']) ? $input['user']['gift'] : ''); ?>
								<span class="input-group-addon">元</span>
							</div>
						</div>
						<div class="col-xs-4">
							<p class="form-control-static small">前提必须：<input type="checkbox" name="user[gift_mobi_off]" value="1" <?php if ($input['user']['gift_mobi_off']) { ?> checked="checked"<?php } ?>  onclick="this.value=this.checked?1:0"> 绑定手机　<input type="checkbox" name="user[gift_email_off]" value="1" <?php if ($input['user']['gift_email_off']) { ?> checked="checked"<?php } ?> onclick="this.value=this.checked?1:0"> 绑定邮箱</p>
						</div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">用户提现手续费</label>
						<div class="col-xs-2">
							<div class="input-group">
								<?php echo(isset($input['user']['charge']) ? $input['user']['charge'] : ''); ?>
								<span class="input-group-addon">%</span>
							</div>
						</div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">用户提现最低限制</label>
						<div class="col-xs-2">
							<div class="input-group">
								<?php echo(isset($input['user']['mintx']) ? $input['user']['mintx'] : ''); ?>
								<span class="input-group-addon">元</span>
							</div>
						</div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">是否开启下线推广</label>
						<div class="col-xs-4"><label class="checkbox-inline"><input type="checkbox" name="user[open_sem]" value="1" <?php if ($input['user']['open_sem']) { ?> checked="checked"<?php } ?>>&nbsp;<span class="form-control-static small">仅支持一级下线，提成比例在用户组内设置！</span></label></div>
					</div>
					<div class="form-group">
						<div class="col-xs-offset-2 col-xs-10">
							<input type="submit" value="&#20445;&#23384;" class="btn btn-info" />
						</div>
					</div>
				</div>
				<div id="tab_5" role="tabpanel" class="tab-pane <?php if ($do == 4) { ?> active<?php } ?>">
					<div class="form-group">
						<label class="col-xs-2 control-label text-info">QQ登陆接口</label>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">申请地址</label>
						<div class="col-xs-4"><p class="form-control-static small"><a href="http://connect.qq.com/" target="_blank">http://connect.qq.com/</a></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">是否启用</label>
						<div class="col-xs-3"><label class="checkbox-inline"><input type="checkbox" name="qq_login[off]" value="1" <?php if ($input['qq_login']['off']) { ?> checked="checked"<?php } ?>>&nbsp;</label></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">APPID</label>
						<div class="col-xs-3"><?php echo(isset($input['qq_login']['appid']) ? $input['qq_login']['appid'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">APPKEY</label>
						<div class="col-xs-3"><?php echo(isset($input['qq_login']['appkey']) ? $input['qq_login']['appkey'] : ''); ?></div>
						<div class="col-xs-4"><p class="form-control-static small"></p></div>
					</div>
					<div class="form-group">
						<label class="col-xs-2 control-label">回调地址</label>
						<div class="col-xs-3"><p class="form-control-static"><code>http://www.您的域名.com/member/index.php</code></p></div>
					</div>
					<div class="form-group">
						<div class="col-xs-offset-2 col-xs-10">
							<input type="submit" value="&#20445;&#23384;" class="btn btn-info" />
						</div>
					</div>
				</div>
			</div>
		</form>
	</div>
</div>
<script type="text/javascript">
//拖拽
$.fn.kpdragsort = function(options) {
	var container = this;

	$(container).children().off("mousedown").mousedown(function(e) {
		if(e.which != 1 || $(e.target).is("input, textarea, a") || window.kp_only) return; // 排除非左击和其他元素
		e.preventDefault(); // 阻止选中文本

		var x = e.pageX;
		var y = e.pageY;
		var _this = $(this); // 点击选中块
		var w = _this.width();
		var h = _this.height();
		var w2 = w/2;
		var h2 = h/2;
		var p = _this.position();
		var left = p.left;
		var top = p.top;		
		var sTop = $(".p:first").scrollTop();
		window.kp_only = true;

		// 添加虚线框
		_this.before('<div id="kp_widget_holder"></div>');
		var wid = $("#kp_widget_holder");
		wid.css({"border":"2px dashed #ccc", "height":_this.outerHeight(true)-4});

		// 保持原来的宽高
		_this.css({"width":w, "height":h, "position":"absolute", opacity: 0.8, "z-index": 999, "left":left, "top":top});

		// 绑定mousemove事件
		$(document).mousemove(function(e) {
			e.preventDefault();

			// 移动选中块
			var l = left + e.pageX - x;
			var t = top + ($(".p:first").scrollTop() - sTop) + e.pageY - y;
			_this.css({"left":l, "top":t});

			// 选中块的中心坐标
			var ml = l+w2;
			var mt = t+h2;

			// 遍历所有块的坐标
			$(container).children().not(_this).not(wid).each(function(i) {
				var obj = $(this);
				var p = obj.position();
				var a1 = p.left;
				var a2 = p.left + obj.width();
				var a3 = p.top;
				var a4 = p.top + obj.height();

				// 移动虚线框
				if(a1 < ml && ml < a2 && a3 < mt && mt < a4) {
					if(!obj.next("#kp_widget_holder").length) {
						wid.insertAfter(this);
					}else{
						wid.insertBefore(this);
					}
					return;
				}
			});
		});

		// 绑定mouseup事件
		var _mouseup = function() {
			$(document).off('mouseup').off('mousemove');

			// 拖拽回位，并删除虚线框
			var p = wid.position();
			_this.animate({"left":p.left, "top":p.top}, 100, function() {
				_this.removeAttr("style");
				wid.replaceWith(_this);
				window.kp_only = null;
				if(parent) parent.document.onmouseup = null;
			});
		};
		$(document).mouseup(_mouseup);
		if(parent) parent.document.onmouseup = _mouseup;
	});
}
//ppajax.submit("form:first");
$("form:first").submit(function(){
	var obj = $(this);
	var d = obj.serializeArray();
	ppajax.postd(obj.attr("action"), d, function(data){
		ppajax.alert(data);
		if(window.ppdata.err==0) setTimeout("window.location.reload()",1000);
	});
	return false;
});
function addBank(){
	id = parseInt($("#bank_list tbody tr").last().find("td").eq(0).html())+1; 
    var html = '<tr id="bank_'+id+'"><td>'+id+'</td><td><input class="form-control" type="text" value="" name="offbank['+id+'][bank]"></td><td><input class="form-control" type="text" value="" name="offbank['+id+'][name]"></td><td><input class="form-control" type="text" value="" name="offbank['+id+'][card]"></td><td><input class="form-control" type="text" value="" name="offbank['+id+'][addr]"></td><td><a onclick="delBank('+id+')" href="javascript:void(0);" class="btn btn-danger">删除</a></td></tr>';
    $("#bank_list tbody").append(html); 
}
function delBank(id){
    $("#bank_"+id).remove();
}
$("#link_cont").kpdragsort();
</script>
</body>
</html>