<%
--[[
    Info    路由器端口转发
]]--
local ver = require("xiaoqiang.XQVersion").webVersion
local XQLanWanUtil = require("xiaoqiang.util.XQLanWanUtil")
local ip = XQLanWanUtil.getLanWanInfo("lan")["ipv4"][1]["ip"]
%>
<%include("web/inc/head")%>
<title><%:小米路由器%></title>
<meta name="viewport" content="width=1200">
<link href="<%=resource%>/web/css/bc.css?v=<%=ver%>" rel="stylesheet">
<link href="<%=resource%>/web/css/nat.css?v=<%=ver%>" rel="stylesheet">
</head>
<body>
    <div id="doc">
        <%include("web/inc/header")%>
        <%include("web/inc/nav_set")%>
        <div id="bd" data-ip="<%=ip%>">
            <div class="mod-set mod-nat">
                <div class='hd'>
                    <h3><%:端口转发%></h3>
                    <!--
                    <div class='switch'>
                        <a href="#" data-status="0" class="btn-switch btn-switch-on" id="btnnat"></a>
                    </div>
                    -->
                </div>
                <div class="bd">
                    <h3><%:端口转发规则列表：%></h3>
                    <form name="portFormEdit">
                        <table class="table table-nat">
                            <thead>
                                <tr>
                                    <th width="200"><%:名称%></th>
                                    <th><%:协议%></th>
                                    <th><%:外部端口%></th>
                                    <th><%:内部IP地址%></th>
                                    <th><%:内部端口%></th>
                                    <!--    <th><%:状态%></th> -->
                                    <th class="center" width="230"><%:操作%></th>
                                </tr>
                            </thead>
                            <tbody id="natlist_port">
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <div class="mod-set mod-nat">
                <div class="bd">
                    <h3><%:范围转发规则列表：%></h3>
                    <form name="rangeFormEdit">
                        <table class="table  table-nat">
                            <thead>
                                <tr>
                                    <th width="200"><%:名称%></th>
                                    <th><%:协议%></th>
                                    <th><%:起始端口%></th>
                                    <th><%:结束端口%></th>
                                    <th><%:目标IP%></th>
                                    <!-- <th><%:状态%></th> -->
                                    <th class="center" width="230"><%:操作%></th>
                                </tr>
                            </thead>
                            <tbody id="natlist_range">
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <div class='mod-set mod-nat'>
                <div class="bd">
                    <div class="item item-control">
                        <button type="submit" id="apply" class="btn btn-primary btn-large"><span><%:保存并生效%></span></button>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <%include("web/inc/footer")%>

</div>

<script type="text/template" id="tpl_new_port">
<form id="portForm" name="portForm" class="form form-horizontal">
    <div class="form-item form-item-input">
        <label for="name" class="k"><%:名称%></label>
        <span class="v"><input type="text" name="name" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-select">
        <label for="proto" class="k"><%:协议%></label>
        <span class="v">
            <select  name="proto" class="beautify" style="">
                <option value='1'>TCP</option>
                <option value='2'>UDP</option>
                <option value='3'><%:TCP和UDP%></option>
            </select>
        </span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="sport" class="k"><%:外部端口%></label>
        <span class="v"><input type="text" name="sport" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input input-ip">
        <label for="ip" class="k"><%:内部IP地址：%><span class="iphere"></span></label>
        <span class="v"><input type="text" name="ip" value="" class="ipt-text no-init" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="dport" class="k"><%:内部端口%></label>
        <span class="v"><input type="text" name="dport" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-contral">
    </div>
</form>
</script>

