<%
'**************************************
'* 最后更新 2013-10-17 by 56770.kingdge
'* Copyright www.56770.com
'**************************************
Dim sum1,sum2,sum3,strsum3,js,jifen1,jifen2,jifen,sql,user_city,user_name,user_tel,user_mail,user_adds,user_adds2,user_zip,user_mobile,fapiao_company,fapiao_adds,fapiao_zip,basket_lowprice,Pro_LsCount,p_weight,CookiesId,deliver_price,basic_weight,user_state,user_country
Showpath = "<a href='"& Eshop_url & LangPath &"'>"& Lebi_word(0) &"</a> → <a href='"&  Eshop_url & PagePath(3) &"'>"& Lebi_word(7) &"</a> → "& Lebi_cart(39)
checkuser()
CookiesId = CheckNum(request.cookies(cookiesname&"_user")("cookiesid"),0)
If CookiesId = 0 Then
        response.redirect Eshop_url & PagePath(1) &"?action=nocookies"
		response.End
End If
Select Case request("action")
	Case "getDeliverArea2" : getDeliverArea2()
	Case "getDeliverList" : getDeliverList()
	Case "getDeliverAreaname" : getDeliverAreaname()
	Case Else
		main()
End Select

Sub main()
	If CInt(getGradePurview(0)) <> 1 Then
			response.redirect Eshop_url & PagePath(1) &"?action=notgrade&HTTP_REFERER="& server.urlencode(Eshop_url & PagePath(3)) &""
			response.End
	Else
			IsNothing = 0
			set rs = conn.execute("select price,basket_count,p_weight from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> '')) and IsGift = 0")
			If rs.eof Then
					IsNothing = 1
			Else
					do While Not rs.EOF
							Sum3 = Sum3 + (rs("price")*rs("basket_count"))
							p_weight= p_weight + (rs("p_weight")*rs("basket_count")/1000)
					rs.MoveNext
					Loop
			End If
			rs.close : Set rs=Nothing
			If IsNothing = 1 Then
					set rs = conn.execute("select id from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> '')) and IsGift = 1")
					If Not rs.eof Then
							IsNothing = 0
							Sum3 = 0
							p_weight = 0
					End If
					rs.close : Set rs=Nothing
			End If
			If IsNothing = 1 Then
					response.redirect Eshop_url & PagePath(1) &"?action=nothing"
					response.End
			End If
			Rem 判断用户状态是否登陆 2006-3-3 Lebi.kingdge
			If Lebi_UserId <>"" Then
					sql="select city,user_name,user_tel,user_mail,user_adds,user_adds2,user_postalcode,fapiao_company,fapiao_adds,fapiao_zip,user_mobile,state,country from [Lebi_user] where user_id='"& Lebi_UserId &"'"
					set Rs = conn.execute(Sql)
					If rs.eof Then
							user_city=""
							user_name=""
							user_tel=""
							user_mail=""
							user_adds=""
							user_adds2=""
							user_zip=""
							fapiao_company=""
							fapiao_adds=""
							fapiao_zip=""
							user_mobile=""
							user_state=""
							user_country=""
					Else
							user_city=trim(rs("city"))
							If isnull(user_city) Then user_city = ""
							user_name=trim(rs("user_name"))
							If isnull(user_name) Then user_name=""
							user_tel=trim(rs("user_tel"))
							If isnull(user_tel) Then user_tel=""
							user_mail=trim(rs("user_mail"))
							If isnull(user_mail) Then user_mail=""
							user_adds=trim(rs("user_adds"))
							If isnull(user_adds) Then user_adds=""
							user_adds2=trim(rs("user_adds2"))
							If isnull(user_adds2) Then user_adds2=""
							user_zip=trim(rs("user_postalcode"))
							If isnull(user_zip) Then user_zip=""
							fapiao_company=trim(rs("fapiao_company"))
							If isnull(fapiao_company) Then fapiao_company=""
							fapiao_adds=trim(rs("fapiao_adds"))
							If isnull(fapiao_adds) Then fapiao_adds=""
							fapiao_zip=trim(rs("fapiao_zip"))
							If isnull(fapiao_zip) Then fapiao_zip=""
							user_mobile=trim(rs("user_mobile"))
							If isnull(user_mobile) Then user_mobile=""
							If isnull(user_adds2) Then user_adds2=""
							user_state=trim(rs("state"))
							If isnull(user_state) Then user_state=""
							user_country=trim(rs("country"))
							If isnull(user_country) Then user_country=""
					End If
					rs.close:Set rs=Nothing
			Else
					user_city=""
					user_name=""
					user_tel=""
					user_mail=""
					user_adds=""
					user_adds2=""
					user_zip=""
					fapiao_company=""
					fapiao_adds=""
					fapiao_zip=""
					user_mobile=""
					user_state=""
					user_country=""
			End If
			If sys_soft = 1 Then 
					If user_tel = "" Then 
							user_tel = ",,,"
					Else
							If InStr(user_tel,",") = 0 Then user_tel = user_tel &",,"
					End If 
			End If 
			rem 如果购物车中无商品购买信息但有积分换购，不做判断 2007-9-26 by 56770.kingdge
			Pro_LsCount = conn.execute("select count(id) from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <> '')) and IsGift=0")(0)
			If CLng(sum3)<CLng(getGradePurview(3)) And Pro_LsCount >0 then ' 2008-3-7 by 56770.WangLei
					response.redirect Eshop_url & PagePath(1) &"?action=basket&error_type=3"
					response.End
			End If
	End If
