<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../KS_Cls/Kesion.CommonCls.asp"-->
<!--#include file="../KS_Cls/Kesion.AdministratorCls.asp"-->
<!--#include file="../KS_Cls/Kesion.Label.CommonCls.asp"-->
<!--#include file="Include/Session.asp"-->
<%

Dim KSCls
Set KSCls = New Admin_Shop
KSCls.Kesion()
Set KSCls = Nothing

Class Admin_Shop
        Private KS,KSCls
		'=====================================定义本页面全局变量=====================================
		Private ID, I, totalPut, Page, RS,ComeFrom
		Private FolderName, CreateDate, TempStr,UnionShopID
		Private IsChangedBuy,ChangeBuyNeedPrice,ChangeBuyPresentPrice
		Private IsLimitbuy,LimitBuyPrice,LimitBuyAmount,LimitBuyTaskID
		
		Private KeyWord, SearchType, StartDate, EndDate, VerificTF, SearchParam
		Private MaxPerPage,UserDefineFieldArr,UserDefineFieldValueStr
		Private T, TitleStr, VerificStr, ShortName, SpecialID,FileName
		Private TypeStr,AttributeStr,HitsByDay, HitsByWeek, HitsByMonth
		Private FolderID,TN, TI, TJ,Action,TemplateID,GroupPrice,ProductID
		Private ProID, Title, PhotoUrl,BigPhoto, ProIntro,Recommend,IsSpecial,IsTop
		Private Popular, Verific,Strip, Comment, Slide,Rolls, KeyWords,ProSpecificat, ProModel,ServiceTerm, ProducerName, TrademarkName, AddDate, Rank, Hits,Unit, TotalNum, AlarmNum,ProductType,Discount, Price_Market,Price_Original,Price_Member,Price,Point,BrandID
		Private CurrPath,UpPowerFlag
		Private Inputer,ComeUrl,AttributeCart,Weight
		Private SqlStr,Errmsg,Makehtml,FnameType,Tid,Fname,KSRObj
		Private ChannelID,F_B_Arr
		'=============================================================================================
		Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		 Set KSCls=Nothing
		End Sub
		Public Sub Kesion()
		ChannelID=KS.ChkClng(KS.G("ChannelID"))
		If ChannelID=0 Then ChannelID=5
		Session("ThumbnailsConfig")=KS.C_S(ChannelID,46)
		
		If KS.G("page") <> "" Then
			  Page = KS.ChkClng(KS.G("page"))
		Else
			  Page = 1
		End If
		If Instr(Request("action"),"LimitBuy")<>0 then
            If Not KS.ReturnPowerResult(5, "M520008") Then                  '权限检查
			 Call KS.ReturnErr(1, "")   
			 Response.End()
		    End If	
		ElseIf Instr(Request("action"),"Package")<>0 then
            If Not KS.ReturnPowerResult(5, "M520011") Then                  '权限检查
			 Call KS.ReturnErr(1, "")   
			 Response.End()
		    End If	
		end if
		
		Select Case Request("action")
		  case "StockAlarm" StockAlarm:Exit Sub
		  cASE "BatchSaveStock" BatchSaveStock
		  case "Packprolist" Packprolist:Exit Sub
		  case "BatchSave" BatchSave
		   case "SetKBXSPrice" SetKBXSPrice:Exit Sub
		   case "BundleSale" BundleSale:Exit Sub
		   case "DelBundleSale" DelBundleSale:Exit Sub
		End Select
		
		F_B_Arr=Split(KS.C_S(ChannelID,5),"|")

		'收集搜索参数
		KeyWord   = KS.G("KeyWord")
		SearchType= KS.G("SearchType")
		StartDate = KS.G("StartDate")
		EndDate   = KS.G("EndDate")
		Action     = KS.G("Action")
		ComeFrom   = KS.G("ComeFrom")
		SearchParam = "ChannelID=" & ChannelID
		If KeyWord<>"" Then SearchParam=SearchParam & "&KeyWord=" & KeyWord
		If SearchType<>"" Then  SearchParam=SearchParam & "&SearchType=" & SearchType
		If StartDate<>"" Then SearchParam=SearchParam & "&StartDate=" & StartDate 
		If EndDate<>"" Then SearchParam=SearchParam & "&EndDate=" & EndDate
		If KS.S("Status")<>"" Then SearchParam=SearchParam & "&Status=" & KS.S("Status")
		If ComeFrom<>"" Then SearchParam=SearchParam & "&ComeFrom=" & ComeFrom
		
		ComeUrl=Cstr(Request.ServerVariables("HTTP_REFERER"))
		
		IF KS.G("Method")="Save" Then
				 Call DoSave()
		Else 
				 Call ShopAdd()
		End If
	   End Sub
	   
	   
	
	   
	 
	   
	  
	   
	   '批量设置库存
	   Sub BatchSaveStock()
	    Dim ID:ID=KS.G("ID")
		If ID="" Then KS.AlertHintScript "对不起,请先选择要补货的商品"
		Dim i,IDArr
		IDArr=Split(KS.FilterIDs(ID),",")
		For i=0 to ubound(idArr)
		  Conn.Execute("Update Product Set alarmnum=" & KS.ChkClng(KS.G("alarmnum"&idArr(i))) & ",totalNum=" & KS.ChkClng(KS.G("totalnum"&idArr(i))) &" Where ID=" & Idarr(i))
		Next
		KS.AlertHintScript "恭喜,批量补货成功!"
	   End Sub

	   
	   '库存报警管理
	   Sub StockAlarm()
	        If Not KS.ReturnPowerResult(5, "M520012") Then                  '权限检查
			 Call KS.ReturnErr(1, "")   
			 Response.End()
		    End If		   

		 With Response
			  .Write "<html>"
			  .Write"<head>"
			  .Write"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
			  .Write"<link href=""Include/Admin_Style.CSS"" rel=""stylesheet"" type=""text/css"">"
			  .Write "<script src=""../Inc/common.js"" language=""JavaScript""></script>"
			  %>
			  <script type="text/javascript">
			  function regInput(obj, reg, inputStr)
				{
					var docSel = document.selection.createRange()
					if (docSel.parentElement().tagName != "INPUT")    return false
					oSel = docSel.duplicate()
					oSel.text = ""
					var srcRange = obj.createTextRange()
					oSel.setEndPoint("StartToStart", srcRange)
					var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
					return reg.test(str)
				}
			  </script>
			  <%
			  .Write "<script language='JavaScript' src='../Inc/jquery.js'></script>" & vbCrLf
			  .Write"</head>"
			  .Write"<body leftmargin=""0"" topmargin=""0"" marginwidth=""0"" marginheight=""0"">"
			  .Write "<div class=""topdashed sort"">以下商品库存量已不足，请及时补货</div>"
			  .Write  "<table width='100%' border='0' align='center' cellspacing='0' cellpadding='0'>"
              .Write "   <tr height='25' align='center' class='sort'>"
	          .Write "   <td width='5%' nowrap>序号</td>"
	          .Write "   <td>小图</td>"
	          .Write "   <td>商品名称</td>"
			  .Write "	 <td>当前库存量</td>"
			  .Write "   <td>报警库存量</td>"
			  .Write " </tr>"
			  .Write "<form name='myform' action='?' method='get'>"
			  .Write "<input type='hidden' name='action' value='BatchSaveStock'>"
			  
			  Dim XML,Node,Param,TotalPages,PhotoUrl
			  MaxPerPage=100
			  Param=" totalnum<=AlarmNum"
			  SQLStr=KS.GetPageSQL("Product","id",MaxPerPage,Page,1,Param,"*")
		      Set RS = Server.CreateObject("AdoDb.RecordSet")
		      RS.Open SQLStr, conn, 1, 1
			  If RS.EOF Then
					 .Write "<tr onmouseout=""this.className='list'"" onmouseover=""this.className='listmouseover'"">"
					 .Write "<td align='center' height='25' class='splittd' colspan=10>还没有发现库存量不足的商品!</td>"
					 .Write "</tr>"
			  Else
					totalPut = Conn.Execute("Select count(id) from [Product] where " & Param)(0)
					if (TotalPut mod MaxPerPage)=0 then
						TotalPages = TotalPut \ MaxPerPage
					else
						TotalPages = TotalPut \ MaxPerPage + 1
					end if
					if Page > TotalPages then Page=TotalPages
					Set XML=KS.ArrayToXml(RS.GetRows(MaxPerPage),RS,"row","")
					For Each Node In XML.DocumentElement.SelectNodes("row")
					 PhotoUrl=Node.SelectSingleNode("@photourl").text
					 If KS.IsNul(PhotoUrl) Then PhotoUrl="../images/nopic.gif"
					 .Write "<tr onmouseout=""this.className='list'"" onmouseover=""this.className='listmouseover'"">"
					 .Write "<td align='center' class='splittd'>" & Node.SelectSingleNode("@id").text & "<input type='hidden' name='id' value='" & Node.SelectSingleNode("@id").text & "'></td>"
					 .Write "<td align='center' class='splittd'><Img src='" &PhotoUrl & "' width='40' height='40' /></td>"
					 .Write "<td class='splittd'>" & KS.Gottopic(Node.SelectSingleNode("@title").text,40) & "</td>"
					 .Write "<td align='center' class='splittd'><input onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" class='textbox' type='text' name='totalnum" & Node.SelectSingleNode("@id").text & "' value='" & Node.SelectSingleNode("@totalnum").text & "' size='5' style='text-align:center'> " & Node.SelectSingleNode("@unit").text & "</td>"
					 .Write "<td align='center' class='splittd'><input onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" class='textbox' type='text' name='alarmnum" & Node.SelectSingleNode("@id").text & "' value='" & Node.SelectSingleNode("@alarmnum").text & "' size='5' style='text-align:center'> " & Node.SelectSingleNode("@unit").text &"</td>"
					 .Write "</tr>"
					Next
	         End If
			 .Write "<tr onmouseout=""this.className='list'"" onmouseover=""this.className='listmouseover'"">"
			 .Write "<td colspan=10>&nbsp;<input type='submit' value='保存批量补货' class='button'> "
			 .Write "</tr>"
			 .Write "</form>"
			 .Write "</table>"
			 
			  Call KS.ShowPage(totalput, MaxPerPage, "", Page,true,true)
			 RS.Close
			 Set RS=Nothing

		End With
		%>
		<br/><br/><br/>
		<div class="attention" style="clear:both">
		<font color=red>说明：这里只显示库存量少于等于库存量报警的商品，为保证客户顺利购买商品，请对库存量不多的商品及时补货。</font>
		</div><br/>
		<%
	   End Sub
	   
	   
	   
	   
	   
	   
	   

       Sub ShopAdd() 
			With Response
			.Write"<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">"
			.Write "<html xmlns=""http://www.w3.org/1999/xhtml"">"
			.Write "<head>" & vbCrlf
			.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrlf
			.Write "<title>添加商品</title>" & vbCrlf
			.Write "<link href='Include/Admin_Style.CSS' rel='stylesheet' type='text/css'>" & vbCrlf
			.Write "<script language='JavaScript' src='../Inc/common.js'></script>" & vbCrlf
			.Write "<script language='JavaScript' src='../Inc/JQuery.js'></script>" & vbCrlf
			.Write "<script language=""javascript"" src=""../KS_Inc/popcalendar.js""></script>" & vbCrlf
			.Write "<script src=""images/pannel/tabpane.js"" language=""JavaScript""></script>"
			.Write "<link href=""images/pannel/tabpane.CSS"" rel=""stylesheet"" type=""text/css"">"
		    .Write "<script type=""text/javascript"" src=""../editor/ckeditor.js"" mce_src=""../editor/ckeditor.js""></script>"
			.Write "<script language='javascript' src='../inc/box.js'></script>"
			CurrPath = KS.GetUpFilesDir()
			Session("UploadFileIDs")=""   '上传附件的ID
						
			Set RS = Server.CreateObject("ADODB.RecordSet")
			If Action = "Add" Then
			  FolderID = Trim(KS.G("FolderID"))
			  If Not KS.ReturnPowerResult(ChannelID, "M" & ChannelID & "10002") Then          '检查是否有添加商品的权限
			   .Write ("<script>$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?ButtonSymbol=ViewFolder&FolderID=" & FolderID & "';</script>")
			   Call KS.ReturnErr(2, "KS.ItemInfo.asp?ChannelID=" & ChannelID & "&Page=" & Page & "&ID=" & FolderID)
			   Exit Sub
			  End If
			  ProductID=0: ProductType=1:Discount=9:Hits = 0:HitsByDay = 0: HitsByWeek = 0:HitsByMonth = 0:TotalNum = 1000: AlarmNum = 10:Comment = 1:GroupPrice=0:BrandID=0:Strip=0:IsChangedBuy=0:Weight=0
			  
				IsLimitbuy = 0
				LimitBuyPrice = 100
				LimitBuyAmount = 100

			  
			  
			  ProID = KS.GetInfoID(ChannelID)
			  KeyWords = Session("keywords")
			  ProducerName = Session("ProducerName")
			  TrademarkName = Session("TrademarkName")
			ElseIf Action = "Edit" Or Action="Verify" Then
			   Set RS = Server.CreateObject("ADODB.RECORDSET")
			   RS.Open "Select top 1 * From Product Where ID=" & KS.G("ID"), conn, 1, 1
			   If RS.EOF And RS.BOF Then Call KS.Alert("参数传递出错!", ComeUrl):Exit Sub
				ID = Trim(RS("ID"))
				FolderID = Trim(RS("Tid"))
				If Not KS.ReturnPowerResult(ChannelID, "M" & ChannelID & "10003") Then     '检查是否有编辑商品的权限
				RS.Close:Set RS = Nothing
				 If KeyWord = "" Then
				  .Write ("<script>$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?ButtonSymbol=ViewFolder&FolderID=" & FolderID & "';</script>")
				  Call KS.ReturnErr(1, "KS.Shop.asp?Page=" & Page & "&ID=" & FolderID)
				 Else
				  .Write ("<script>$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?OpStr=" & server.URLEncode("商品管理 >> <font color=red>搜索商品结果</font>") & "&ButtonSymbol=ShopSearch';</script>")
				  Call KS.ReturnErr(1, "KS.Shop.asp?Page=" & Page & "&KeyWord=" & KeyWord & "&SearchType=" & SearchType & "&StartDate=" & StartDate & "&EndDate=" & EndDate)
				 End If
				 Exit Sub
			   End If
			    ProductID=RS("ID")
				ProID=RS("ProID")
				Title = Trim(RS("title"))
				PhotoUrl = Trim(RS("PhotoUrl"))
				BigPhoto=Trim(RS("BigPhoto"))
				BigPhoto = Trim(RS("BigPhoto"))
				ProIntro = Trim(RS("ProIntro"))
				Rolls = CInt(RS("Rolls"))
				Recommend = CInt(RS("Recommend"))
				Popular = CInt(RS("Popular"))
				Verific = CInt(RS("Verific"))
				Comment = CInt(RS("Comment"))
				Slide = CInt(RS("Slide"))
				IsSpecial =RS("IsSpecial")
				IsTop = RS("IsTop")
				Strip = RS("Strip")
				AddDate = CDate(RS("AddDate"))
				Rank = Trim(RS("Rank"))
                FileName= RS("Fname")
				TemplateID = RS("TemplateID")
				Hits = Trim(RS("Hits"))
				HitsByDay = Trim(RS("HitsByDay"))
				HitsByWeek = Trim(RS("HitsByWeek"))
				HitsByMonth = Trim(RS("HitsByMonth"))
				IsChangedBuy=RS("IsChangedBuy")
				ChangeBuyNeedPrice=RS("ChangeBuyNeedPrice")
				ChangeBuyPresentPrice=RS("ChangeBuyPresentPrice")
				Weight=RS("Weight")
				IsLimitbuy = KS.ChkClng(RS("IsLimitBuy"))
				LimitBuyPrice = RS("LimitBuyPrice")
				LimitBuyTaskID= RS("LimitBuyTaskID")
				LimitBuyAmount = KS.ChkCLng(RS("LimitBuyAmount"))
				
				
				Unit= Trim(RS("Unit"))
				TotalNum = Trim(RS("TotalNum"))
				AlarmNum = Trim(RS("AlarmNum"))
				ProductType=RS("ProductType")
				Price= RS("Price")
				Discount=RS("Discount")
				Price_Original=RS("Price_Original")
				GroupPrice = RS("GroupPrice")
				Price_Member=RS("Price_Member")
				Price_Market = Trim(RS("Price_Market"))
				KeyWords = Trim(RS("KeyWords"))
				ProducerName = Trim(RS("ProducerName"))
				TrademarkName = Trim(RS("TrademarkName"))
				ProModel= RS("ProModel")
				ProSpecificat=RS("ProSpecificat")
				ServiceTerm=RS("ServiceTerm")
				FolderID = RS("Tid")
				Point=RS("Point")
				BrandID=RS("BrandID")
				AttributeCart=RS("AttributeCart")
				'自定义字段
				UserDefineFieldArr=KSCls.Get_KS_D_F_Arr(ChannelID)
				If IsArray(UserDefineFieldArr) Then
				For I=0 To Ubound(UserDefineFieldArr,2)
				  Dim UnitOption
				  If UserDefineFieldArr(12,I)="1" Then
				   UnitOption="@" & RS(UserDefineFieldArr(0,I)&"_Unit")
				  Else
				   UnitOption=""
				  End If
				  If I=0 Then
				    UserDefineFieldValueStr=RS(UserDefineFieldArr(0,I))& UnitOption & "||||"
				  Else
				    UserDefineFieldValueStr=UserDefineFieldValueStr  & RS(UserDefineFieldArr(0,I))& UnitOption & "||||"
				  End If
				Next
			  End If
				RS.Close:Set RS = Nothing
			End If
			If KS.IsNul(AttributeCart) Then AttributeCart=""
			'取得上传权限
			UpPowerFlag = KS.ReturnPowerResult(ChannelID, "M" & ChannelID & "10009")
			.Write "<script>var BigPhoto='" & BigPhoto & "';</script>" & vbCrlf
			%>
			<script>
		    $(document).ready(function(){
				$(parent.frames["BottomFrame"].document).find("#Button1").attr("disabled",false);
				$(parent.frames["BottomFrame"].document).find("#Button2").attr("disabled",false);
				$('#KeyLinkByTitle').click(function(){
			     GetKeyTags();
			    });
				$('#checkProIdButton').click(function(){
				  CheckProIdRepeat();
				});
				
		    })
            function GetKeyTags()
			{
			  var text=escape($('input[name=Title]').val());
			  if (text!=''){
				  $('#KeyWords').val('请稍等,系统正在自动获取tags...').attr("disabled",true);
				  $.get("../plus/ajaxs.asp", { action: "GetTags", text: text,maxlen: 20 },
				  function(data){
					$('#KeyWords').val(unescape(data)).attr("disabled",false);
				  });
			  }else{
			   alert('对不起,请先输入商品名称!');
			  }
			}
			function CheckProIdRepeat(){
			 var text=$('input[name=proid]').val();
			 if(text!=''){
			    if (text.length<8){
				 alert('编号长度不能小于8位!');
				}else{
				 $(parent.frames["FrameTop"].document).find("#ajaxmsg").toggle(true);
				 $.get("../plus/ajaxs.asp",{action:"Shop_CheckProID",proid:escape(text),id:<%=ProductID%>},function(d){
				 $(parent.frames["FrameTop"].document).find("#ajaxmsg").toggle(false);
				 alert(unescape(d));
				 });
				}
			 }else{
			  alert('请输入商品编号!');
			  $("input[name=proid]").focus();
			 }
			}
			function UnSelectAll(){
			  $("#SpecialID>option").each(function(){
				$(this).attr("selected",false);
				});
			}
			function displaydiscount(){
			 if (document.myform.ProductType[2].checked==true)
			   $('#discountarea').show();
			 else
			   $('#discountarea').hide();
			}
			function getprice(Price_Original){
			  if(Price_Original==''|| isNaN(Price_Original)){Price_Original=0;}
			  if(document.myform.ProductType[2].checked==true){
			  document.myform.Price.value=Math.round(Price_Original*Math.abs(document.myform.Discount.value/10)*100)/100;
			  }
			  else{document.myform.Price.value=Price_Original;}
			  document.myform.Price_Market.value=document.myform.Price.value;
			}
			function regInput(obj, reg, inputStr)
			{
				var docSel = document.selection.createRange()
				if (docSel.parentElement().tagName != "INPUT")    return false
				oSel = docSel.duplicate()
				oSel.text = ""
				var srcRange = obj.createTextRange()
				oSel.setEndPoint("StartToStart", srcRange)
				var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
				return reg.test(str)
			}
			function GetFileNameArea(f)
			{
			  $('#filearea').toggle(f);
			}
			function GetTemplateArea(f)
			{
			   $('#templatearea').toggle(f);
			}
			function insertHTMLToEditor(codeStr) 
			{ 
			 CKEDITOR.instances.Content.insertHtml(codeStr);
			} 
            function SelectAllUnion(){
			  $("select[name=UnionShopID]>option").each(function(){
				$(this).attr({"selected":true});
				});
			}
			function UnSelectAllUnion(){
			  $("select[name=UnionShopID]>option").each(function(){
				$(this).attr({"selected":false});
				});
			}
			function SubmitFun()
			{   if ($('input[name=title]').val()==""){
					alert("请输入商品名称！");
					$('input[name=title]').focus();
					return;
				}
				if ($('input[name=proid]').val()==""){
				    alert("请输入商品编号!");
					$('input[name=proid]').focus();
					return;
				}
				 if ($('#tid').val()=='0' || $('#tid').val()==''){
				    alert('请选择商品栏目!');
					return ;
				 }
				  if ($('#Unit').val()==""){
				    alert("商品单位不能为空!");
					$('#Unit').focus();
					return;
				  }
				  if ($('input[name=Price_Original]').val()==""){
				   alert("商品的原始零售价不能为空!");
				   $('input[name=Price_Original]').focus();
				   return;
				  }
				if ($("#BeyondSavePic").attr("checked")==true) {
				   $("#LayerPrompt").show();
				  window.setInterval('ShowPromptMessage()',150)
				 }
				  $('#myform').submit();
				  $(parent.frames["BottomFrame"].document).find("#Button1").attr("disabled",true);
				  $(parent.frames["BottomFrame"].document).find("#Button2").attr("disabled",true);
			}

			function getBrandList(v)
			{
			  if (v==0)
			  $("#brandarea").html("");
			  else
			  {
			   $(parent.frames["FrameTop"].document).find("#ajaxmsg").toggle(true);
			   var url='../plus/ajaxs.asp';
			   $.get(url,{action:"Shop_BrandOption",classid:$("#tid").val()},function(d){
			   $(parent.frames["FrameTop"].document).find("#ajaxmsg").toggle(false);
			   $("#brandarea").html(unescape(d));
			   });
 
			  }
			}
			var ForwardShow=true;
			function ShowPromptMessage()
			{
				var TempStr=ShowArticleArea.innerText;
				if (ForwardShow==true)
				{
					if (TempStr.length>4) ForwardShow=false;
					ShowArticleArea.innerText=TempStr+'.';
					
				}
				else
				{
					if (TempStr.length==1) ForwardShow=true;
					ShowArticleArea.innerText=TempStr.substr(0,TempStr.length-1);
				}
			}
			
			
			var SaveBeyondInfo=''
					   +'<div id="LayerPrompt" style="position:absolute; z-index:1; left: 200px; top: 150px; background-color: #f1efd9; layer-background-color: #f1efd9; border: 1px none #000000; width: 360px; height: 63px; display: none;"> '
					   +'<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FF0000">'
					   +'<tr> '
					   +'<td align="center">'
					   +'<table width="80%" border="0" cellspacing="0" cellpadding="0">'
					   +'<tr>'
					   +' <td width="75%" nowrap>'
					   +'<div align="right">请稍候，系统正在保存远程图片到本地</div></td>'
					   +'   <td width="25%"><font id="ShowArticleArea">&nbsp;</font></td>'
					   +' </tr>'
					   +'</table>'
					   +'</td>'
					   +'</tr>'
					   +'</table>'
					   +'</div>'
			document.write (SaveBeyondInfo)
			</script>
			<%
			.Write "</head>"
			.Write "<body leftmargin='0' topmargin='0' marginwidth='0' onkeydown='if (event.keyCode==83 && event.ctrlKey) SubmitFun();' marginheight='0'>"
			.Write "<div align='center'>"
			.Write "<ul id='menu_top'>"
			.Write "<li onclick=""return(SubmitFun())"" class='parent'><span class=child onmouseover=""this.parentNode.className='parent_border'"" onMouseOut=""this.parentNode.className='parent'""><img src='images/ico/save.gif' border='0' align='absmiddle'>确定保存</span></li>"
			.Write "<li onclick=""history.back();"" class='parent'><span class=child onmouseover=""this.parentNode.className='parent_border'"" onMouseOut=""this.parentNode.className='parent'""><img src='images/ico/back.gif' border='0' align='absmiddle'>取消返回</span></li>"
		    .Write "</ul>"			
			
           .Write "<div class=tab-page id=ShopPane>"
			.Write " <SCRIPT type=text/javascript>"
			.Write "   var tabPane1 = new WebFXTabPane( document.getElementById( ""ShopPane"" ), 1 )"
			.Write " </SCRIPT>"
					 
			.Write " <div class=tab-page id=basic-page>"
			.Write "  <H2 class=tab>基本信息</H2>"
			.Write "	<SCRIPT type=text/javascript>"
			.Write "				 tabPane1.addTabPage( document.getElementById( ""basic-page"" ) );"
			.Write "	</SCRIPT>"
			.Write " <TABLE width='100%' BORDER='0' cellpadding='1'  cellspacing='1' class='ctable'>"
			.Write "    <form action='?ChannelID=" & ChannelID & "&Method=Save' method='post' id='myform' name='myform' onsubmit='return(SubmitFun())'>"
			.Write "      <input type='hidden' value='" & ProductID & "' name='ProductID'>"
			.Write "      <input type='hidden' value='" & Action & "' name='Action'>"
			.Write "      <input type='hidden' name='Page' value='" & Page & "'>"
			.Write "      <input type='hidden' name='KeyWord' value='" & KeyWord & "'>"
			.Write "      <input type='hidden' name='SearchType' value='" & SearchType & "'>"
			.Write "      <Input type='hidden' name='StartDate' value='" & StartDate & "'>"
			.Write "      <input type='hidden' name='EndDate' value='" & EndDate & "'>"
			.Write "            <tr class='tdbg'>"
			.Write "                <td width='85' class='clefttitle'><div align='right'><font color='#FF0000'><strong>商品名称:</strong></font></div></td>"
			.Write "                <td> "
			.Write "                  <input name='title' type='text'  class='textbox' value='" & Title & "' size=40><font color='#FF0000'>*</font>  <input type='checkbox' name='MakeHtml' value='1' checked>立即发布 </td>"
			.Write "              </tr>"
			.Write "            <tr class='tdbg'>"
			.Write "                <td class='clefttitle' align='right'><strong>商品编号:</strong></td>"
			.Write "                <td>"
			.Write "                 <input name='proid' type='text' id='proid' class='textbox' value='" & proid & "' size=20> <input type='button' value='检测重复' id='checkProIdButton' class='button'><font color=green>所指定的商品号必须唯一</font><span id='cmsg'></span>"
			.Write "              </tr>"
			.Write "              <tr class='tdbg'>"
			.Write "                <td class='clefttitle' align='right'><strong>归属栏目:</strong></td>"
			.Write "                <td>"
			
			.Write " <select size='1' name='tid' id='tid' onchange='getBrandList(1)'><option value='0'>--请选择栏目--</option>"
			.Write Replace(KS.LoadClassOption(ChannelID,true),"value='" & FolderID & "'","value='" & FolderID &"' selected") & " </select>"

			.Write "属性:"
			.Write "                                 <input name='Recommend' type='checkbox' id='Recommend' value='1'"
			If Recommend = "1" Then .Write (" Checked")
			.Write ">"

			.Write "                                推荐"
			.Write "                                <input name='IsSpecial' type='checkbox' id='IsSpecial' value='1'"
			If IsSpecial = "1" Then .Write (" Checked")
			.Write ">"
			.Write "                                特价"
			.Write "                                <input name='Popular' type='checkbox' id='Popular' value='1'"
			If Popular = "1" Then .Write (" Checked")
			.Write ">"
			.Write "                                热卖"
			.Write "                                <input name='Verific' type='checkbox' id='Verific' value='1'"
			If Action <> "Edit" Then
			 .Write (" checked")
			ElseIf Verific = "1" Then
			.Write (" Checked")
			End If
			.Write ">"
			.Write "                                正常销售"
			.Write "                                <input name='Comment' type='checkbox' id='Comment' value='1'"
			If Comment = "1" Then .Write (" Checked")
			.Write ">"
			.Write "                                允许评论"
			.Write "                                <input name='IsTop' type='checkbox' id='IsTop' value='1'"
			If IsTop = "1" Then .Write (" Checked")
			.Write ">"
			.Write "                                置顶"
			.Write "                                <input name='Rolls' type='checkbox' id='Rolls' value='1'"
			If Rolls = "1" Then .Write (" Checked")
			.Write ">"
			.Write "                                滚动"
			.Write "                                <input name='Slide' type='checkbox' id='Slide' value='1'"
			If Slide = "1" Then .Write (" Checked")
			.Write ">幻灯"
			.Write "                                <input name='Strip' type='checkbox' id='Strip' value='1'"
			If Strip = "1" Then .Write (" Checked")
			.Write ">头条"
		    .Write "             </td>"
			.Write "             </tr>"
			
			.Write "              <tr class='tdbg' style='height:25px'>"
			.Write "                <td  class='clefttitle' align='right'><strong>商品小图:</strong></td>"
			.Write "                <td height='25' width='92%'  nowrap> <input name='PhotoUrl' type='text' id='PhotoUrl' size='30' value='" & PhotoUrl & "' class='textbox'>"
			.Write "   &nbsp;<input class=""button"" type='button' name='Submit' value='选择商品小图片...' onClick=""OpenThenSetValue('Include/SelectPic.asp?ChannelID=5&CurrPath=" & CurrPath & "',550,290,window,document.myform.PhotoUrl);""> <input class=""button"" type='button' name='Submit' value='远程抓取小图片...' onClick=""OpenThenSetValue('Include/Frame.asp?FileName=SaveBeyondfile.asp&PageTitle='+escape('抓取远程图片')+'&ItemName=小图片&CurrPath=" & CurrPath & "',300,100,window,document.myform.PhotoUrl);"">"
		.Write "        <input class=""button""  type='button' name='Submit' value='裁剪...' onClick=""if($('#PhotoUrl').val()==''){alert('请选择图片或是上传后再使用此功能');return false;}else{OpenImgCutWindow(1,'" & KS.Setting(3) & "',$('#PhotoUrl').val())}"">  "
			.Write "            </td>"
			.Write "              </tr>"
			
			.Write "              <tr class='tdbg' style='height:25px'>"
			.Write "                <td  class='clefttitle' align='right'><strong>商品大图:</strong></td>"
			.Write "                <td> <input name='BigPhoto' type='text' id='BigPhoto' size='30' value='" & BigPhoto & "' class='textbox'>"
			.Write "   &nbsp;<input class=""button"" type='button' name='Submit' value='选择商品大图片...' onClick=""OpenThenSetValue('Include/SelectPic.asp?ChannelID=5&CurrPath=" & CurrPath & "',550,290,window,document.myform.BigPhoto);""> <input class=""button"" type='button' name='Submit' value='远程抓取大图片...' onClick=""OpenThenSetValue('Include/Frame.asp?FileName=SaveBeyondfile.asp&PageTitle='+escape('抓取远程图片')+'&ItemName=大图片&CurrPath=" & CurrPath & "',300,100,window,document.myform.BigPhoto);"">"
		.Write "        <input class=""button""  type='button' name='Submit' value='裁剪...' onClick=""if($('#BigPhoto').val()==''){alert('请选择图片或是上传后再使用此功能');return false;}else{OpenImgCutWindows(1,'" & KS.Setting(3) & "',$('#BigPhoto').val(),$('#BigPhoto')[0])}"">  "
			.Write "            </td>"
			.Write "              </tr>"
			
		If CBool(UpPowerFlag) = True Then
		.Write "              <tr class='tdbg' style='height:25px'>"
		.Write "                <td height='25'  class='clefttitle' align='right'><strong><font color=blue>上传图片:</font></strong></td>"
		.Write "                <td height='25' width='92%'  align='left'><iframe id='UpPhotoFrame' name='UpPhotoFrame' src='KS.UpFileForm.asp?ChannelID=5&UpType=Pic' frameborder=0 scrolling=no width='100%' height='100%'></iframe>"
		.Write "            </td>"
		.Write "              </tr>"
		End If
        .Write               KSCls.Get_KS_D_F(ChannelID,UserDefineFieldValueStr)
		
		

	
		.Write " <tr class='tdbg'>"
		.Write "  <td class='clefttitle' align='right'><strong>商品单位:</strong></td>"
		.Write "  <td><input name='Unit' type='text' id='Unit' value='" & Unit & "' size='10' class='textbox'> "
		.Write " << <select name='sUnit' onchange=""$('#Unit').val(this.value);"">"
		.Write " <option value=''>请选择</option>"
		.Write  KSCls.Get_O_F_D(KS.C_S(ChannelID,2),"Distinct Top 10 Unit","1=1 Group by unit")
		.Write "</select>"
		.Write " 单件重量：<input name='Weight' type='text' id='Weight' value='" & Weight & "' size='6' class='textbox'>KG <span style='color:green'>用于计算运费，如果不设置请输入0，表示按首重计算运费。</span>"
		.Write "              </td>"
		.Write "             </tr>"
		.Write "             <tr class='tdbg'><td height='70' class='clefttitle' align='right'><strong>商品价格:</strong></td><td><input name='ProductType' type='radio' value='1'"
		If ProductType=1 Then .Write " Checked"
		.Write " onclick='document.myform.Price.value=document.myform.Price_Original.value;document.myform.Price.disabled=true;displaydiscount();'>正常销售&nbsp;<input name='ProductType' type='radio' value='2'"
		If ProductType=2 Then .Write " Checked"
		.Write " onclick='document.myform.Price.disabled=false;displaydiscount();'><font color='green'> 涨价销售&nbsp;&nbsp;&nbsp;&nbsp;</font><input name='ProductType' type='radio' value='3'"
		If ProductType=3 Then .Write " Checked"
		.Write " onclick='getprice(document.myform.Price_Original.value);document.myform.Price.disabled=false;displaydiscount();'><font color='red'> 降价销售&nbsp;&nbsp;&nbsp;&nbsp;<span id='discountarea'"
		If ProductType<>3 Then .Write " style='display:none'"
		.Write ">折扣率：<input name='Discount' type='text' onkeyup='getprice($(""input[name=Price_Original]"").val())' value='" & Discount &"' size='4' maxlength='4' class='textbox' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" style='text-align: center;'> 折&nbsp;&nbsp;如书籍等商品9折促销</font></span><hr size=1 color=blue><font color=red>原始零售价<input name='Price_Original' type='text' id='Price_Original' value='" & Price_Original & "' size='6' onchange='getprice(this.value)' onkeyup='getprice(this.value)' style='text-align: right;' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" class='textbox'> *元</font>&nbsp;<font color=blue>当前零售价<input name='Price' type='text' id='Price' value='" & Price & "' size='6' class='textbox'"
		If ProductType=1 Then .Write " disabled"
		.Write" onKeyPress=""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"">元</font>&nbsp;&nbsp;市场价<input name='Price_Market' type='text' id='Price_Market' value='" & Price_Market & "' size='6' class='textbox' onKeyPress=""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"">元"
		
		.Write "&nbsp;&nbsp;&nbsp;获得积分:<input type=text class='textbox' value='" & point & "' name='point' size='5' style='text-align:center'>分(<font color=#ff0000>以客户付款成功为准</font>)"
		
		.Write "<table border='0' width='80%'>"
		.Write "<tr>"
		.Write " <td width='200'><input type='radio' onclick=""$('#GroupPriceArea').hide();""  name='GroupPrice' value='0'"
		 If GroupPrice=0 Then .Write " Checked"
		.Write ">会员统一指定价</td>"
		.Write " <td align='left'>会员价<input name='Price_Member' type='text' id='Price_Member' value='" & Price_Member & "' size='6' class='textbox' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"">元&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;所有会员都以此为准，不区分组别。"
		.Write "</tr>"
		.Write "<tr>"
		.Write "  <td><input type='radio' onclick=""$('#GroupPriceArea').show();"" name='GroupPrice' value='1'"
		If GroupPrice=1 Then .Write " Checked"
		.Write ">详细设置会员价</td>"
		.Write "  <td>详细设置每个会员组的价格。</td>"
		.Write "</tr>"
		If GroupPrice=0 Then
		.Write "<tr id='GroupPriceArea' style='display:none'>"
		Else
		.Write "<tr id='GroupPriceArea'>" 
		End If
		.Write "<td colspan=2>"
		
		  .Write "<table border='0' width='80%'>"
		  .Write "<tr class='clefttitle'><td>会员组</td><td>价格</td></tr>"
		  Dim Node
		  Call KS.LoadUserGroup()
		  For Each Node In Application(KS.SiteSN&"_UserGroup").DocumentElement.SelectNodes("row")
		  .Write "<tr><td>" &Node.SelectSingleNode("@groupname").text & "</td><td><input onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" class='textbox' type='text' size='6' name='price" & Node.SelectSingleNode("@id").text & "' value='" & LFCls.GetSingleFieldValue("Select Price From KS_ProPrice Where GroupID=" & Node.SelectSingleNode("@id").text & " and ProID=" & ProductID) & "'> 元</td></tr>"
		 Next
		  .Write "</table>"
		.Write "</td>"
		.Write "</tr></table>"
		
		.Write "              </td>"
		.Write "             </tr>"
    	.Write "             <tr class='tdbg'><td class='clefttitle' align='right'><strong>库存设置:</strong></td><td>库存数量<input name='TotalNum' type='text' id='TotalNum' value='" & TotalNum & "' size='10' class='textbox' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"">&nbsp;&nbsp;&nbsp;库存报警下限数&nbsp;<input name='AlarmNum' type='text' id='AlarmNum' value='" & AlarmNum & "' size='10' class='textbox' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"">"
       .Write "</td></tr>"
	   
       .Write "<tr  class='tdbg'><td class='clefttitle' align='right'><strong>新加属性: </strong><br><font color=red>可留空</font></td><td align='left'><table border='0'><tr><td> <textarea name=""AttributeCart"" style='width:400px;height:100px;line-height:26px;padding-left:20px;background:url(Images/rule1.gif) no-repeat 0 0px;border:1px solid #999999;' ID=""AttributeCart"">" & Replace(AttributeCart,"§",vbcrlf) & "</textarea></td><td align='left'>  <span class='help' onclick=""new KesionPopup().mousepop('购物车属性作用','当一件商品有多种属性可供选择时,可以在这里设置。如衣服的颜色,尺码等。',300)"">帮助</span><br/><font color=green>一行表示一个属性，属性名称与属性值之间用“|”线隔开，属性值与属性值之间用英文逗号(,)隔开。<br/></font><font color=blue><b>录入格式如下：</b></font><br/>颜色|红色,白色,蓝色<br/>尺码|29码,30码,32码</td></tr>"
			.Write "</table>"
			
			.Write "</TD>"
			.Write "      </TR>"

        .Write "</table>"
		.Write "</div>"
		
		.Write " <div class=tab-page id=intro-page>"
		.Write "  <H2 class=tab>商品介绍</H2>"
		.Write "	<SCRIPT type=text/javascript>"
		.Write "				 tabPane1.addTabPage( document.getElementById( ""intro-page"" ) );"
		.Write "	</SCRIPT>"

        .Write "<TABLE style='margin:1px' width='100%' BORDER='0' cellpadding='1'  cellspacing='1' class='ctable'>"

		.Write "      <tr class='tdbg'>"
		.Write "       <td class='clefttitle' width='100' align='right'><strong>" & KS.C_S(ChannelID,3) & "简介:</strong><br><input name='BeyondSavePic' type='checkbox' value='1' id='BeyondSavePic'><font color=green>自动下载简介里的图片</font></td>"
		.Write "       <td valign='top'>"
		.Write "<table border='0' width='100%' cellspacing='0' cellpadding='0'>"
		.Write "<tr><td height='30' width=70>&nbsp;<strong>附件上传:</strong></td><td width='120'><input onclick='PopInsertAnnex()' class='button' type='button' name='annexbtn' value='插入已存在的附件...'/>&nbsp;</td><td><iframe id='UpFileFrame' name='UpFileFrame' src='KS.UpFileForm.asp?UPType=File&ChannelID=" & ChannelID &"' frameborder=0 scrolling=no width='100%' height='24'></iframe></td></tr>"
		.Write "</table>"
			.Write " <textarea ID='Content' name='Content' style='display:none'>" & Server.HTMLEncode(ProIntro) & "</textarea>"
					.Write "<script type=""text/javascript"">"
            .Write "CKEDITOR.replace('Content', {width:""98%"",height:""300px"",toolbar:""Basic"",filebrowserBrowseUrl :""Include/SelectPic.asp?from=ckeditor&Currpath="& KS.GetUpFilesDir() &""",filebrowserWindowWidth:650,filebrowserWindowHeight:290});"
			.Write "</script>"
			

		
		.Write "      </TD></tr>"
        .Write "</table>"
		.Write "</div>"
		
		
		.Write " <div class=tab-page id=option-page>"
		.Write "  <H2 class=tab>属性设置</H2>"
		.Write "	<SCRIPT type=text/javascript>"
		.Write "				 tabPane1.addTabPage( document.getElementById( ""option-page"" ) );"
		.Write "	</SCRIPT>"

        .Write "<TABLE style='margin:1px' width='100%' BORDER='0' cellpadding='1'  cellspacing='1' class='ctable'>"
			.Write "           <tr class='tdbg'>"
			.Write "              <td class='clefttitle' width='80' align='right'><strong>所属专题:</strong></td>"
			.Write "              <td>"
			Call KSCls.Get_KS_Admin_Special(ChannelID,KS.ChkClng(KS.G("ID")))
			.write "              </td>"
			.Write "           </tr>"
		.Write "      <tr class='tdbg'>"
		.Write "         <td  class='clefttitle' align='right'><strong>关 键 字:</strong></td>"
		.Write "         <td> <input name='KeyWords' type='text' id='KeyWords' class='textbox' value='" & KeyWords & "' size=50> <<"
		.Write "                  <select name='SelKeyWords' style='width:100px' onChange='InsertKeyWords($(""#KeyWords"").get(0),this.options[this.selectedIndex].value)'>"
		.Write "<option value="""" selected> </option><option value=""Clean"" style=""color:red"">清空</option>"
		.Write KSCls.Get_O_F_D("KS_KeyWords","KeyText","IsSearch=0 Order BY AddDate Desc")
		.Write "                  </select>"
		.Write " <br />【<a href=""#"" id=""KeyLinkByTitle"" style=""color:green"">根据商品名称自动获取Tags</a>】<input type='checkbox' name='tagstf' value='1' checked>写入Tags表"
		.Write "                </td>"
		.Write "              </tr>"
		.Write "              <tr class='tdbg'>"
		.Write "                <td class='clefttitle' align='right'><strong>" & KS.C_S(ChannelID,3) & "型号:</strong></td>"
		.Write "                <td> <input name='ProModel' type='text' id='ProModel' value='" & ProModel & "' size=50 class='textbox'> << "
		.Write ("<select name='sProModel' style='width:100px' onChange=""$('#ProModel').val(this.options[this.selectedIndex].value)"">")
		.Write  KSCls.Get_O_F_D(KS.C_S(ChannelID,2),"Distinct Top 10 ProModel","1=1 Group by ProModel")
        .Write "</select>"
		.Write "</td>"
		.Write "              </tr>"
		.Write "              <tr class='tdbg'>"
		.Write "                <td class='clefttitle' align='right'><strong>" & KS.C_S(ChannelID,3) & "规格:</strong></td>"
		.Write "                <td height='22' nowrap> <input name='ProSpecificat' type='text' id='ProSpecificat' value='" &ProSpecificat & "' size=50 class='textbox'> << "
		.Write ("<select name='selProSpecificat' style='width:100px' onChange=""$('#ProSpecificat').val(this.options[this.selectedIndex].value)"">")
		.Write  KSCls.Get_O_F_D(KS.C_S(ChannelID,2),"Distinct Top 10 ProSpecificat","1=1 Group by ProSpecificat")
        .Write "</select>"
		.Write "</td>"
		.Write "              </tr>"
		.Write "              <tr class='tdbg'>"
		.Write "                <td class='clefttitle' align='right'><strong>生 产 商:</strong></td>"
		.Write "                <td> <input name='ProducerName' type='text' id='ProducerName' value='" & ProducerName & "' size=50 class='textbox'>               << "
			.Write ("<select name='SelProducerName' style='width:100px' onChange=""$('#ProducerName').val(this.options[this.selectedIndex].value)"">")
		    .Write "<option value="""" selected> </option><option value="""" style=""color:red"">清空</option>"
			.Write KSCls.Get_O_F_D("KS_Origin","OriginName","ChannelID=" & ChannelID &" And OriginType=1 Order BY AddDate Desc")
			.Write "       </select></td>"
			.Write "              </tr>"
			.Write "              <tr class='tdbg'>"
			.Write "                <td class='clefttitle' align='right' nowrap><strong>商品商标:</strong></td>"
			.Write "                <td><input name='TrademarkName' type='text' id='TrademarkName' value='" & TrademarkName & "' size=50 class='textbox'>                << "
			.Write ("<select name='selTrademarkName' style='width:100px' onChange=""$('#TrademarkName').val(this.options[this.selectedIndex].value)"">")
		    .Write  KSCls.Get_O_F_D(KS.C_S(ChannelID,2),"Distinct Top 10 TrademarkName","1=1 Group by TrademarkName")
			.Write "                </select> </td>"
			.Write "              </tr>"
			.Write "              <tr class='tdbg'>"
			.Write "                <td class='clefttitle' align='right'><strong>上市时间:</strong></td>"
			.Write "                <td height='22' nowrap>"
		If Action <> "Edit" Then
		.Write ("<input name='AddDate' type='text' id='AddDate' value='" & Now() & "' size='60'  onclick=""popUpCalendar(this, this, dateFormat,-1,-1)"" class='textbox'>")
		Else
		.Write ("<input name='AddDate' type='text' id='AddDate' value='" & AddDate & "' size='60'  onclick=""popUpCalendar(this, this, dateFormat,-1,-1)"" class='textbox'>")
		End If
		.Write "                 <a href='#' onClick=""popUpCalendar(this, $('input[name=AddDate]').get(0), dateFormat,-1,-1)""><img src='Images/date.gif' border='0' align='absmiddle' title='选择日期'></a>"
			.Write "             </td>"
			.Write "            </tr>"
			.Write "            <tr class='tdbg'>"
			.Write "                <td class='clefttitle' align='right'><strong>服务期限:</strong></td>"
			.Write "                <td><input name='ServiceTerm' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" type='text' id='ServiceTerm' value='" & ServiceTerm & "' size=8 class='textbox'>年</td>"
			.Write "              </tr>"
			.Write "              <tr class='tdbg'>"
			.Write "                <td class='clefttitle' align='right'><strong>商品等级:</strong></td>"
			.Write "                <td height='22' nowrap><select name='rank'>"
			If Rank = "★" Then
			.Write "                    <option  selected>★</option>"
			Else
			.Write "                    <option>★</option>"
			End If
			If Rank = "★★" Then
			.Write "                    <option  selected>★★</option>"
			Else
			.Write "                    <option>★★</option>"
			End If
			If Rank = "★★★" Or Action = "Add" Then
			.Write "                    <option  selected>★★★</option>"
			Else
			.Write "                    <option>★★★</option>"
			End If
			If Rank = "★★★★" Then
			.Write "                    <option  selected>★★★★</option>"
			Else
			.Write "                    <option>★★★★</option>"
			End If
			If Rank = "★★★★★" Then
			.Write "                    <option  selected>★★★★★</option>"
			Else
			.Write "                    <option>★★★★★</option>"
			End If
			.Write "                  </select>"
			.Write "                  请为商品评定推荐等级"
			.Write "               </td>"
			.Write "               <tr class='tdbg'>"
			.Write "               <td class='clefttitle' align='right'><strong>点 击 数:</strong></td>"
			.Write "               <td>本日：<input name='HitsByDay' type='text' id='HitsByDay' value='" & HitsByDay & "' size='10' class='textbox'> 本周：<input name='HitsByWeek' type='text' id='HitsByWeek' value='" & HitsByWeek & "' size='10' class='textbox'> 本月：<input name='HitsByMonth' type='text' id='HitsByMonth' value='" & HitsByMonth & "' size='10' class='textbox'> 总计：<input name='Hits' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" type='text' id='Hits' value='" & Hits & "' size='10' class='textbox'>次"
			.Write "</td></tr>"
			 .Write "             <tr class='tdbg'>"
			 .Write "               <td class='clefttitle'><div align='right'><strong>" & KS.C_S(ChannelID,3) & "模板:</strong></div></td>"
			.Write "                <td> "
			IF Action <> "Edit" and  Action<>"Verify" Then
			.Write " <input type='radio' name='templateflag' onclick='GetTemplateArea(false);' value='2' checked>继承栏目设定<input type='radio' onclick='GetTemplateArea(true);' name='templateflag' value='1'>自定义"
			.Write "<div id='templatearea' style='display:none'><input id='TemplateID' name='TemplateID' readonly size=30 class='textbox' value='" & TemplateID & "'>&nbsp;" & KSCls.Get_KS_T_C("$('#TemplateID')[0]") & "</div>"
			Else
			
			.Write "<div id='templatearea'><input name='TemplateID' id='TemplateID' readonly size=30 class='textbox' value='" & TemplateID & "'>&nbsp;" & KSCls.Get_KS_T_C("$('#TemplateID')[0]") & "</div>"
			End If
			.Write "                </td>"
			.Write "             </tr>"
			.Write "             <tr class='tdbg'>"
			.Write "               <td class='clefttitle'><div align='right'><strong>文 件 名:</strong></td><td>"
			IF Action = "Edit" or Action="Verify" Then
			.Write "<input name='FileName' type='text' id='FileName' readonly  value='" & FileName & "' size='25' class='textbox'> <font color=red>不能改</font>"
			Else
			.Write "<input type='radio' value='0' name='filetype' onclick='GetFileNameArea(false);' checked>自动生成 <input type='radio' value='1' name='filetype' onclick='GetFileNameArea(true);' >自定义"
			.Write "<div id='filearea' style='display:none'><input name='FileName' type='text' id='FileName'   value='" & FileName  & "' size='25' class='textbox'> <font color=red>可带路径,如 help.html,news/news_1.shtml等</font></div>"
			End IF
			 .Write "                  </td>"
			 .Write "             </tr>"
			 .Write "    </table>"
			 .Write "    </div>"
			 
			 KSCls.LoadRelativeOption ChannelID,KS.ChkClng(KS.G("ID"))			
			
			 .Write "      </form>"
			 .Write " </div>"
			 .Write "</body>"
			 .Write "</html>"
			 End With
		End Sub
		
		'保存
		Sub DoSave()
		  Dim SelectInfoList,HasInRelativeID
		  With Response
		    ProductID = KS.ChkClng(Request("ProductID"))
		    ProID       = KS.G("ProID")
			If ProID="" Then ProID = KS.GetInfoID(ChannelID)
			Title       = KS.G("Title")
			PhotoUrl    = KS.G("PhotoUrl")
			BigPhoto    = KS.G("BigPhoto")
			ProIntro    = Request.Form("Content")
			Hits        = KS.ChkClng(KS.G("Hits"))
			HitsByDay   = KS.ChkClng(KS.G("HitsByDay"))
			HitsByWeek  = KS.ChkClng(KS.G("HitsByWeek"))
			HitsByMonth = KS.ChkClng(KS.G("HitsByMonth"))
			TotalNum    = KS.ChkClng(KS.G("TotalNum"))
			AlarmNum    = KS.ChkClng(KS.G("AlarmNum"))
			Unit        = KS.G("Unit")
			Weight      = KS.G("Weight")
			If Not IsNumeric(Weight) Then KS.AlertHintScript "商品重量只能输入数字!"
			ProductType = KS.ChkClng(KS.G("ProductType"))
			AttributeCart  = Replace(Request.Form("AttributeCart"),vbcrlf,"§")
			If ProductType<>3 Then
			 Discount=10
			Else 
			 Discount=KS.G("Discount")
			End If
			Price_Original = KS.G("Price_Original")
			If ProductType=1 Then
			 Price=Price_Original
			ElseIf (ProductType=2 Or ProductType=3) And KS.G("Price")="" Then
			 Price=Price_Original
			Else
			 Price = KS.G("Price")
			End If
			Price_Market = KS.G("Price_Market"):If Price_Market="" Then Price_Market=0
			Price_Member = KS.G("Price_Member"):If Price_Member="" Then Price_Member=0
			If Discount>10 Then ErrMsg = ErrMsg & "商品的折扣率必须小于10! \n"
			If ProductType=2 And KS.ChkClng(Price)<KS.ChkClng(Price_Original) Then ErrMsg = ErrMsg & "涨价销售,商品的“当前零售价”必须大于等于“原始零售价”! \n"
			If ProductType=3 And KS.ChkClng(Price_Member)>KS.ChkClng(Price) Then ErrMsg = ErrMsg & "降价销售,商品的“会员价”必须小于等于“当前零售价”! \n"
			GroupPrice  = KS.ChkClng(KS.G("GroupPrice"))  
			Recommend   = KS.ChkClng(KS.G("Recommend"))
			Rolls       = KS.ChkClng(KS.G("Rolls"))
			Popular     = KS.ChkClng(KS.G("Popular"))
			Verific     = KS.ChkClng(KS.G("Verific"))
			Comment     = KS.ChkClng(KS.G("Comment"))
			Strip       = KS.ChkClng(KS.G("Strip"))
			Slide       = KS.ChkClng(KS.G("Slide"))
			Point       = KS.ChkClng(KS.G("Point"))
			BrandID     = KS.ChkClng(KS.G("Brandid"))
			IsSpecial   = KS.ChkCLng(KS.G("IsSpecial"))
			IsTop       = KS.ChkClng(KS.G("IsTop"))
			SpecialID = Replace(KS.G("SpecialID")," ",""):SpecialID = Split(SpecialID,",")
			UnionShopID=Replace(KS.G("UnionShopID")," ",""):UnionShopID=Split(UnionShopID,",")
			SelectInfoList = Replace(KS.G("SelectInfoList")," ","")
			Makehtml    = KS.ChkClng(KS.G("Makehtml"))
			FnameType = Trim(KS.G("Fnametype"))
			Tid = Trim(KS.G("Tid"))
			
				TemplateID = KS.G("TemplateID")
				Dim filetype:filetype=KS.ChkClng(KS.G("filetype"))
				Dim FnameType
				Dim RS_C:Set RS_C=Server.CreateObject("Adodb.RecordSet")
					RS_C.Open "Select top 1 * From KS_Class Where ID='" & Tid & "'",conn,1,1
					If Not RS_C.Eof Then
					    FnameType=RS_C("FnameType")
						If KS.ChkClng(KS.G("TemplateFlag"))=2 Or TemplateID="" Then TemplateID=RS_C("TemplateID")
						If FileType=0 Then
						  If Action = "Add" OR Action="Verify" Then
						   Fname=KS.GetFileName(RS_C("FsoType"), Now, "") & FnameType
						   End If
						End If
					End If
				RS_C.Close:Set RS_C=Nothing
				If filetype=1 Then Fname=KS.G("FileName")
                Call KSCls.CheckDiyField(ChannelID,UserDefineFieldArr,ErrMsg)  '检查自定义字段
					
			KeyWords = KS.G("KeyWords")
			ProducerName = KS.G("ProducerName")
			TrademarkName = KS.G("TrademarkName")
			ProModel = KS.G("ProModel")
			ProSpecificat =KS.G("ProSpecificat")
			ServiceTerm = KS.ChkClng(KS.G("ServiceTerm"))
			AddDate = KS.G("AddDate")
			Rank = Trim(KS.G("Rank"))	
			IsChangedBuy=KS.ChkClng(KS.G("IsChangedBuy"))
			ChangeBuyNeedPrice=KS.G("ChangeBuyNeedPrice"): If Not IsNumeric(ChangeBuyNeedPrice) Then ChangeBuyNeedPrice=0
			ChangeBuyPresentPrice=KS.G("ChangeBuyPresentPrice"): If Not IsNumeric(ChangeBuyPresentPrice) Then ChangeBuyPresentPrice=0
			
			IsLimitbuy = KS.ChkClng(KS.S("IsLimitBuy"))
			LimitBuyPrice = KS.S("LimitBuyPrice")
			LimitBuyAmount = KS.ChkCLng(KS.S("LimitBuyAmount"))
			LimitBuyTaskID=KS.ChkCLng(KS.S("LimitBuyTaskID" & IsLimitbuy))
			If IsLimitBuy<>0 And LimitBuyTaskID=0 Then ErrMsg = ErrMsg & "请选请择抢购任务! \n"
			iF IsLimitbuy<>0 and LimitBuyAmount>=TotalNum Then ErrMsg=ErrMsg & "抢购数量必须小于等于商品数量!\n"
			If Not IsNumeric(LimitBuyPrice) Then LimitBuyPrice=0
			
			
					 
			If Title = "" Then .Write ("<script>alert('商品名称不能为空!');history.back(-1);</script>")
			
			Set RS = Server.CreateObject("ADODB.RecordSet")
			If Tid = "" Then ErrMsg = ErrMsg & "[商品类别]必选! \n"
			If Title = "" Then ErrMsg = ErrMsg & "[商品标题]不能为空! \n"
			If Title <> "" And Tid <> "" And Action = "Add" Then
			  SqlStr = "select top 1 * from Product where Title='" & Title & "' And Tid='" & Tid & "'"
			   RS.Open SqlStr, conn, 1, 1
				If Not RS.EOF Then
				 ErrMsg = ErrMsg & "该类别已存在此商品! \n"
			   End If
			   RS.Close
			End If
			If ProductID=0 Then
			  If Not Conn.Execute("Select top 1 ProID From Product Where ProID='" & ProID & "'").eof Then
			    ErrMsg = ErrMsg & "该商品编号已存在! \n"
			  End If
			Else
			  If Not Conn.Execute("Select top 1 ProID From Product Where ID<>" & ProductID & " and ProID='" & ProID & "'").eof Then
			    ErrMsg = ErrMsg & "该商品编号已存在! \n"
			  End If
			End If
			
			If ErrMsg <> "" Then
			   .Write ("<script>alert('" & ErrMsg & "');history.back(-1);</script>")
			   .End
			Else
			
			    If KS.ChkClng(KS.G("BeyondSavePic")) = 1 Then
				    Dim SaveFilePath
					SaveFilePath = KS.GetUpFilesDir & "/"
					KS.CreateListFolder (SaveFilePath)
				    ProIntro= KS.ReplaceBeyondUrl(ProIntro, SaveFilePath)
				End If
						
				If KS.ChkClng(KS.G("TagsTF"))=1 Then Call KSCls.AddKeyTags(KeyWords)	
				  If Action = "Add" Then
					SqlStr = "select top 1 * from Product where 1=0"
					RS.Open SqlStr, conn, 1, 3
					RS.AddNew
					RS("ProID") = ProID
					RS("Title") = Title
					RS("PhotoUrl") = PhotoUrl
					RS("BigPhoto")=BigPhoto
					RS("ProIntro") = ProIntro
					RS("Recommend") = Recommend
					RS("Rolls") = Rolls
					RS("Popular") = Popular
					RS("Verific") = Verific
					RS("Strip")   = Strip
					RS("Comment") = Comment
					RS("Tid") = Tid
					RS("TotalNum") = TotalNum
					RS("AlarmNum") = AlarmNum
					RS("ProductType") = ProductType
					RS("Discount") = Discount
					RS("Unit") = Unit
					RS("Weight")=Weight
					RS("Price_Original") = Price_Original
					RS("Price") = Price
					RS("GroupPrice") = GroupPrice
					RS("Price_Member")=Price_Member
					RS("Price_Market") = Price_Market
					RS("KeyWords") = KeyWords
					RS("ProSpecificat")=ProSpecificat
					RS("ProModel") = ProModel
					RS("ServiceTerm") = ServiceTerm
					RS("ProducerName") = ProducerName
					RS("TrademarkName") = TrademarkName
					RS("AddDate") = AddDate
					RS("Rank") = Rank
					RS("Slide") = Slide
					RS("IsTop") = IsTop
					RS("IsSpecial") = IsSpecial
					RS("TemplateID") = TemplateID
					RS("Hits") = Hits
					RS("HitsByDay") = HitsByDay
					RS("HitsByWeek") = HitsByWeek
					RS("HitsByMonth") = HitsByMonth
					RS("Fname") = Fname
					RS("Point") = Point
					RS("BrandID")=BrandID
					RS("AttributeCart")=AttributeCart
					RS("IsChangedBuy")=IsChangedBuy
					RS("ChangeBuyNeedPrice")=ChangeBuyNeedPrice
					RS("ChangeBuyPresentPrice")=ChangeBuyPresentPrice
					
					RS("IsLimitbuy") = IsLimitBuy
					RS("LimitBuyPrice") = LimitBuyPrice
					RS("LimitBuyTaskID")=LimitBuyTaskID
					RS("LimitBuyAmount")= LimitBuyAmount

					
					if Action="Verify" Then
						   RS("Inputer") = Trim(KS.G("Inputer"))
					Else
					       RS("Inputer") = KS.C("AdminName")
					End IF
					RS("RefreshTF") = Makehtml
					RS("DelTF") = 0
					Call KSCls.AddDiyFieldValue(RS,UserDefineFieldArr)
					RS.Update
					
				   Session("KeyWords") = KeyWords
				   Session("ProducerName") = ProducerName
				   Session("TrademarkName") = TrademarkName
				    RS.MoveLast
					  If Left(Ucase(Fname),2)="ID" Then
					   RS("Fname") = RS("ID") & FnameType
					   RS.Update
					  End If
					  
					   Call addBundleSale(rs("id"))
					  
					  
					   Call AddGroupPrice(RS("ID"))
					   For I=0 To Ubound(UnionShopID)
						Conn.Execute("Insert Into KS_ShopUnionR(UnionID,ProID) values(" & UnionShopID(I) & "," & RS("ID") &")")
						Next
						For I=0 To Ubound(SpecialID)
						Conn.Execute("Insert Into KS_SpecialR(SpecialID,InfoID,ChannelID) values(" & SpecialID(I) & "," & RS("ID") & "," & ChannelID & ")")
					  Next
					    Call KSCls.UpdateRelative(ChannelID,RS("ID"),SelectInfoList,0)
						Call LFCls.AddItemInfo(ChannelID,RS("ID"),Title,Tid,ProIntro,KeyWords,PhotoUrl,AddDate,KS.C("AdminName"),Hits,HitsByDay,HitsByWeek,HitsByMonth,Recommend,Rolls,IsSpecial,Popular,Slide,IsTop,Comment,Verific,RS("Fname"))
					   '关联上传文件
				       Call KS.FileAssociation(ChannelID,RS("ID"),PhotoUrl & BigPhoto & ProIntro ,0)
                       If Not KS.IsNul(Session("UploadFileIDs")) Then 
					    Conn.Execute("Update [KS_UpLoadFiles] Set InfoID=" & RS("ID") &",classID=" & KS.C_C(Tid,9) & " Where ID In (" & KS.FilterIds(Session("UploadFileIDs")) & ")")
					   End If
			        Call RefreshHtml(1)
					RS.Close:Set RS = Nothing
					
				ElseIf Action = "Edit"  Or Action="Verify" Then
				
				SqlStr = "SELECT Top 1 * FROM Product Where ID=" & ProductID
					RS.Open SqlStr, conn, 1, 3
					If RS.EOF And RS.BOF Then
					 .Write ("<script>alert('参数传递出错!');history.back(-1);</script>")
					 .End
					End If
					RS("ProID") = ProID
					RS("Title") = Title
					RS("PhotoUrl") = PhotoUrl
					RS("BigPhoto")=BigPhoto
					RS("ProIntro") = ProIntro
					RS("Recommend") = Recommend
					RS("Rolls") = Rolls
					RS("Strip")   = Strip
					RS("Popular") = Popular
					RS("Verific") = Verific
					RS("Comment") = Comment
					RS("Tid") = Tid
					RS("KeyWords") = KeyWords
					RS("TotalNum") = TotalNum
					RS("AlarmNum") = AlarmNum
					RS("Unit") = Unit
					RS("Weight")=Weight
					RS("ProductType") = ProductType
					RS("Discount") = Discount
					RS("Price_Original") = Price_Original
					RS("Price") = Price
					RS("GroupPrice") = GroupPrice
					RS("Price_Member")=Price_Member
					RS("Price_Market") = Price_Market
					RS("ProSpecificat")=ProSpecificat
					RS("ProModel") = ProModel
					RS("ServiceTerm") = ServiceTerm
					RS("ProducerName") = ProducerName
					RS("TrademarkName") = TrademarkName
					RS("AddDate") = AddDate
					RS("Rank") = Rank
					RS("Slide") = Slide
					RS("IsTop") = IsTop
					RS("IsSpecial") = IsSpecial
					RS("TemplateID") = TemplateID
					RS("Fname") = Replace(RS("Fname"), Trim(Mid(Trim(RS("Fname")), InStrRev(Trim(RS("Fname")), "."))), FnameType)
					If Makehtml = 1 Then RS("RefreshTF") = 1
					RS("Hits") = Hits
					RS("HitsByDay") = HitsByDay
					RS("HitsByWeek") = HitsByWeek
					RS("HitsByMonth") = HitsByMonth
					RS("Point") = Point
					RS("BrandID")=BrandID
					RS("AttributeCart")=AttributeCart
					RS("IsChangedBuy")=IsChangedBuy
					RS("ChangeBuyNeedPrice")=ChangeBuyNeedPrice
					RS("ChangeBuyPresentPrice")=ChangeBuyPresentPrice
					RS("IsLimitbuy") = IsLimitBuy
					RS("LimitBuyPrice") = LimitBuyPrice
					RS("LimitBuyTaskID")=LimitBuyTaskID
					RS("LimitBuyAmount")= LimitBuyAmount
                    Call KSCls.AddDiyFieldValue(RS,UserDefineFieldArr)
					RS.Update
				   RS.MoveLast
					
				   Call addBundleSale(rs("id"))

				   Call AddGroupPrice(RS("ID"))
					Conn.Execute("Delete From KS_ShopUnionR Where Proid=" & ProductID)
					For I=0 To Ubound(UnionShopID)
						Conn.Execute("Insert Into KS_ShopUnionR(UnionID,ProID) values(" & UnionShopID(I) & "," & ProductID &")")
					Next
					Conn.Execute("Delete From KS_SpecialR Where InfoID=" &ProductID & " and channelid=" & ChannelID)
					For I=0 To Ubound(SpecialID)
					Conn.Execute("Insert Into KS_SpecialR(SpecialID,InfoID,ChannelID) values(" & SpecialID(I) & "," & ProductID & "," & ChannelID & ")")
					Next
					Call KSCls.UpdateRelative(ChannelID,ProductID,SelectInfoList,1)
					Call LFCls.UpdateItemInfo(ChannelID,ProductID,Title,Tid,ProIntro,KeyWords,PhotoUrl,AddDate,Hits,HitsByDay,HitsByWeek,HitsByMonth,Recommend,Rolls,IsSpecial,Popular,Slide,IsTop,Comment,Verific)
					'关联上传文件
				    Call KS.FileAssociation(ChannelID,ProductID,PhotoUrl & BigPhoto & ProIntro ,1)
					If Not KS.IsNul(Session("UploadFileIDs")) Then 
					    Conn.Execute("Update [KS_UpLoadFiles] Set InfoID=" & ProductID &",classID=" & KS.C_C(Tid,9) & " Where ID In (" & KS.FilterIds(Session("UploadFileIDs")) & ")")
					End If
				    Call RefreshHtml(2)
		          
				  RS.Close:Set RS = Nothing
					
					If KeyWord <>"" Then
						 .Write ("<script> parent.frames['MainFrame'].focus();alert('商品修改成功!');location.href='KS.Shop.asp?Page=" & Page & "&KeyWord=" & KeyWord & "&SearchType=" & SearchType & "&StartDate=" & StartDate & "&EndDate=" & EndDate & "';$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?ButtonSymbol=ShopSearch&OpStr=" & server.URLEncode("商品管理 >> <font color=red>搜索结果</font>") & "';</script>")
					End If
				End If
			End If
		 End With		
		End Sub
		
		Sub AddGroupPrice(ByVal ID)
		    If GroupPrice=1 Then
			  Dim Node
			  Call KS.LoadUserGroup()
			  For Each Node In Application(KS.SiteSN&"_UserGroup").DocumentElement.SelectNodes("row")
				  Dim PRS:Set PRS=Server.CreateOBject("ADODB.RECORDSET")
				  PRS.Open "Select * From KS_ProPrice Where GroupiD=" & Node.SelectSingleNode("@id").text & " And ProID=" & ID,conn,1,3
				  If PRS.Eof Then
				   PRS.AddNew
				  End If
				   PRS("GroupID")=Node.SelectSingleNode("@id").text
				   PRS("ProID")=ID
				   If KS.G("Price" & Node.SelectSingleNode("@id").text)="" Then
				    PRS("Price")=0
				   Else
				   PRS("Price")=KS.G("Price" & Node.SelectSingleNode("@id").text)
				   End If
				  PRS.Update
				  PRS.Close:Set PRS=Nothing
				Next
			End If
		End Sub
		
		Sub RefreshHtml(Flag)
			     Dim TempStr,EditStr,AddStr
			    If Flag=1 Then
				  TempStr="添加":EditStr="修改商品":AddStr="继续添加商品"
				Else
				  TempStr="修改":EditStr="继续修改商品":AddStr="添加商品"
				End If
			    With Response
				     .Write "<link href='Include/Admin_Style.CSS' rel='stylesheet' type='text/css'>"
					  .Write "<script language='JavaScript' src='../Inc/Jquery.js'></script>"
					 .Write " <Br><br><br><table align='center' width=""95%"" height='200' class='ctable' cellpadding=""1"" cellspacing=""1"">"
					  .Write "	  <tr class=""sort""> "
					  .Write "		<td  height=""28"" colspan=2>系统操作提示信息</td>" & vbcrlf
					  .Write "	  </tr>"
                      .Write "    <tr class='tdbg'>"
					  .Write "          <td align='center'><img src='images/succeed.gif'></td>"
					  .Write "<td><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;恭喜，" & TempStr &"" & KS.C_S(ChannelID,3) & "成功！</b><br>"
					   If Makehtml = 1 Then
					      .Write "<div style=""margin-top:15px;border: #E7E7E7;height:220; overflow: auto; width:100%"">" 
					    If KS.C_S(ChannelID,7)=1 Or KS.C_S(ChannelID,7)=2 Then
						  	 .Write "<div><iframe src=""Include/RefreshHtmlSave.Asp?ChannelID=" & ChannelID &"&Types=Content&RefreshFlag=ID&ID=" & RS("ID") &""" width=""100%"" height=""80"" frameborder=""0"" allowtransparency='true'></iframe></div>"
						  Else
						  .Write "<div style=""height:25px""><li>由于" & KS.C_S(ChannelID,1) & "没有启用生成HTML的功能，所以ID号为 <font color=red>" & RS("ID") & "</font>  的" & KS.C_S(ChannelID,3) & "没有生成!</li></div> "
						  End If
						  
							If KS.C_S(ChannelID,7)<>1 Then
							  .Write "<div style=""height:25px""><li>由于" & KS.C_S(ChannelID,1) & "的栏目页没有启用生成HTML的功能，所以ID号为 <font color=red>" & TID & "</font>  的栏目没有生成!</li></div> "
							Else
							 If KS.C_S(ChannelID,9)<>1 Then
								  Dim FolderIDArr:FolderIDArr=Split(left(KS.C_C(Tid,8),Len(KS.C_C(Tid,8))-1),",")
								  For I=0 To Ubound(FolderIDArr)
								  .Write "<div align=center><iframe src=""Include/RefreshHtmlSave.Asp?ChannelID=" & ChannelID &"&Types=Folder&RefreshFlag=ID&FolderID=" & FolderIDArr(i) &""" width=""100%"" height=""90"" frameborder=""0"" allowtransparency='true'></iframe></div>"
								   Next
							 End If
						   End If
					   If Split(KS.Setting(5),".")(1)="asp" or KS.C_S(ChannelID,9)<>3 Then
					   Else
					     .Write "<div align=center><iframe src=""Include/RefreshIndex.asp?RefreshFlag=Info"" width=""100%"" height=""80"" frameborder=""0"" allowtransparency='true'></iframe></div>"
					   End If
					   .Write "</div>"
					   End If
					   .Write   "</td></tr>"
					  .Write "	  <tr class='tdbg'>"
					  .Write "		<td></td><td height=""25"" style='text-align:right'>【<a href=""#"" onclick=""location.href='KS.Shop.asp?Page=" & Page & "&Action=Edit&KeyWord=" & KeyWord &"&SearchType=" & SearchType &"&StartDate=" & StartDate & "&EndDate=" & EndDate &"&ID=" & RS("ID") & "';""><strong>" & EditStr &"</strong></a>】&nbsp;【<a href=""#"" onclick=""location.href='KS.Shop.asp?Action=Add&FolderID=" & Tid & "';$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?OpStr=" & server.URLEncode("添加商品")& "&ButtonSymbol=AddInfo&FolderID=" & Tid & "';""><strong>" & AddStr & "</strong></a>】&nbsp;【<a href=""#"" onclick=""location.href='KS.ItemInfo.asp?ChannelID=" & ChannelID &"&ID=" & Tid & "&Page=" & Page &"';$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?ButtonSymbol=ViewFolder&FolderID=" & Tid & "';""><strong>商品管理</strong></a>】&nbsp;【<a href=""#"" onclick=""location.href='KS.ProImages.asp?ProID=" & RS("ID") & "&ChannelID=5&Page=" & Page &"';$(parent.document).find('#BottomFrame')[0].src='KS.Split.asp?OpStr=" & server.URLEncode("商品图片管理")& "&ButtonSymbol=disabled';""><strong>商品图片管理</strong></a>】&nbsp;【<a href=""" & KS.GetDomain & "Item/Show.asp?m=" & ChannelID & "&d=" & RS("ID") & """ target=""_blank""><strong>预览商品内容</strong></a>】</td>"
					  .Write "	  </tr>"
					  .Write "	</table>"				
			End With
		End Sub
		
		Function GetBrandByClassID(ClassID,BrandID)
		  Dim SQL,K
		  Dim RS:Set RS=Server.CreateOBject("ADODB.RECORDSET")
		  RS.Open "Select B.ID,B.BrandName From KS_ClassBrand B inner join KS_ClassBrandR R On B.id=R.BrandID where R.classid='" & classid & "' order by B.orderid",conn,1,1
		  If Not RS.Eof  Then SQL=RS.GetRows(-1):RS.Close:Set RS=Nothing
		  If Not IsArray(SQL) Then
		   GetBrandByClassID="Null" 
		  Else
		     GetBrandByClassID = "<select name='brandid'>"
			 GetBrandByClassID = GetBrandByClassID & "<option value='0'>-请选择品牌-</option>"
		     For K=0 To Ubound(SQL,2)
			  If BrandID=SQL(0,K) Then
			  GetBrandByClassID=GetBrandByClassID & "<option value='" & sql(0,k) & "' selected>" & sql(1,k) & "</option>"
			  Else
			  GetBrandByClassID=GetBrandByClassID & "<option value='" & sql(0,k) & "'>" & sql(1,k) & "</option>"
			  End If
			 Next
			 GetBrandByClassID = GetBrandByClassID &  "</select>"
			 Erase Sql
		  End If
       End Function

	   Sub SetKBXSPrice()
	   	  with response
		      .Write "<html>"
			  .Write"<head>"
			  .Write"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"
			  .Write"<link href=""Include/Admin_Style.CSS"" rel=""stylesheet"" type=""text/css"">"
			  .Write "<script src=""../Inc/common.js"" language=""JavaScript""></script>"
			  .Write "<script language='JavaScript' src='../Inc/jquery.js'></script>" & vbCrLf
			  .Write"</head>"
			  .Write"<body leftmargin=""0"" topmargin=""0"" marginwidth=""0"" marginheight=""0"">"

	    dim proid:proid=ks.chkclng(request("proid"))
		if proid=0 then ks.die "error!"
		dim kbprice:kbprice=request("kbprice")
	    dim rs:set rs=server.createobject("adodb.recordset")
		rs.open "select top 1 * from product where id=" & proid,conn,1,1
		if not rs.eof then
		%>
		 <script type="text/javascript">
		  function regInput(obj, reg, inputStr)
				{
					var docSel = document.selection.createRange()
					if (docSel.parentElement().tagName != "INPUT")    return false
					oSel = docSel.duplicate()
					oSel.text = ""
					var srcRange = obj.createTextRange()
					oSel.setEndPoint("StartToStart", srcRange)
					var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
					return reg.test(str)
				}
			function addIn(){
		   var title=$("#title").val();
		   var proid=$("#proid").val();
		   var kbprice=$("#kbprice").val();
		   top.frames["MainFrame"].updateKBXS(proid+"@@@"+kbprice+"@@@"+title);
		   top.frames["MainFrame"].closeWindow();
		  }
		 </script>
		<%if kbprice="" then kbprice=rs("price_member")
	     .write "<table border='0' width='100%' class='ctable' cellspacing='1' cellpadding='1'>"
		 .write "<tr class='tdbg'><td height='30' class='clefttitle' align='right' width='130'><strong>商品名称:</strong></td><td>" & rs("title") & "<input type='hidden' name='title' id='title' value='" & rs("title") & "'><input type='hidden' name='proid' id='proid' value='" & proid & "'></td></tr>"
		 .write "<tr class='tdbg'><td height='30' class='clefttitle' align='right'><strong>当前零售价:</strong></td><td>￥" & formatnumber(rs("price"),2,-1) & "元</td></tr>"
		 .write "<tr class='tdbg'><td height='30' class='clefttitle' align='right'><strong>会 员 价:</strong></td><td><font color=red>￥" & formatnumber(rs("price_member"),2,-1) & "元</font></td></tr>"
		 .write "<tr class='tdbg'><td height='30' class='clefttitle' align='right'><strong>捆绑销售价:</strong></td><td><input type='text' name='kbprice' id='kbprice' value='" & kbprice & "' size='5' onKeyPress= ""return regInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"" onpaste=""return regInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"" ondrop=""return regInput(this,    /^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"" style='text-align:center'> 元</td></tr>"
		 .write "<tr class='tdbg'><td height='30' align='center' colspan='2'>"
		 if request("kbprice")="" Then
		 .Write "<input onclick='addIn()' type='button' value='确定加入' class='button'>"
		 else
		 .Write "<input onclick='addIn()' type='button' value='确定修改' class='button'>"
		 end if
		 .Write "</td></tr>"
         .write "</table>"		
		end if
		rs.close
		set rs=nothing
		end with
	   End Sub
	   
	   Sub addBundleSale(ID)
	   		Dim KBProList:KBProList=KS.S("KBProList")
			Dim KBArr,I
			 Conn.Execute("Delete From KS_ShopBundleSale Where ProID=" & ID)
			 
			If Not KS.IsNul(KBProList) Then
			  KBProList=Replace(KBProList," ","")
			  KBArr=Split(KBProList,",")
			   For i=0 to ubound(KBArr)
			        Dim KBSArr:KBSArr=Split(KBArr(i),"|")
					Dim PRS:Set PRS=Server.CreateOBject("ADODB.RECORDSET")
					PRS.Open "Select * From KS_ShopBundleSale Where KBProID=" & KBSArr(0) & " And ProID=" & ID,conn,1,3
				  If PRS.Eof Then
				   PRS.AddNew
				  End If
				   PRS("ProID")=ID
				   PRS("KBProID")=KBSArr(0)
				   PRS("KBPrice")=KBSArr(1)
				  PRS.Update
				  PRS.Close:Set PRS=Nothing
				Next
		  End If
		   
	   End Sub
End Class
%> 