<script type="text/template" id="tpl_new_range">
<form id="rangeForm" name="rangeForm" class="form form-horizontal">
    <div class="form-item form-item-input">
        <label for="name" class="k"><%:名称%></label>
        <span class="v"><input type="text" name="name" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-select">
        <label for="proto" class="k"><%:协议%></label>
        <span class="v">
            <select  name="proto" class="beautify" style="">
                <option value='1'>TCP</option>
                <option value='2'>UDP</option>
                <option value='3'><%:TCP和UDP%></option>
            </select>
        </span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="fport" class="k"><%:起始端口%></label>
        <span class="v"><input type="text" name="fport" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="tport" class="k"><%:结束端口%></label>
        <span class="v"><input type="text" name="tport" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="ip" class="k"><%:目标IP%></label>
        <span class="v"><input type="text" name="ip" value="" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-contral">
    </div>
</form>
</script>
<script type="text/template" id="tpl_tr_port">
{for(var i=0;i<$arr.length;i++)}
    <tr>
        <td>{js print( StringH.encode4Html( $arr[i].name ) )}</td>
        <td>
            {if($arr[i].proto == 1)}TCP{/if}
            {if($arr[i].proto == 2)}UDP{/if}
            {if($arr[i].proto == 3)}TCP和UDP{/if}
        </td>
        <td>{$arr[i].srcport}</td>
        <td>{$arr[i].destip}</td>
        <td>{$arr[i].destport}</td>
     <!--   <td><%:未生效%></td> -->
        <td class="center">
            <a class="btn btn-dft editPort" href="javascript:;" data-item="{encodeURIComponent(QW.JSON.stringify($arr[i]))}" data-port="{$arr[i].srcport}"><span><%:编辑%></span></a>
            <a class="btn btn-dft delPort" href="javascript:;" data-port="{$arr[i].srcport}"><span><%:删除%></span></a>
        </td>
    </tr>
{/for}
</script>

<script type="text/template" id="tpl_tr_port_edit">
<form id="portForm" name="portForm" class="form form-horizontal">
    <div class="form-item form-item-input">
        <label for="name" class="k"><%:名称%></label>
        <span class="v"><input type="text" name="name" value="{$item.name}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-select">
        <label for="proto" class="k"><%:协议%></label>
        <span class="v">
            <select  name="proto" class="beautify" style="">
                <option value='1' {js print($item.proto == 1? "selected": "")}>TCP</option>
                <option value='2' {js print($item.proto == 2? "selected": "")}>UDP</option>
                <option value='3' {js print($item.proto == 3? "selected": "")}><%:TCP和UDP%></option>
            </select>
        </span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="sport" class="k"><%:外部端口%></label>
        <span class="v"><input type="text" name="sport" value="{$item.srcport}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input input-ip">
        <label for="ip" class="k"><%:内部IP地址：%><span class="iphere"></span></label>
        <span class="v"><input type="text" name="ip" value="{$item.destip}" class="ipt-text no-init" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="dport" class="k"><%:内部端口%></label>
        <span class="v"><input type="text" name="dport" value="{$item.destport}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-contral">
    </div>
</form>
</script>
<script type="text/template" id="tpl_tr_range">
{for(var i=0;i<$arr.length;i++)}
    <tr>
        <td>{js print( StringH.encode4Html( $arr[i].name ) )}</td>
        <td>
            {if($arr[i].proto == 1)}TCP{/if}
            {if($arr[i].proto == 2)}UDP{/if}
            {if($arr[i].proto == 3)}<%:TCP和UDP%>{/if}
        </td>
        <td>{$arr[i].srcport.f}</td>
        <td>{$arr[i].srcport.t}</td>
        <td>{$arr[i].destip}</td>
        <!-- <td><%:未生效%></td> -->
        <td class="center">
            <a class="btn btn-dft editRange" href="javascript:;" data-item="{encodeURIComponent(QW.JSON.stringify($arr[i]))}" data-port="{$arr[i].srcport.f}"><span><%:编辑%></span></a>
            <a class="btn btn-dft delRange" href="javascript:;" data-port="{$arr[i].srcport.f}"><span><%:删除%></span></a>
        </td>
    </tr>
{/for}
</script>
<script type="text/template" id="tpl_tr_range_edit">
<form id="rangeForm" name="rangeForm" class="form form-horizontal">
    <div class="form-item form-item-input">
        <label for="name" class="k"><%:名称%></label>
        <span class="v"><input type="text" name="name" value="{$item.name}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-select">
        <label for="proto" class="k"><%:协议%></label>
        <span class="v">
            <select  name="proto" class="beautify" style="">
                <option value='1' {js print($item.proto == 1? "selected": "")}>TCP</option>
                <option value='2' {js print($item.proto == 2? "selected": "")}>UDP</option>
                <option value='3' {js print($item.proto == 3? "selected": "")}><%:TCP和UDP%></option>
            </select>
        </span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="fport" class="k"><%:起始端口%></label>
        <span class="v"><input type="text" name="fport" value="{$item.srcport.f}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="tport" class="k"><%:结束端口%></label>
        <span class="v"><input type="text" name="tport" value="{$item.srcport.t}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-item form-item-input">
        <label for="ip" class="k"><%:目标IP%></label>
        <span class="v"><input type="text" name="ip" value="{$item.destip}" class="ipt-text" /></span>
        <em class="t"></em>
    </div>

    <div class="form-contral">
    </div>
