<script type="text/javascript">
function searchname() {
    if(document.couponfrm.keyword.value.length == 0) {
        alert('未填写商铺关键字');
        return;
    }
	var keyword = document.couponfrm.keyword.value.trim();
	$.get('{$MOD[url]}', {ac:"submit",op:"searchshop",keyword:keyword }, function(result) {
        if (result.match(/id="shoplist"/)) {
            myDialog('查找商铺', result, 380, 250);
		} else {
			myAlert(result);
		}
	});
}

function insertshop(shopid,shopname) {
    document.couponfrm.keyword.value = shopname;
    document.couponfrm.shopid.value = shopid;
    myDialogClose();
}

function checksubmit(obj) {
    if(obj.pic.value.length==0) {
        alert('未选择上传的{$MOD[name]}。');
        return false;
    } else if(!document.getElementById('xuke').checked) {
        alert('您未接受此项保证。');
        return false;
    } else if(obj.shopid.value.length == 0) {
        alert('未选择优惠商铺。');
        return false;
    } else if(obj.subject.value.length == 0) {
        alert('未填写$MOD[name]主题名称。');
        return false;
    } else if(obj.describe.value.length == 0) {
        alert('未填写优惠说明。');
        return false;
    } else if(!obj.starttime.value.match(/^[0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2}$/)) {
        alert('未填写正确的开始时间。');
        return false;
    } else if(!obj.endtime.value.match(/^[0-9]{4}\-[0-9]{1,2}\-[0-9]{1,2}$/)) {
        alert('未填写正确的结束时间。');
        return false;
    } else if(obj.seccode && obj.seccode.value.length <= 3) {
        alert('未填写正确的验证码。');
        return false;
    }
    return true;
}
</script>
<div id="body">
    <div id="left">
        <div class="mainrail rail-border-1">
            <h1 class="rail-h-1 rail-h-bg-1"><strong>发布$MOD[name]保证</strong></h1>
            <p class="rail-text">此$MOD[name]系本人发布，本人承诺此优惠券真实有效，且发布优惠券行为系经商家许可之合法行为，因该优惠权或发布优惠券行为引发之责任由本人承担，与本网站无关。</p>
        </div>
    </div>
    <div id="right">
        <div class="post">
            <div class="title"><h1>发布$MOD[name]</h1>(<span class="font_1">*</span>为必填选项)</div>
            <form method="post" action="{$MOD[url]}?ac=submit" name="couponfrm" enctype="multipart/form-data" onsubmit="return checksubmit(this);">
            <table class="table" border="0" cellspacing="0" cellpadding="0">
                <tr>
                    <td align="right" width="90px"><span class="font_1">*</span>上传$MOD[name]：</td>
                    <td width="*"><input type="file" name="pic" class="f_input" /></td>
                </tr>
                <tr>
                    <input type="hidden" name="shopid" value="$shopid" />
                    <td align="right"><span class="font_1">*</span>优惠商铺：</td>
                    <td><input type="text" name="keyword" size="30" value="$shopdetail['shopname']" class="t_input" />&nbsp;
                    <button type="button" onclick="searchname();" class="button">查找商铺</button></td>
                </tr>
                <tr>
                    <td align="right"><span class="font_1">*</span>标题：</td>
                    <td><input type="text" name="subject" size="30" class="t_input" /></td>
                </tr>
                <tr>
                    <td align="right"><span class="font_1">*</span>优惠说明：</td>
                    <td><input type="text" name="describe" size="38" class="t_input" />
                    不超过10个字。<span class="font_3">例如：优惠10元</span></td>
                </tr>
                <tr>
                    <td align="right"><span class="font_1">*</span>有效期：</td>
                    <td><input type="text" name="starttime" size="15" class="t_input" />&nbsp;至&nbsp;<input type="text" name="endtime" size="15" class="t_input" />
                    格式：年-月-日。<span class="font_3">例如：2008-8-8</span></td>
                </tr>
                <tr>
                    <td align="right" valign="top">详细说明：</td>
                    <td><textarea name="content" rows="5"></textarea>
                    [<a href="javascript:;" onclick="addrows(couponfrm.content, 8);">＋增加行数</a>]&nbsp;[<a href="javascript:;" onclick="decrows(couponfrm.content, 8);">－减少行数</a>]</td>
                </tr>
                <!--{if $MOD['seccode']}-->
                <tr>
                    <td align="right">验证码：</td>
                    <td><div id="seccode"></div><input type="text" name="seccode" onfocus="show_seccode();" class="t_input" /></td>
                </tr>
                <!--{/if}-->
                <tr>
                    <td align="right"></td>
                    <td><button type="submit" value="yes" name="couponsubmit" />确认发布</button>&nbsp;&nbsp;
                    <input type="checkbox" id="xuke" /> 我接受此项保证</td>
                </tr>
            </table>
            </form>
        </div>
    </div>
</div>