<%@ Page Language="C#" MasterPageFile="~/Admin/MainPage.Master" AutoEventWireup="true"
    Codebehind="SpecificationEdit.aspx.cs" Inherits="PPFOR.Admin.ContentArea.Product.SpecificationEdit"
    Title="修改规格" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_mainContent" runat="server">
    <script type="text/javascript" src="../../JS/specValue.js"></script>
    <script type="text/javascript" src="/ckfinder/ckfinder.js"></script>   
    <script language="javascript" type="text/javascript">          
    function changeSpecType()
    {
        var isImage=document.getElementById('<%=PPFOR_specImageType.ClientID %>').checked;   
        var objTable=document.getElementById('specValueTable');      
        hideCol=isImage ? -1 : 1;
        for(var i=0;i<objTable.rows.length;i++){   
            for(var j=0;j<objTable.rows[i].cells.length;j++){
                if(j==hideCol){
                    objTable.rows[i].cells[j].style.display='none';  
                }else if(objTable.rows[i].cells[j].style.display=='none'){
                    objTable.rows[i].cells[j].style.display='';  
                }
            }
        }
    }
    var finder = new CKFinder();
    finder.BasePath = '/ckfinder/';
    finder.ResourceType="Images";
    finder.RememberLastFolder=true;
    finder.PrintWaterImage=false;
    function BrowseServer( functionData )
    {  
        finder.SelectFunction = checkThumbnailAuto
        finder.SelectFunctionData = functionData ;
        finder.SelectThumbnailFunction = checkThumbnailAuto ;
        finder.SelectThumbnailFunctionData = functionData ;
        finder.DisableThumbnailSelection=false;
	    finder.Popup();        
    }
    function checkThumbnailAuto(fileUrl, data)
    {
        var target=document.getElementById('imgUrl_' + (data["selectFunctionData"] || data["selectThumbnailFunctionData"]));
        var targetImg=document.getElementById('specValueImg_' + (data["selectFunctionData"] || data["selectThumbnailFunctionData"]));
        if(target!=null && targetImg!=null)
        {            
            if(fileUrl.indexOf(finder.RootUrl)==0)
            {
                if(fileUrl.indexOf(finder.RootUrl + '_thumbs/')==0){
                    target.value=fileUrl; 
                }
                else{                
                    target.value=fileUrl.replace(finder.RootUrl,finder.RootUrl + '_thumbs/');                    
                }
                targetImg.src=target.value;
            }  
        }
    }
    </script>
    <form action="SpecificationEdit.aspx" id="form1" runat="server" onsubmit="return checkSpecValues();">       
        <table width="100%" border="0" cellpadding="0" cellspacing="0"  class="fortable">
        <thead>
            <tr>
                <td align="center" colspan="2">修改规格</td>
            </tr>
        </thead>
        <tr>
            <td style="width:15%" align="right">规格名称：</td>
            <td>
                <asp:TextBox ID="PPFOR_specName" runat="server" Text="" Width="300px" MaxLength="20"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_specName"><br />规格名称不能为空</asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_specName" ValidationExpression="^[^<>\x22]{1,20}$"><br />规格名称长度必须在1至20个字符之间，且不能包含以下字符之一：<，>，"</asp:RegularExpressionValidator>
                <asp:Label ID="PPFOR_specID" runat="server" Enabled="false" Visible="false"></asp:Label>
            </td>
        </tr>     
        <tr>
            <td align="right">规格备注：</td>
            <td>
                <asp:TextBox ID="PPFOR_specDescription" runat="server" Text="" Width="90%" MaxLength="255"></asp:TextBox>
            </td>
        </tr>   
        <tr>
            <td align="right">显示类型：</td>
            <td>
                <asp:RadioButton GroupName="image" ID="PPFOR_specTextType" runat="server" Text="文字" Checked="true" />
                <asp:RadioButton ID="PPFOR_specImageType" GroupName="image" runat="server" Text="图片" />
            </td>
        </tr>     
        <tr>
            <td align="right">显示方式：</td>
            <td>
                <asp:RadioButton GroupName="downlist" ID="PPFOR_specTileStyle" runat="server" Text="平铺显示" Checked="true" />
                <asp:RadioButton ID="PPFOR_specDownlistStyle" GroupName="downlist" runat="server" Text="下拉显示" />
            </td>
        </tr>  
         <tr>
            <td align="right">规格排序：</td>
            <td>
                <asp:TextBox ID="PPFOR_sort" runat="server" Text="0" MaxLength="4"></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="PPFOR_sort" Display="Dynamic" SetFocusOnError="true" Type="Integer" MinimumValue="-999" MaximumValue="9999">规格排序只能填写-999至9999之间的整数</asp:RangeValidator>
            </td>
        </tr>
        </table>
        <br />
        <input type="button" class="blueinput" value="添加规格值" onclick="addSpecValue();" />
        <table width="100%" border="0" cellpadding="0" cellspacing="0"  class="fortable" style="margin-top:5px;margin-bottom:5px;" id="specValueTable">  
        <thead>
            <tr>
                <td style="width:35%" align="center">规格值名称</td>             
                <td align="center">规格图片</td>
                <td align="center">排序</td>
                <td align="center">操作</td>
            </tr>           
        </thead>
        <tr style="display:none; height:0px;">
            <td colspan="4">&nbsp;</td>
        </tr>    
        </table>
        <input type="button" class="blueinput" value="添加规格值" onclick="addSpecValue();" />
        <br />
        <br />
        <table>                          
        <tr>
            <td colspan="2" style="width:100%; height:50px; display:none" align="center" valign="middle">
                <asp:Button ID="PPFOR_updateSpecification" CssClass="inputbutton" runat="server" Text="提交" OnClick="PPFOR_updateSpecificationClick" />
                <input name="reset" type="reset" id="reset1" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" onclick="location.reload();" value="重置" />
                <script type="text/javascript">
                    addButtonArray("<%= PPFOR_updateSpecification.ClientID %>","reset1");
                </script> 
            </td>               
        </tr>
    </table>
    </form>
</asp:Content>