</form>
</script>
<%include("web/inc/g.js")%>
<script>
var modelNat = (function(){
	return {
		init : function(){

        // save ip for later use
        var ip = $('#bd').data('ip');
        var iparr = ip.split('.');
        iparr.pop();
        var ipprefix = iparr.join('.') + '.';
        window.ipprefix = ipprefix;

        // newPost
            $('body').on('click', '.newPort' ,function(e) {
                var dlg = window.art.dialog({
                    title: '<%:新建端口转发规则%>',
                    content: $('#tpl_new_port').html(),
                    initialize: function() {
                        $.selectBeautify();
                        $.formInit();
                        $('.iphere').text(window.ipprefix);
                    },
                    lock: true,
                    fixed: true,
                    okValue: '<%:添加%>',
                    ok: function() {
                        e.preventDefault();
                        var data = $('#portForm').serialize();
                        var ip = $('.iphere').text() + $('input[name="ip"]').val();
                        data = data.replace(/ip=\d{1,3}/, 'ip=' + ip);
                        var validator = FormValidator.checkAll('portForm', [
                            {
                                name: 'ip',
                                display :'<%:IP地址最后一位%>',
                                rules: 'required|is_natural|less_than[255]|greater_than[1]'
                            },
                            {
                                name: 'name',
                                display: '<%:名称%>',
                                rules: 'required'
                            },
                            {
                                name: 'sport',
                                display: '<%:外部端口%>',
                                rules: 'required|is_natural|less_than[65536]'
                            },
                            {
                                name: 'dport',
                                display: '<%:内部端口%>',
                                rules: 'required|is_natural|less_than[65536]'
                            }
                        ]);
                        if (validator) {
                            modelNat.addPort(data, 'new');
                        } else {
                            return false;
                        }
                    }
                });
            });

            // delPort
            $('#natlist_port').on('click', '.delPort', function(e) {
                e.preventDefault();
                var port = $(this).data('port');
                var dlg = window.art.dialog({
                    title: '<%:端口转发%>',
                    content: '<%:确定要删除这条规则吗？%>',
                    lock: true,
                    fixed: true,
                    ok: function() {
                        modelNat.delPort(port);
                    },
                    cancel: function() {}
                })
            });

            // editPort
            $('#natlist_port').on('click', '.editPort', function(e) {
                e.preventDefault();
                var item = $(e.currentTarget).data('item');
                modelNat.editPort(item, e);
            });

            // confirmEdit port
            $('#natlist_port').on('click', '.confirmEdit', function(e) {

                var data = $(e.target).parents('form').serialize();
                var validator = FormValidator.checkAll('portFormEdit', [
                    {
                        name: 'ip',
                        display :'<%:IP地址最后一位%>',
                        rules: 'required|is_natural|less_than[255]|greater_than[1]'
                    },
                    {
                        name: 'name',
                        display: '<%:名称%>',
                        rules: 'required'
                    },
                    {
                        name: 'sport',
                        display: '<%:外部端口%>',
                        rules: 'required|is_natural|less_than[65536]'
                    },
                    {
                        name: 'dport',
                        display: '<%:内部端口%>',
                        rules: 'required|is_natural|less_than[65536]'
                    }
                ]);
                if (validator) {
                    modelNat.addPort(data, 'edit');
                }
                e.preventDefault();
            });

            // cancelEdit port
            $('#natlist_port').on('click', '.cancelEdit', function(e) {
                e.preventDefault();
                var $tr = $(e.currentTarget).parent().parent();
                $tr.html(modelNat.savedItem);
            });

            // newRange
            $('body').on('click', '.newRange', function(e) {
                var dlg = window.art.dialog({
                    title: '<%:新建范围转发规则%>',
                    content: $('#tpl_new_range').html(),
                    initialize: function() {
                        $.selectBeautify();
                        $.formInit();
                    },
                    lock: true,
                    fixed: true,
                    okValue: '<%:添加%>',
                    ok: function() {
                        e.preventDefault();

                        var data = $('#rangeForm').serialize();
                        var validator = FormValidator.checkAll('rangeForm', [
                            {
                                name: 'ip',
                                display :'<%:目标IP%>',
                                rules: 'required|valid_ip|callback_no_change'
                            },
                            {
                                name: 'name',
                                display: '<%:名称%>',
                                rules: 'required'
                            },
                            {
                                name: 'fport',
                                display: '<%:起始端口%>',
                                rules: 'required|is_natural|less_than[65536]'
                            },
                            {
                                name: 'tport',
                                display: '<%:结束端口%>',
                                rules: 'required|is_natural|less_than[65536]'
                            }
                        ]);
                        if (validator) {
                            modelNat.addRange(data, 'new');
                        } else {
                            return false;
                        }
                    }
                });
            });

            // delRange
            $('#natlist_range').on('click', '.delRange', function(e) {
                e.preventDefault();
                var port = $(this).data('port');

                var dlg = window.art.dialog({
                    title: '<%:端口转发%>',
                    content: '<%:确定要删除这条规则吗？%>',
                    lock: true,
                    fixed: true,
                    ok: function() {
                        modelNat.delRange(port);
                    },
                    cancel: function() {}
                })
            });

            // editRange
            $('#natlist_range').on('click', '.editRange', function(e) {
                e.preventDefault();
                var item = $(e.currentTarget).data('item');
                modelNat.editRange(item, e);
            });

            // confirmEdit range
            $('#natlist_range').on('click', '.confirmEditRange', function(e) {
                e.preventDefault();

                var data = $(e.target).parents('form').serialize();
                var validator = FormValidator.checkAll('rangeFormEdit', [
                    {
                        name: 'ip',
                        display :'<%:目标IP%>',
                        rules: 'required|valid_ip|callback_no_change'
                    },
                    {
                        name: 'name',
                        display: '<%:名称%>',
                        rules: 'required'
                    },
                    {
                        name: 'fport',
                        display: '<%:起始端口%>',
                        rules: 'required|is_natural|less_than[65536]'
                    },
                    {
                        name: 'tport',
                        display: '<%:结束端口%>',
                        rules: 'required|is_natural|less_than[65536]'
                    }
                ]);
                if (validator) {
                    modelNat.addRange(data, 'edit');
                }
                e.preventDefault();
            });

            // cancelEdit range
            $('#natlist_range').on('click', '.cancelEditRange', function(e) {
                e.preventDefault();
                var $tr = $(e.currentTarget).parent().parent();
                $tr.html(modelNat.savedItemRange);
            });

            // apply
            $('#apply').on('click', function(e) {
                var $btn = $(e.currentTarget);
                var dlg = window.top.art.dialog({
                    title: '<%:端口转发%>',
                    content: '<%:规则正在生效中，请等待...%>',
                    lock: true,
                    fixed: true,
                    cancel: false
                });
                $.getJSON(modelNat.url.applyRedirect, function(rsp) {
                    if (rsp.code === 0) {
                        dlg.close();
                    }
                });
            });

            // init
            // ftype: 0/1/2 全部/端口/范围
            modelNat.getRedirectPort();
            modelNat.getRedirectRange();
		},
        addPort: function(data, type) {
            $.post(modelNat.url.addPort, data, function(rsp) {
                if (rsp.code === 0) {
                    modelNat.getRedirectPort();
                    if (type === 'new') {
                        // 成功后清空form
                        $('#portForm').find('input:not(".dummy")').val('');
                    }
                } else {
                    window.top.art.dialog({
                        title: '<%:端口转发%>',
                        content: rsp.msg,
                        fixed: true,
                        lock: true,
                        time: 5*1000
                    });
                }
            }, 'json');
        },
        addRange: function(data, type) {
            $.post(modelNat.url.addRange, data, function(rsp) {
                if (rsp.code === 0) {
                    modelNat.getRedirectRange();
                    if (type === 'new') {
                        $('#rangeForm').find('input:not(".dummy")').val('');
                    }
                } else {
                    window.top.art.dialog({
                        title: '<%:端口转发%>',
                        content: rsp.msg,
                        fixed: true,
                        lock: true,
                        time: 5*1000
                    });

                }
            }, 'json');
        },
        delPort: function(port) {
            $.post(modelNat.url.delRedirect, 'port=' + port, function(rsp) {
                if (rsp.code === 0) {
                    modelNat.getRedirectPort();
                } else {
                    window.top.art.dialog({
                        title: '<%:端口转发%>',
                        content: rsp.msg,
                        lock: true,
                        fixed: true,
                        time: 5*1000
                    });
                }
            }, 'json');
        },
        delRange: function(port) {
            $.post(modelNat.url.delRedirect, 'port=' + port, function(rsp) {
                if (rsp.code === 0) {
                    modelNat.getRedirectRange();
                } else {
                    window.top.art.dialog({
                        title: '<%:端口转发%>',
                        content: rsp.msg,
                        fixed: true,
                        lock: true,
                        time: 5*1000
                    });
                }
            }, 'json');
        },
        savedItem: '',
        savedItemRange: '',
        editPort: function(item, e) {
            item = QW.JSON.parse(decodeURIComponent(item));
            var $tr = $(e.currentTarget).parent().parent();
            modelNat.savedItem = $tr.html();

            var dlg = window.art.dialog({
                title: '<%:编辑端口转发规则%>',
                content: StringH.tmpl($('#tpl_tr_port_edit').html(), {item: item}),
                initialize: function() {
                    $.selectBeautify();
                    $.formInit();
                    $('.iphere').text(window.ipprefix);
                    var ip = $('input[name="ip"]').val();
                    $('input[name="ip"]').val(ip.split('.')[3]);
                },
                lock: true,
                fixed: true,
                okValue: '<%:更新%>',
                ok: function() {
                    e.preventDefault();
                    var data = $('#portForm').serialize();
                    var ip = window.ipprefix + $('input[name="ip"]').val();
                    data = data.replace(/ip=\d{1,3}/, 'ip=' + ip);
                    data += '&force=1'; // 编辑时增加参数 force=1
                    var validator = FormValidator.checkAll('portForm', [
                        {
                            name: 'ip',
                            display :'<%:IP地址最后一位%>',
                            rules: 'required|is_natural|less_than[255]|greater_than[1]'
                        },
                        {
                            name: 'name',
                            display: '<%:名称%>',
                            rules: 'required'
                        },
                        {
                            name: 'sport',
                            display: '<%:外部端口%>',
                            rules: 'required|is_natural|less_than[65536]'
                        },
                        {
                            name: 'dport',
                            display: '<%:内部端口%>',
                            rules: 'required|is_natural|less_than[65536]'
                        }
                    ]);
                    if (validator) {
                        modelNat.addPort(data, 'new');
                    } else {
                        return false;
                    }
                }
            });
        },
        editRange: function(item, e) {
            item = QW.JSON.parse(decodeURIComponent(item));
            var $tr = $(e.currentTarget).parent().parent();
            modelNat.savedItemRange = $tr.html();

            var dlg = window.art.dialog({
                title: '<%:编辑范围转发规则%>',
                content: StringH.tmpl($('#tpl_tr_range_edit').html(), {item: item}),
                initialize: function() {
                    $.selectBeautify();
                    $.formInit();
                },
                lock: true,
                fixed: true,
                okValue: '<%:更新%>',
                ok: function() {
                    e.preventDefault();

                    var data = $('#rangeForm').serialize();
                    // 编辑时添加参数
                    data += '&force=1';
                    var validator = FormValidator.checkAll('rangeForm', [
                        {
                            name: 'ip',
                            display :'<%:目标IP%>',
                            rules: 'required|valid_ip|callback_no_change'
                        },
                        {
                            name: 'name',
                            display: '<%:名称%>',
                            rules: 'required'
                        },
                        {
                            name: 'fport',
                            display: '<%:起始端口%>',
                            rules: 'required|is_natural|less_than[65536]'
                        },
                        {
                            name: 'tport',
                            display: '<%:结束端口%>',
                            rules: 'required|is_natural|less_than[65536]'
                        }
                    ]);
                    if (validator) {
                        modelNat.addRange(data, 'new');
                    } else {
                        return false;
                    }
                }
            });
        },
        getRedirectPort: function() {
            $.getJSON(modelNat.url.getRedirect, 'ftype='+1, function(rsp) {
                var html;
                htmlAdd = '<tr><td style="text-align:center;" colspan="6"><a class="btn btn-dft newPort" href="#"><span><%:添加规则%></span></a></td></tr>';
                if (rsp.code === 0) {
                    if (rsp.list.length !== 0) {
                        html = StringH.tmpl($('#tpl_tr_port').html(), {arr: rsp.list});
                        $('#natlist_port').html(html);
                        $('#natlist_port').append(htmlAdd)
                    } else {
                        $('#natlist_port').html(htmlAdd);
                    }
                } else {
                    window.top.art.dialog({
                        title: '<%:端口转发%>',
                        content: rsp.msg,
                        lock: true,
                        fixed: true,
                        time: 5*1000
                    });
                }
            });
        },
        getRedirectRange: function() {
            $.getJSON(modelNat.url.getRedirect, 'ftype='+2, function(rsp) {
                var html;
                htmlAdd = '<tr><td style="text-align:center;" colspan="6"><a class="btn btn-dft newRange" href="#"><span><%:添加规则%></span></a></td></tr>';
                if (rsp.code === 0) {
                    if (rsp.list.length　!== 0) {
                        var html = StringH.tmpl($('#tpl_tr_range').html(), {arr: rsp.list});
                        $('#natlist_range').html(html);
                        $('#natlist_range').append(htmlAdd)
                    } else {
                        $('#natlist_range').html(htmlAdd);
                    }
                } else {
                    window.top.art.dialog({
                        title: '<%:端口转发%>',
                        content: rsp.msg,
                        fixed: true,
                        lock: true,
                        time: 5*1000
                    });
                }
            });
        },
        url: {
            'addPort': '<%=luci.dispatcher.build_url("api", "xqnetwork", "add_redirect")%>',
            'addRange': '<%=luci.dispatcher.build_url("api", "xqnetwork", "add_range_redirect")%>',
            'delRedirect': '<%=luci.dispatcher.build_url("api", "xqnetwork", "delete_redirect")%>',
            'applyRedirect': '<%=luci.dispatcher.build_url("api", "xqnetwork", "redirect_apply")%>',
            'getRedirect': '<%=luci.dispatcher.build_url("api", "xqnetwork", "portforward")%>'
        }
	}
}());
$(function(){
    $.selectBeautify();
    $.formInit();
	modelNat.init();
});

</script>
</body>
</html>