End Sub
'..................................
'读取 支付方式
'..................................
Public Function payment()
        Dim payment_num,payment_content
        payment="<table width='100%' align='center' cellpadding='0' cellspacing='0'>"
        sql="select id,zf_fs"& LangTxt &",bank"& LangTxt &" from [Lebi_bank] where ShowLang like '%"& Langname &"%' order by id desc"
        Set rs = conn.execute(sql)
        if rs.eof And rs.bof then
               payment = payment &"<tr><td height=""25""><input type=""radio"" name='paymenttype' value='"&Lebi_cart(66)&"' title='"&Lebi_cart(66)&"' checked> "&Lebi_cart(66)&"</td></tr>"
        Else
		       payment_num = 1
               do while not rs.eof
			   rem 增加支付信息换行功能 2007-11-8 by 56770.kingdge
			   payment_content = Replace(rs(2),chr(13),"<br>")
               payment = payment &"<tr><td height=""25"" id=""payment_"&payment_num&"""><label><input type=""radio"" name='paymenttype' value='"&rs(1)&"' title='"&rs(1)&"' onclick='turnit(document.getElementById(""Content_"&payment_num&"""),document.getElementById(""payment_"&payment_num&"""));"
			   If payment_num > 1 Then payment = payment &"document.getElementById(""Content_1"").style.display=""none"";"
			   payment = payment &"' style='CURSOR: pointer'"
			   If payment_num = 1 Then payment = payment &" checked"
			   payment = payment &"> "&rs(1)&"</label></td></tr>"
			   If Trim(payment_content) <> "" Then 
			   payment = payment &"<tr id=""Content_"&payment_num&""""
			   If payment_num > 1 Then payment = payment &" style=""display:none;"""
			   payment = payment &" ><td style=""padding:10px;"">"& payment_content &"</td></tr>"
			   End If 
               rs.movenext
			   payment_num = payment_num + 1
               loop
        end if
        rs.close:set rs=Nothing
	    If Pay_chinabank(0)=1 And InStr(Pay_chinabank(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_chinabank""><label><input type=""radio"" name='paymenttype' value='001' title='"&Pay_chinabank(8)&"' onclick='turnit(document.getElementById(""Content_chinabank""),document.getElementById(""payment_chinabank""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_chinabank(8) &"</label></td></tr>"
		If Trim(Pay_chinabank(5)) <> "" Then payment = payment &"<tr id=""Content_chinabank"" style=""display:none;""><td style=""padding:10px;"">"& Pay_chinabank(5) &"</td></tr>"
	    If Pay_alipay(0)=1 And InStr(Pay_alipay(13),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_alipay""><label><input type=""radio"" name='paymenttype' value='002' title='"&Pay_alipay(10)&"' onclick='turnit(document.getElementById(""Content_alipay""),document.getElementById(""payment_alipay""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_alipay(10) &"</label></td></tr>"
		If Trim(Pay_alipay(7)) <> "" Then payment = payment &"<tr id=""Content_alipay"" style=""display:none;""><td style=""padding:10px;"">"& Pay_alipay(7) &"</td></tr>"
	    If Pay_paypal(0)=1 And InStr(Pay_paypal(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_paypal""><label><input type=""radio"" name='paymenttype' value='003' title='"&Pay_paypal(8)&"' onclick='turnit(document.getElementById(""Content_paypal""),document.getElementById(""payment_paypal""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_paypal(8) &"</label></td></tr>"
		If Trim(Pay_paypal(3)) <> "" Then payment = payment &"<tr id=""Content_paypal"" style=""display:none;""><td style=""padding:10px;"">"& Pay_paypal(3) &"</td></tr>"
	    If Pay_paypal_cn(0)=1 And InStr(Pay_paypal_cn(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_paypal_cn""><label><input type=""radio"" name='paymenttype' value='007' title='"&Pay_paypal_cn(8)&"' onclick='turnit(document.getElementById(""Content_paypal_cn""),document.getElementById(""payment_paypal_cn""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_paypal_cn(8) &"</label></td></tr>"
		If Trim(Pay_paypal_cn(3)) <> "" Then payment = payment &"<tr id=""Content_paypal_cn"" style=""display:none;""><td style=""padding:10px;"">"& Pay_paypal_cn(3) &"</td></tr>"
	    If Pay_bill(0)=1 And InStr(Pay_bill(10),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_bill""><label><input type=""radio"" name='paymenttype' value='004' title='"&Pay_bill(7)&"' onclick='turnit(document.getElementById(""Content_bill""),document.getElementById(""payment_bill""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_bill(7) &"</label></td></tr>"
		If Trim(Pay_bill(4)) <> "" Then payment = payment &"<tr id=""Content_bill"" style=""display:none;""><td style=""padding:10px;"">"& Pay_bill(4) &"</td></tr>"
	    If Pay_tenpay(0)=1 And InStr(Pay_tenpay(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_tenpay""><label><input type=""radio"" name='paymenttype' value='005' title='"&Pay_tenpay(8)&"' onclick='turnit(document.getElementById(""Content_tenpay""),document.getElementById(""payment_tenpay""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_tenpay(8) &"</label></td></tr>"
		If Trim(Pay_tenpay(5)) <> "" Then payment = payment &"<tr id=""Content_tenpay"" style=""display:none;""><td style=""padding:10px;"">"& Pay_tenpay(5) &"</td></tr>"
	    If Pay_tenpay2(0)=1 And InStr(Pay_tenpay2(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_tenpay2""><label><input type=""radio"" name='paymenttype' value='006' title='"&Pay_tenpay2(8)&"' onclick='turnit(document.getElementById(""Content_tenpay2""),document.getElementById(""payment_tenpay2""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_tenpay2(8) &"</label></td></tr>"
		If Trim(Pay_tenpay2(5)) <> "" Then payment = payment &"<tr id=""Content_tenpay2"" style=""display:none;""><td style=""padding:10px;"">"& Pay_tenpay2(5) &"</td></tr>"
	    If Pay_ips(0)=1 And InStr(Pay_ips(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_ips""><label><input type=""radio"" name='paymenttype' value='008' title='"&Pay_ips(8)&"' onclick='turnit(document.getElementById(""Content_ips""),document.getElementById(""payment_ips""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_ips(8) &"</label></td></tr>"
		If Trim(Pay_ips(5)) <> "" Then payment = payment &"<tr id=""Content_ips"" style=""display:none;""><td style=""padding:10px;"">"& Pay_ips(5) &"</td></tr>"
	    If Pay_baofu(0)=1 And InStr(Pay_baofu(11),Langname)>0 Then payment = payment &"<tr><td height=""25"" id=""payment_baofu""><label><input type=""radio"" name='paymenttype' value='009' title='"&Pay_baofu(8)&"' onclick='turnit(document.getElementById(""Content_baofu""),document.getElementById(""payment_baofu""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> "& Pay_baofu(8) &"</label></td></tr>"
		If Trim(Pay_baofu(5)) <> "" Then payment = payment &"<tr id=""Content_baofu"" style=""display:none;""><td style=""padding:10px;"">"& Pay_baofu(5) &"</td></tr>"
		rem <-{添加收汇宝支付 2008-7-8 by 56770.kingdge
	    If shb_state=1 Then payment = payment &"<tr><td height=""25"" id=""payment_shb""><label><input type=""radio"" name='paymenttype' value='007' title='Credit Card (Visa,Master)' onclick='turnit(document.getElementById(""Content_shb""),document.getElementById(""payment_shb""));document.getElementById(""Content_1"").style.display=""none"";' style='CURSOR: pointer'> Credit Card (Visa,Master)</label></td></tr>"
		If Trim(shb_info) <> "" Then payment = payment &"<tr id=""Content_shb"" style=""display:none;""><td style=""padding:10px;"">"& shb_info &"</td></tr>"
		rem }->
        payment = payment &"</table>"
%>
		<script language="javascript" type="text/javascript">
		var item_one='start';
		var item_two='start';
		function turnit(ss,bb) {
		  if (ss.style.display=="none") {
			if(item_one!='start') item_one.style.display="none";
			if(item_one!='start') item_two.src="";
			ss.style.display="";
			item_one=ss;
			item_two=bb;
			bb.src="";
		  }
		  else {
			ss.style.display="none";
			bb.src="";
		  }
		}
		</script>
<%
End Function
'..................................
'原在 Lebi_main_cls.asp 中  2008-3-13
'读取 配送方式
'..................................
Public Function shipping()
		Dim area_list_str,area_list_num,AreaId
		Set rs=conn.execute("SELECT id,area_name"& LangTxt &" FROM [Lebi_deliver_area] where parent_id=0 and ShowLang like '%"& LangName &"%' ORDER BY area_order desc,id asc")
		area_list_num = 1
		If rs.eof Then 
		AreaId = 0
		Else 
		AreaId = rs(0)
		do while not rs.eof
			area_list_str = area_list_str & "<option value="""&rs(0)&""""
			If area_list_num = 1 Then area_list_str = area_list_str & " selected"
			area_list_str = area_list_str & ">"&rs(1)&"</option>"
			rs.movenext
			area_list_num = area_list_num + 1
		Loop
		End If 
		rs.close: Set rs = Nothing
		Dim FirstDeliver,bw_price,b_weight,o_price,deliver_name,l_price,f_price
		sql="SELECT a.id,a.deliver_id,a.is_end_pay,a.basic_weight_price,a.basic_weight,a.overstep_price, b.deliver_name"& LangTxt &",b.deliver_info"& LangTxt &",b.deliver_price,a.last_price,a.free_price FROM [Lebi_deliver_list] as a,[Lebi_deliver] as b where a.area_id="&areaid&" and a.deliver_id=b.id ORDER BY a.d_order desc"
		Set rs= conn.execute(SQL)
		If Not rs.eof Then
		i = 0
		b_weight = rs(4)
		o_price = rs(5)
		deliver_name = rs(6)
		l_price = rs(9)
		f_price = rs(10)
		Select Case Config_Lebi_Eshop(15)
		Case "0" bw_price = rs(8)
		Case "1" bw_price = rs(3)
		End Select 
		do while not rs.eof
			FirstDeliver = FirstDeliver &"<tr><td class='listright' colspan='2'><input type='radio' value='"&rs("deliver_id")&"' name='deliver_id' title='"&rs(6)&"' onclick='getDeliverPrice("&i&");'"
			If i = 0 Then FirstDeliver = FirstDeliver &" checked"
			FirstDeliver = FirstDeliver &"> "&rs(6)&"</td></tr>"
			FirstDeliver = FirstDeliver &"<tr><td class='listright' colspan='2'>"&rs(7)&"</td></tr><INPUT TYPE=""hidden"" value="""&rs(2)&""" name=""is_end_pay""><INPUT TYPE=""hidden"" value="""&rs(6)&""" name=""deliver_name""><INPUT TYPE=""hidden"" value="""&rs(4)&""" name=""basic_weight""><INPUT TYPE=""hidden"" value="""&rs(5)&""" name=""overstep_price""><INPUT TYPE=""hidden"" value="""&rs(9)&""" name=""last_price""><INPUT TYPE=""hidden"" value="""&rs(10)&""" name=""free_price"">"
			Select Case Config_Lebi_Eshop(15)
			Case "0" FirstDeliver = FirstDeliver &"<INPUT TYPE=""hidden"" value="""& rs(8) &""" name=""basic_weight_price"">"
			Case "1" FirstDeliver = FirstDeliver &"<INPUT TYPE=""hidden"" value="""& rs(3) &""" name=""basic_weight_price"">"
			End Select 
			rs.movenext
			i = i+1
		Loop
		End If
		rs.close:set rs=Nothing
		%>
		<table width='100%' align='center' cellpadding='0' cellspacing='0'>
		<%If sys_soft = 0 Then%><tr><td class="listright" colspan="2"><%=Lebi_cart(180)%>：<select size="1" name="area_id" onchange="ajaxSub(0,'?action=getDeliverArea2&parentid='+this.value);ajaxSub1(1,'?action=getDeliverList&areaid='+this.value+'&parentid=0');ajaxSub2(1,'?action=getDeliverList&isdefault=1&areaid='+this.value);"><option value="0"><%=Lebi_pro(15)%></option><%=area_list_str%></select>
			<span id="deliver_area_2">
			<%
			Set rs= conn.execute("SELECT id,area_name"& LangTxt &" FROM [Lebi_deliver_area] where parent_id="&AreaId&" ORDER BY area_order desc,id asc")
			If Not rs.eof Then
			        Response.write("<select size=1 name=""area2_id"" onchange=""ajaxSub1(1,'?action=getDeliverList&areaid='+this.value+'&parentid="& AreaId &"');ajaxSub2(1,'?action=getDeliverList&isdefault=1&areaid='+this.value+'&parentid="& AreaId &"');""><option value=""0"">"& Lebi_pro(15) &"</option>")
					do while not rs.eof
					Response.write("<option value="""&rs(0)&""">"&rs(1)&"</option>")
					rs.movenext
					Loop
					Response.write("</select>")
			End If
			rs.close:set rs=Nothing
			Response.write("</span></td></tr>")
			End If 
			If (p_weight) <= b_weight Or Config_Lebi_Eshop(15) = 0 Then
					deliver_price = bw_price
			Else
					If b_weight = 0 Then
							deliver_price = bw_price
					Else
'							If (p_weight) Mod 2 = 0 Then
'									basic_weight = (p_weight*2) - 1
'							Else
'									If (p_weight/2) < 1 Then
'											basic_weight = 1
'									Else
'											basic_weight = ((Split((p_weight/2),".")(0) + 1) * 2) - 1
'									End If
'							End If
							basic_weight = (p_weight - b_weight) / b_weight
							If basic_weight < 1 Then basic_weight = 1
							If InStr(basic_weight,".") > 0 Then basic_weight = Split(basic_weight,".")(0) + 1
							deliver_price = bw_price + (basic_weight * o_price)
					End If
					If l_price > 0 And CLng(deliver_price) >= CLng(l_price) Then deliver_price = l_price
			End If
			If f_price > 0 And CLng(Sum3) >= CLng(f_price) Then deliver_price = 0
			%>
		<tr>
			<td class="listright" colspan="2"><span id="div_deliver_show"><table width='100%' align='center' cellpadding='0' cellspacing='0'><%=FirstDeliver%></table></span></td>
		</tr>
		<tr>
			<td class="listright" colspan="2"><INPUT TYPE="hidden" NAME="p_weight" value="<%=p_weight%>"><INPUT TYPE="hidden" NAME="sendtype" value="<%=deliver_name%>"><INPUT TYPE="hidden" NAME="stype" value="<%=Config_Lebi_Eshop(15)%>"><input type="hidden" name="deliver_price" value="<%=deliver_price%>"><span id="weightmoney">
			<script language="javascript" type="text/javascript">
			document.write("<%If Config_Lebi_Eshop(15) = 1 Then%><strong><%=Lebi_cart(26)%>：</strong><font color=red><%=formatnumber2(p_weight)%></font> Kg&nbsp;&nbsp;<%End if%><strong><%=Lebi_cart(59)%>：</strong><font color=red><%= dw & formatnumber2(deliver_price/moneyhl) & dw2 %></font>");
			</script></span></td>
		</tr>
		</table>
		<script language="javascript" type="text/javascript">
			/***** 配送地区 2008-3-13 by 56770.WangLei **********/
			function getDeliverArea2() {
			  if (xmlHttp.readyState < 4) {
				document.getElementById('deliver_area_2').innerHTML="loading...";
			  }
			  if (xmlHttp.readyState == 4) {
				var response = xmlHttp.responseText;
				document.getElementById('deliver_area_2').innerHTML=response;
			  }
			}
			function ajaxSub2(t,url)
			{
				 webRequest(url+'&t000='+Math.random(), "", "GET", true, function() {
					var xmlhttp = arguments[0];
					var args = new Array();
					if (xmlhttp.readyState == 4) {
						var returntxt = xmlhttp.responseText;
						if (returntxt=="")
						{
						var pweight = document.getElementsByName('p_weight')[0].value;
						document.getElementById('weightmoney').innerHTML = "<%If Config_Lebi_Eshop(15) = 1 Then%><strong><%=Lebi_cart(26)%>：</strong><font color=red>"+(pweight/1).toFixed(<%=Langdecimal%>)+"</font> Kg&nbsp;&nbsp;<%End if%><strong><%=Lebi_cart(59)%>：</strong><font color=red><%= dw%><%=formatnumber2(0)%></font><%= dw2%>";
						document.getElementsByName('sendtype')[0].value = '';
						document.getElementsByName('deliver_price')[0].value = 0;
						}else{
						var deliverPrice = 0
						var pweight = document.getElementsByName('p_weight')[0].value/1;
						var bw_price = returntxt.split("|")[6]/1;
						var b_weight = returntxt.split("|")[2]/1;
						var o_price = returntxt.split("|")[3]/1;
						var d_name = returntxt.split("|")[0];
						var l_price = returntxt.split("|")[4]/1;
						var f_price = returntxt.split("|")[5]/1;
						if ((pweight <= b_weight) || (<%=Config_Lebi_Eshop(15)%>==0))
						{
							deliverPrice = bw_price;
						}else
						{
							if (b_weight==0)
							{
								deliverPrice = bw_price/1;
							}else{
								deliverPrice = bw_price/1 + (Math.ceil((pweight-b_weight)/b_weight)) * o_price;
							}
							if (l_price >0 && deliverPrice >= l_price){deliverPrice = l_price}
						}
						if (f_price >0 && <%=sum3%> >= f_price){deliverPrice = 0}
						document.getElementById('weightmoney').innerHTML = "<%If Config_Lebi_Eshop(15) = 1 Then%><strong><%=Lebi_cart(26)%>：</strong><font color=red>"+(pweight/1).toFixed(<%=Langdecimal%>)+"</font> Kg&nbsp;&nbsp;<%End if%><strong><%=Lebi_cart(59)%>：</strong><font color=red><%= dw%>"+(deliverPrice/moneyhl).toFixed(<%=Langdecimal%>)+"<%= dw2%></font>";
						document.getElementsByName('sendtype')[0].value = d_name;
						document.getElementsByName('deliver_price')[0].value = deliverPrice;
						}
					}
				 }, "");
			}
			/***** 配送方式列表地区 2008-3-13 by 56770.WangLei **********/
			function ajaxSub1(t,url)
			{
				xmlHttp1.open("GET", url+'&t000='+Math.random(), true);
				xmlHttp1.onreadystatechange = getDeliverList;
				xmlHttp1.send(null);
			}

			function getDeliverList() {
			  if (xmlHttp1.readyState < 4) {
				document.getElementById('div_deliver_show').innerHTML="<span>loading...</span>";
			  }
			  if (xmlHttp1.readyState == 4) {
				var response = xmlHttp1.responseText;
				if (response == "")
				{
					var pweight = document.getElementsByName('p_weight')[0].value;
					document.getElementById('div_deliver_show').innerHTML="";
					document.getElementById('weightmoney').innerHTML = "<%If Config_Lebi_Eshop(15) = 1 Then%><strong><%=Lebi_cart(26)%>：</strong><font color=red>"+(pweight/1).toFixed(<%=Langdecimal%>)+"</font> Kg&nbsp;&nbsp;<%End if%><strong><%=Lebi_cart(59)%>：</strong><font color=red><%= dw%><%=formatnumber2(0)%></font><%= dw2%>";
					document.getElementsByName('sendtype')[0].value = '-';
					document.getElementsByName('deliver_price')[0].value = 0;
				}else
				{
					document.getElementById('div_deliver_show').innerHTML="<table cellspacing=0 cellpadding=0 border=0 width=100%>"+ response +"</table>";
					document.getElementById('weightmoney').innerHTML = "<%If Config_Lebi_Eshop(15) = 1 Then%><strong><%=Lebi_cart(26)%>：</strong><font color=red><%=formatnumber2(0)%></font> Kg&nbsp;&nbsp;<%End if%><strong><%=Lebi_cart(59)%>：</strong><font color=red><%= dw%><%=formatnumber2(0)%></font><%= dw2%>";
					document.getElementsByName('sendtype')[0].value = '';
					document.getElementsByName('deliver_price')[0].value = 0;
				}
			  }
			}

			function getDeliverPrice(i)
			{
				var deliverPrice = 0
				var pweight = document.getElementsByName('p_weight')[0].value/1;
				var bw_price = document.getElementsByName('basic_weight_price')[i].value/1;
				var b_weight = document.getElementsByName('basic_weight')[i].value/1;
				var o_price = document.getElementsByName('overstep_price')[i].value/1;
				var d_name = document.getElementsByName('deliver_name')[i].value;
				var l_price = document.getElementsByName('last_price')[i].value/1;
				var f_price = document.getElementsByName('free_price')[i].value/1;
				if ((pweight <= b_weight) || (<%=Config_Lebi_Eshop(15)%>==0))
				{
					deliverPrice = bw_price;
				}else
				{
					if (b_weight==0)
					{
						deliverPrice = bw_price/1;
					}else{
						deliverPrice = bw_price/1 + (Math.ceil((pweight-b_weight)/b_weight)) * o_price;
					}
					if (l_price >0 && deliverPrice >= l_price){deliverPrice = l_price}
				}
				if (f_price >0 && <%=sum3%> >= f_price){deliverPrice = 0}
				document.getElementById('weightmoney').innerHTML = "<%If Config_Lebi_Eshop(15) = 1 Then%><strong><%=Lebi_cart(26)%>：</strong><font color=red>"+(pweight/1).toFixed(<%=Langdecimal%>)+"</font> Kg&nbsp;&nbsp;<%End if%><strong><%=Lebi_cart(59)%>：</strong><font color=red><%= dw%>"+(deliverPrice/moneyhl).toFixed(<%=Langdecimal%>)+"<%= dw2%></font>";
				document.getElementsByName('sendtype')[0].value = d_name;
				document.getElementsByName('deliver_price')[0].value = deliverPrice;
			}

			function setPackingPrice(p)
			{
				document.getElementsByName('packing_price')[0].value = p;
				//alert(document.getElementsByName('packing_price')[0].value);
			}
		</script>
<%
End Function

rem	<-{ 获得地市级配送地区 2008-3-13 by 56770.WangLei
sub getDeliverArea2()
	Dim parentid,tstr
	parentid= CInt(request("parentid"))
	If parentid = 0 Then response.End
	sql="SELECT id,area_name"& LangTxt &" FROM [Lebi_deliver_area] where parent_id="&parentid&" and ShowLang like '%"& Langname &"%' ORDER BY area_order desc,id asc"
	Set rs= conn.execute(SQL)
	If Not rs.eof Then
			tstr = "<select size=1 name=""area2_id"" onchange=""ajaxSub1(1,'?action=getDeliverList&areaid='+this.value+'&parentid="&parentid&"');ajaxSub2(1,'?action=getDeliverList&isdefault=1&areaid='+this.value+'&parentid="&parentid&"');""><option value=""0"">"&Lebi_pro(15)&"</option>"
			do while not rs.eof
			tstr = tstr & "<option value="""&rs(0)&""">"&rs(1)&"</option>"
			rs.movenext
			Loop
			tstr = tstr & "</select>"
	End If
	rs.close:set rs=Nothing
	response.write(tstr)
	response.End
End sub
rem	}->

rem	<-{ 获得配送方式列表 2008-3-13 by 56770.WangLei
sub getDeliverList()
	Dim areaid,parentid,tstr,i
	areaid= checknum(request("areaid"),0)
	parentid= checknum(request("parentid"),0)
	isdefault= checknum(request("isdefault"),0)
	If parentid <> 0 Then 
		set rs = conn.execute("SELECT parent_id FROM [Lebi_deliver_area] WHERE id="& areaid &"")
		If not rs.eof Then 
		parentid = rs(0)
		End If 
		rs.close : set rs = nothing
	End If 
	sql="SELECT a.id,a.deliver_id,a.is_end_pay,a.basic_weight_price,a.basic_weight,a.overstep_price,b.deliver_name"& LangTxt &",b.deliver_info"& LangTxt &",b.deliver_price,a.last_price,a.free_price FROM [Lebi_deliver_list] as a,[Lebi_deliver] as b where a.area_id="&areaid&" and a.deliver_id=b.id ORDER BY a.d_order desc,area_id desc"
	Set rs= conn.execute(SQL)
	If Not rs.eof Then 
	If isdefault = 1 Then 
		tstr = tstr & rs(6) &"|"& rs(2) &"|"& rs(4) &"|"& rs(5) &"|"& rs(9) &"|"& rs(10) &"|"
		If CInt(Config_Lebi_Eshop(15)) = 0 Then
			tstr = tstr & rs(8)
		Else
			tstr = tstr & rs(3)
		End If
	Else 
	i = 0
	do while not rs.eof
		tstr = tstr & "<tr><td class=""listright"" colspan=""2""><label><input type=""radio"" value="""&rs(1)&""" name=""deliver_id"" title='"&rs(6)&"' onclick=""getDeliverPrice("&i&");"""
		If i = 0 Then tstr = tstr & " checked"
		tstr = tstr & "> "&rs(6)&"</label></td></tr>"
		tstr = tstr & "<tr><td class=""listright"" colspan=""2"">"&rs(7)&"</td></tr><input type=""hidden"" value="""&rs(2)&""" name=""is_end_pay""><input type=""hidden"" value="""&rs(6)&""" name=""deliver_name""><input type=""hidden"" value="""&rs(4)&""" name=""basic_weight""><input type=""hidden"" value="""&rs(5)&""" name=""overstep_price""><input type=""hidden"" value="""&rs(9)&""" name=""last_price""><input type=""hidden"" value="""&rs(10)&""" name=""free_price"">"
		If CInt(Config_Lebi_Eshop(15)) = 0 Then
			tstr = tstr & "<input type=""hidden"" value="""&rs(8)&""" name=""basic_weight_price"">"
		Else
			tstr = tstr & "<input type=""hidden"" value="""&rs(3)&""" name=""basic_weight_price"">"
		End If
		rs.movenext
		i = i+1
	Loop
	End If 
	End If 
	rs.close:set rs=Nothing
	If tstr = "" And parentid > 0 Then
		sql="SELECT a.id,a.deliver_id,a.is_end_pay,a.basic_weight_price,a.basic_weight,a.overstep_price,b.deliver_name"& LangTxt &",b.deliver_info"& LangTxt &",b.deliver_price,a.last_price,a.free_price FROM [Lebi_deliver_list] as a,[Lebi_deliver] as b where a.area_id="&parentid&" and a.deliver_id=b.id ORDER BY a.d_order desc,area_id desc"
		Set rs= conn.execute(SQL)
		If Not rs.eof Then 
		If isdefault = 1 Then 
			tstr = tstr & rs(6) &"|"& rs(2) &"|"& rs(4) &"|"& rs(5) &"|"& rs(9) &"|"& rs(10) &"|"
			If CInt(Config_Lebi_Eshop(15)) = 0 Then
				tstr = tstr & rs(8)
			Else
				tstr = tstr & rs(3)
			End If
		Else 
		i = 0
		do while not rs.eof
			tstr = tstr & "<tr><td class=""listright"" colspan=""2""><label><input type=""radio"" value="""&rs(1)&""" name=""deliver_id"" title='"&rs(6)&"' onclick=""getDeliverPrice("&i&");"""
			If i = 0 Then tstr = tstr & " checked"
			tstr = tstr & "> "&rs(6)&"</label></td></tr>"
			tstr = tstr & "<tr><td class=""listright"" colspan=""2"">"&rs(7)&"</td></tr><input type=""hidden"" value="""&rs(2)&""" name=""is_end_pay""><input type=""hidden"" value="""&rs(6)&""" name=""deliver_name""><input type=""hidden"" value="""&rs(4)&""" name=""basic_weight""><input type=""hidden"" value="""&rs(5)&""" name=""overstep_price""><input type=""hidden"" value="""&rs(9)&""" name=""last_price""><input type=""hidden"" value="""&rs(10)&""" name=""free_price"">"
			If CInt(Config_Lebi_Eshop(15)) = 0 Then
				tstr = tstr & "<input type=""hidden"" value="""&rs(8)&""" name=""basic_weight_price"">"
			Else
				tstr = tstr & "<input type=""hidden"" value="""&rs(3)&""" name=""basic_weight_price"">"
			End If
			rs.movenext
			i = i+1
		Loop
		End If 
		End If 
		rs.close:set rs=Nothing
	End If
	response.write(tstr)
	response.End
End sub
rem	}->

rem	<-{ 显示包装列表 2008-3-14 by 56770.WangLei
Function PackingList()
	Dim p_rs,i : i = 0
	Set p_rs= conn.execute("select id,packing_price,pic,packing_name"& LangTxt &",packing_info"& LangTxt &" from [Lebi_packing] where packing_type<>0 order by id desc")
	do while not p_rs.eof
		PackingList = PackingList & "<tr><td><label><input type=radio value="""&p_rs(0)&""" name=packing_id onclick=""setPackingPrice('"&p_rs(1)&"');""> "&p_rs(3)&"</label>&nbsp;&nbsp;"&Lebi_cart(162)&"：<FONT COLOR=red>"& dw & formatnumber2(p_rs(1)/moneyhl) & dw2 &"</FONT>"
		If trim(p_rs(2)) <> "" Then PackingList = PackingList & "&nbsp;&nbsp;<img src='"& Eshop_url &"images/img.gif' align='absmiddle' onMouseover=""javascript:ddrivetip('<img src="& Eshop_url & trim(p_rs(2))&" height=100>', '#ffffff', '100')"" onMouseout=""hideddrivetip()"">"
		PackingList = PackingList & "</td></tr><tr><td style=""padding-left:25px"">"& Replace(p_rs(4),Chr(13),"<br/>") &"</td></tr>"
		p_rs.movenext
		i = i+1
	Loop
	p_rs.close : Set p_rs = Nothing
	PackingList = "<tr><input type=""hidden"" name=""packing_price""><td><input type=radio checked value=""0""  name=packing_id onclick=""setPackingPrice('0');""> "& Lebi_cart(163) &"</td></tr>" & PackingList
	PackingList = "<table border=0 width=""100%"" >"&PackingList&"</table>"
End Function
rem	}->

Function BasketList()
		Dim strFile,strFile2,LoopStr(4),tstr,tmpstr,tmpstr2
		strFile = Eshop_url& Style_Folder &"Lebi.Basket_Cashsave_Product."
	    sql="select id,bianhao,product_name,price,basket_count,color,chima from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <>'')) and Isgift = 0 order by id desc"
	    set rs = conn.execute(sql)
		rs_bof_eof_product=rs.eof and rs.bof
        If Not (rs.eof And rs.bof) Then
				BasketList = splits(LoadStyle(strFile&"0.style"))
				if EshopUseType = 1 Then
						tstr = splits(LoadStyle(strFile&"0.style"))
						ReplaceStyle "property0",splits(LoadStyle(strFile&"1.style")),BasketList
				Else
						ReplaceStyle "property0","",BasketList
				End If
				LoopStr(0) = LoadStyle(strFile&"2.style")
				LoopStr(1) = LoadStyle(strFile&"3.style")
				LoopStr(2) = LoadStyle(strFile&"4.style")
				LoopStr(3) = LoadStyle(strFile&"5.style")
				Do While Not rs.EOF
						tmpstr = LoopStr(0)
						if EshopUseType = 1 Then
								tstr = LoopStr(1)
								ReplaceStyle "color",rs("color"),tstr
								ReplaceStyle "size",rs("chima"),tstr
								ReplaceStyle "property1",tstr,tmpstr
						Else
								ReplaceStyle "property1","",tmpstr
						End If
						ReplaceStyle "number",rs("bianhao"),tmpstr
						ReplaceStyle "name",rs("product_name"),tmpstr
						ReplaceStyle "price",Formatnumber2(rs("price")/moneyhl),tmpstr
						ReplaceStyle "count",rs("basket_count"),tmpstr
						ReplaceStyle "total",FormatNumber2(rs("price")*rs("basket_count")/moneyhl),tmpstr
						ReplaceStyle "correlative_product","",tmpstr
						BasketList = BasketList & tmpstr
				rs.MoveNext
				Loop
				BasketList = BasketList & LoadStyle(strFile&"6.style")
		End If
        rs.close:Set rs=Nothing
		strFile2 = Eshop_url& Style_Folder &"Lebi.Basket_Cashsave_Gift."
		set rs = conn.execute("select Basket_count,product_name,price from [Lebi_lsbuy] where (sessionid="& CookiesId &" or (User_Id = '"& Lebi_UserId &"' and User_Id <>'')) and Isgift = 1 order by id desc")
		If Not rs.eof Then
				BasketGiftList = splits(LoadStyle(strFile2&"0.style"))
				tmpstr = LoadStyle(strFile2&"1.style")
				tstr = ""
				Do While Not rs.eof
						loopstr2 = tmpstr
						ReplaceStyle "name",rs("product_name"),LoopStr2
						ReplaceStyle "price",FormatNumber2(rs("price")/moneyhl),LoopStr2
						ReplaceStyle "count",rs("basket_count"),LoopStr2
						ReplaceStyle "total",FormatNumber2(rs("price")*rs("basket_count")/moneyhl),LoopStr2
						tstr = tstr & loopstr2
						rs.movenext
				Loop
				BasketGiftList = BasketGiftList & tstr & LoadStyle(strFile2&"2.style")
		End If
		rs.close:Set rs=Nothing
		BasketList = BasketList & BasketGiftList
End Function
%>