<%@ page language="C#" masterpagefile="~/MasterPage/UserMasterPage.master" autoeventwireup="true" inherits="Rest_Gift_AddGift, DoodiiShop" title="Untitled Page" enableEventValidation="false" viewStateEncryptionMode="Never" %>

<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%@ Register Assembly="Brettle.Web.NeatUpload" Namespace="Brettle.Web.NeatUpload"
    TagPrefix="Upload" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<style type="text/css">
.cui{background-color:#008c00; color:#FFFFFF; width:72px;  height:25px; line-height:25px; text-align:center; margin-right:8px; cursor:pointer;}

</style>
    <script type="text/javascript">
    function getPath(obj)
    {
        if(obj)
        {
        //ie
        if (window.navigator.userAgent.indexOf("MSIE")>=1)
        {
        obj.select();
        // IE下取得图片的本地路径
        return document.selection.createRange().text;
        }
        //firefox
        else if(window.navigator.userAgent.indexOf("Firefox")>=1)
        {
        if(obj.files)
        {
        // Firefox下取得的是图片的数据
        return obj.files.item(0).getAsDataURL();
        }
        return obj.value;
        }
        return obj.value;
        }
    }
    var changeImage = function(ele) {
        var filePath = document.getElementById("<%=InputFile1.ClientID%>").value;
        if ( doodii.Web.App_Code.Common.checkImgExt(filePath).value == 0 ) {
            $("#<%=Image1.ClientID%>").attr("src", "/getImage_0_100_100_0_0_0_0.aspx");
        } else {
            $("#<%=Image1.ClientID%>").attr("src", getPath(ele));
    }
    }
    function AddClass()
    {
       location.href="/Rest/Gift/AddGiftClass.aspx";
    }
    function checkCk()
    {
       var cktg=document.getElementById("tg");
       var ckxf=document.getElementById("xf");
       var ckuv=document.getElementById("uv");
       var sptg=document.getElementById("sptg");
       var spxf=document.getElementById("spxf");
       var spuv=document.getElementById("spuv");
       
       if(cktg.checked==true && ckxf.checked==true && ckuv.checked==true)
       {alert("只能选择２种兑换方式！请取消一种再做选择");return;}
       
       if(cktg.checked==true)
       {sptg.style.display="";
       if($("#giftspread").val()=="0")
       {$("#giftspread").val("");
       }else{}
       }
       else
       {sptg.style.display="none";
        $("#giftspread").val("0");
       }
       if(ckxf.checked==true)
       {spxf.style.display="";
       if($("#giftexpend").val()=="0")
       {$("#giftexpend").val("");}else{}
       }
       else{spxf.style.display="none";$("#giftexpend").val("0")}
       
       if(ckuv.checked==true)
       {spuv.style.display=""; if($("#txtUserValue").val()=="0")
       {$("#txtUserValue").val("");}else{}
       }
       else{spuv.style.display="none";$("#txtUserValue").val("0")}
       
    }
    </script>

    <div>
        <table style="width: 100%" class="NewTable">
            <tr>
                <td>
                    类&nbsp;&nbsp;&nbsp;别：
                </td>
                <td>
                    <asp:DropDownList ID="giftclass" runat="server">
                    </asp:DropDownList>
                    &nbsp;&nbsp;<input class="cui" type="button" value="类别管理" onclick="AddClass()" /></td>
            </tr>
            <tr>
                <td>
                    礼品名称：</td>
                <td>
                    <asp:TextBox BorderStyle="Groove" ID="giftname" runat="server" Width="128px" MaxLength="20" />&nbsp;&nbsp;库存：<asp:TextBox
                        BorderStyle="Groove" ID="giftnum" runat="server" Width="40px"></asp:TextBox>&nbsp;&nbsp;积分：<input
                            type="checkbox" checked="checked" id="xf" onclick="checkCk()" style="display: none;" />
                    <span id="spxf">
                        <asp:TextBox BorderStyle="Groove" ID="giftexpend" runat="server" Width="40px" Text="0" /></span>&nbsp;排序：
                    <asp:TextBox ID="txtSort" runat="server" Text="0" Width="40px"></asp:TextBox>&nbsp;
                    <br />
                    排序数字越大，位置越靠前，默认排序为0<span style="display: none">价值：<asp:TextBox BorderStyle="Groove"
                        ID="giftworth" runat="server" Width="40px" Text="0" MaxLength="20" /></span></td>
            </tr>
            <tr style="display: none;">
                <td style="height: 25px;" colspan="10">
                    金豆<input type="checkbox" id="tg" onclick="checkCk()" />
                    <span id="sptg" style="display: none">
                        <asp:TextBox BorderStyle="Groove" ID="giftspread" runat="server" Width="94px" />
                    </span>会员价格
                    <input type="checkbox" id="uv" onclick="checkCk()" />
                    <span id="spuv" style="display: none">
                        <asp:TextBox BorderStyle="Groove" ID="txtUserValue" runat="server" Width="88px" /></span></td>
            </tr>
            <tr>
                <td>
                    礼品图片：</td>
                <td>
                    <Upload:InputFile ID="InputFile1" runat="server" Size="50" Width="356px" onchange="changeImage(this)" />
                    <br />
                    文件大小请不要超过100KB。文件类型可使用gif、jpg及png
                    <br />
                    <asp:Image ImageUrl="/getImage_0_100_100_0_0_0_0.aspx" ID="Image1" runat="server"
                        Height="150" Width="150" AlternateText="预览图片" />
                </td>
            </tr>
            <tr style="display: none;">
                <td colspan="4" style="padding-left: 3px; height: 20px">
                    &nbsp;是否推荐<input id="chIsCommend" value="1" runat="server" type="checkbox" />
                    是否新品<input id="ckIsNew" value="1" type="checkbox" runat="server" />
                </td>
            </tr>
            <tr>
                <td>
                    礼品说明：</td>
                <td style="width:568px">
                    <FCKeditorV2:FCKeditor ID="FCKNote" runat="server" ToolbarSet="bulletin">
                    </FCKeditorV2:FCKeditor>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:RadioButton ID="rdIsShow" Text="立即上架" GroupName="rdShow" runat="server" />&nbsp;<asp:RadioButton
                        ID="RdIsHide" Text="稍后上架" GroupName="rdShow" runat="server" Checked="true" /></td>
            </tr>
            <tr>
                <td style="text-align: center; height: 24px;" colspan="2">
                    <asp:Button ID="SubmitBT" CssClass="cui" runat="server" Text="提交" OnClick="SubmitBT_Click" /></td>
            </tr> 
        </table>
    </div>
</asp:Content>
