<!-- #include file="skin.asp" -->
<!-- #include file="jk_nsort.asp" -->
<!-- #include file="jk_keyes.asp" -->
<!-- #include file="joekoe_pay.asp" -->
<!-- #include file="../style/data_sort_dmain.asp" -->
<%
dim n_name
cid=0
sid=0
n_sort="dmain"
index_url="dmain"
tit_fir=format_menu(index_url)
m_channel=index_url
web_img_m="m_"&m_channel
web_img_h="h_"&m_channel

sub dmain_load()
  response.write joekoe_cms.js_put("style/con_dmain.js",0)
end sub

sub dmain_end()
  if isarray(sort_dim) then erase sort_dim
end sub

sub dmain_left()
  dim tmp
  tmp=CMS_Skin.GetDB("dmain_tool")
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  call dmain_left_table("域名订购",tmp,3,1)
end sub

sub dmain_searchs()
dim tmp
tmp=CMS_Skin.GetDB("dmain_cxun")
tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
call dmain_center_table("域名查询",tmp,3,1)
end sub

sub dmain_left_nsort(ltype)
    call dmain_left_table("产品分类",nsort_left_type("dmain_list.asp?",ltype),2,0)
end sub

sub dmain_cs_name()
  if cname<>"" then
    n_name=cname
    if sname<>"" then
      n_name=n_name&"→"&sname
    end if
  end if
  if n_name<>"" then
    n_name="（"&n_name&"）"
  end if
end sub

sub dmain_good(sqlvar)
  dim price,price_now,discount,name,remark_1,tmp
  sql="select top 1 id,name,smallimg,brand,remark_1,price,discount,is_emoney,emoney from dmain_product where hidden=1 and isgood=1"&sqlvar&" order by id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    name=joekoe_cms.code_html(rs("name"),1,0)
    remark_1=joekoe_cms.code_html(rs("remark_1"),2,0)
    price=fm_price(rs("price"),0)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    tmp=tmp&"<td width='100%'>"&dmain_main_good(rs("id"),name,rs("smallimg"),rs("brand"),price,price_now,discount,rs("is_emoney"),rs("emoney"),remark_1)&"</td>"
    rs.movenext
  loop
  rs.close
  call dmain_center_table("推荐域名",tmp,1,1)
end sub

sub dmain_cast_top(n_num,c_num)
  dim n_topic,n_tim,tmp
  sql="select top "&n_num&" id,topic,tim from dmain_cast where hidden=1 order by istop desc,id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    n_topic=rs("topic")
    n_tim=rs("tim")
    n_tim=joekoe_cms.time_type(n_tim,1)
    tmp=tmp&dmain_topic_type(c_num,rs("id"),n_topic,n_tim)
	tmp=tmp&"<tr align=right><td><a href='dmain_cast.asp'>浏览更多域名公告…</a>&nbsp;&nbsp;</td></tr>"
    rs.movenext
  loop
  rs.close
  call dmain_left_table("域名公告",tmp,1,1)
end sub

sub dmain_top(n_num,c_num)
  dim n_topic,n_counter,tmp
  sql="select top "&n_num&" id,name,buy_counter from dmain_product order by buy_counter desc,id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
  n_topic=rs("name")
  n_topic=joekoe_cms.code_js(n_topic,1)
  n_counter=rs("buy_counter")
  tmp=tmp&vbcrlf&"<tr>" &_
          vbcrlf&"<td>"&img_skin(web_img_m)&"</td>" &_
		  vbcrlf&"<td align=left><a href='dmain_view.asp?id="&rs("id")&"' alt='"&joekoe_cms.code_html(n_topic,1,0)&"'>"&joekoe_cms.code_html(n_topic,1,c_num)&"</a></td>" &_
		  vbcrlf&"<td align=right>"&n_counter&"</td>" &_
		  vbcrlf&"</tr>"
  rs.movenext
loop
rs.close
  call dmain_left_table("销售排行",tmp,4,1)
end sub

function fm_discount(dvar)
  if dvar>=100 then
    fm_discount="不打折"
    exit function
  end if 
  fm_discount=cstr(dvar/10)&"折"
end function

function dmain_emoney_pay(p_is_emoney,p_emoney,p_id,put)
  dim nemoney
  nemoney=0
  if p_is_emoney=true then nemoney=p_emoney
  dmain_emoney_pay=note_emoney_pay(nemoney,n_sort,p_id,put)
end function

sub dmain_search()
dim temp1,tmp
temp1=temp1&vbcrlf&"<table border=0>" & _
          vbcrlf&"<form name=dmain_sea_frm action='dmain_list.asp' method=get onsubmit=""javascript:frm_submitonce(this);"">" & _
          vbcrlf&"<input type=hidden name=action value='search'>" & _
          vbcrlf&"<tr>" & _
          vbcrlf&"<td>"&img_skin("new")&"</td>" & _
          vbcrlf&"<td width=5></td>" & _
          vbcrlf&"<td>"&select_type("域名",0,0)&"</td>" & _
          vbcrlf&"<td width=5></td>" & _
          vbcrlf&"<td><select name=sea_type sizs=1><option value='name'>域名名称</option><option value='price'>域名价格</option><option value='brand'>域名品牌</option><option value='serial'>域名编号</option></seelct></td>" & _
          vbcrlf&"<td width=5></td>" & _
          vbcrlf&"<td><select name=sea_term sizs=1><option value='all'>满足所有条件</option><option value='only'>满足一个条件</option></seelct></td>" & _
          vbcrlf&"<td width=5></td>" & _
          vbcrlf&"<td><input type=text name=keyword size=20 maxlength=20 title='多个关键字请用 空格 格开' class=bg_search></td>" & _
          vbcrlf&"<td width=5></td>" & _
          vbcrlf&"<td><input type=submit value='搜索'></td>" & _
          vbcrlf&"</tr></form></table>"
  call dmain_center_table("域名搜索",temp1,3,0)
end sub

sub dmain_left_table(tit,body,ttype,tt)
  dim w_wid,tmp
  w_wid="70"
  if len(tit)>8 then w_wid="240"
  if len(tit)>20 then w_wid="400"
  if tt=1 then body="<table border=0 width='100%'>"&body&"</table>"
  tmp=CMS_Skin.GetDB("dmain_left")
  tmp=Replace(tmp,"{$wid}",w_wid)
  tmp=Replace(tmp,"{$tit}",tit)
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  tmp=Replace(tmp,"{$channel}",m_channel)
  tmp=Replace(tmp,"{$ttype}",ttype)
  tmp=Replace(tmp,"{$body}",body)
  tmp=Replace(tmp,"{$ukong}",CMS_Skin.skukong)
  Response.Write(vbcrlf&tmp)
end sub

sub dmain_center_table(tit,body,ttype,tt)
  dim w_wid,tmp
  w_wid="70"
  if len(tit)>8 then w_wid="240"
  if len(tit)>20 then w_wid="400"
  if tt=1 then body="<table border=0 width='100%'>"&body&"</table>"
  tmp=CMS_Skin.GetDB("dmain_center")
  tmp=Replace(tmp,"{$wid}",w_wid)
  tmp=Replace(tmp,"{$tit}",tit)
  tmp=Replace(tmp,"{$web_skin}",joekoe_cms.web_dir_skin)
  tmp=Replace(tmp,"{$channel}",m_channel)
  tmp=Replace(tmp,"{$ttype}",ttype)
  tmp=Replace(tmp,"{$body}",body)
  tmp=Replace(tmp,"{$ukong}",CMS_Skin.skukong)
  Response.Write(vbcrlf&tmp)
end sub

function dmain_bar_end(mvar,tt)
  dim temp1
  if tt=1 then temp1=temp1&vbcrlf&"  </table>"
  temp1=temp1&vbcrlf&"</td></tr>"
  if mvar<>"" then temp1=temp1&vbcrlf&"<tr><td align=right>"&mvar&"&nbsp;&nbsp;</td></tr>"
  temp1=temp1&vbcrlf&"</table>"
  dmain_bar_end=temp1&ukong
end function

function dmain_topic_type(b_c_num,b_id,b_topic,b_tim)
  dim n_url,n_jt
  n_url="dmain_cast.asp?action=view&id="&b_id
  n_jt=img_skin(web_img_h)
  dmain_topic_type="<tr><td>"&n_jt&"<a href='"&n_url&"' alt='公告标题："&joekoe_cms.code_html(b_topic,1,0)&"<br>发布时间："&b_tim&"' target=_blank>"&joekoe_cms.code_html(b_topic,1,b_c_num)&"</a></td></tr>"
end function

function dmain_list_type(n_id,n_name,n_smallimg,n_brand,n_price,n_price_now,n_discount,n_is_emoney,n_emoney)
   dim temp1
  temp1=CMS_Skin.GetDB("dmain_list")
  temp1=Replace(temp1,"{$pic}",pic_fk(n_smallimg,1,"dmain_view.asp?id="&n_id))
  temp1=Replace(temp1,"{$id}",n_id)
  temp1=Replace(temp1,"{$name}",n_name)
  temp1=Replace(temp1,"{$price_now}",n_price_now)
  temp1=Replace(temp1,"{$val_unit}",web_dim(45))
  temp1=Replace(temp1,"{$price}",n_price)
  temp1=Replace(temp1,"{$discount}",n_discount)
  temp1=Replace(temp1,"{$web_unit}",joekoe_cms.web_unit)
  temp1=Replace(temp1,"{$dmain_emoney_pay}",dmain_emoney_pay(n_is_emoney,n_emoney,n_id,1))
  temp1=Replace(temp1,"{$web_dir_skin}",joekoe_cms.web_dir_skin)
  dmain_list_type=temp1
end function

function dmain_main_good(n_id,n_name,n_smallimg,n_brand,n_price,n_price_now,n_discount,n_is_emoney,n_emoney,n_remark_1)
  dim temp1
  temp1=CMS_Skin.GetDB("dmain_good")
  temp1=Replace(temp1,"{$pic}",pic_fk(n_smallimg,2,"dmain_view.asp?id="&n_id))
  temp1=Replace(temp1,"{$id}",n_id)
  temp1=Replace(temp1,"{$name}",n_name)
  temp1=Replace(temp1,"{$price_now}",n_price_now)
  temp1=Replace(temp1,"{$val_unit}",web_dim(45))
  temp1=Replace(temp1,"{$web_dir_skin}",joekoe_cms.web_dir_skin)
  temp1=Replace(temp1,"{$price}",n_price)
  temp1=Replace(temp1,"{$discount}",n_discount)
  temp1=Replace(temp1,"{$web_unit}",joekoe_cms.web_unit)
  temp1=Replace(temp1,"{$dmain_emoney_pay}",dmain_emoney_pay(n_is_emoney,n_emoney,n_id,1))
  temp1=Replace(temp1,"{$brand}",n_brand)
  temp1=Replace(temp1,"{$remark}",n_remark_1)
  dmain_main_good=temp1
end function

sub dmain_list()
  dim price,price_now,discount,name,li,tmp
  li=0
  sql="select top 6 id,name,smallimg,brand,price,discount,is_emoney,emoney from dmain_product where hidden=1"&sql_var&" order by id desc"
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    if (li mod 2)=0 then tmp=tmp&"<tr valign=top>"
    name=joekoe_cms.code_html(rs("name"),1,13)
    price=fm_price(rs("price"),0)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    tmp=tmp&"<td width='50%'>"&dmain_list_type(rs("id"),name,rs("smallimg"),rs("brand"),price,price_now,discount,rs("is_emoney"),rs("emoney"))&"</td>"
    if (li mod 2)>0 then tmp=tmp&"</tr>"
    rs.movenext
    li=li+1
  loop
  rs.close
tmp=tmp&"<table border=0 width='95%'><tr><td align=right height=30><a href='?action=more&c_id="&cid&"&s_id="&sid&"&taxis='>浏览更多<font class=red2>"&n_name&"</font>...</a></td></tr>"
call dmain_center_table("域名列表"&n_name,tmp,2,1)
end sub

function dmain_list_taxis_sql(n_taxis)
  dim temp1
  select case n_taxis
  case "tim"
    temp1="tim desc,id desc"
  case "buy"
    temp1="buy_counter desc,id desc"
  case "price_high"
    temp1="price desc,id desc"
  case "price_low"
    temp1="price,id desc"
  case "counter"
    temp1="counter desc,id desc"
  case else
    temp1="id desc"
  end select
  dmain_list_taxis_sql=temp1
end function

sub dmain_list_more()
  dim pageurl,sql_add,li,price,price_now,discount,name,tmp
  li=0
  pageurl="?action="&action&"&c_id="&cid&"&s_id="&sid&"&"
  sql="select count(id) from dmain_product where hidden=1"&sql_var
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" id,name,smallimg,brand,price,discount,is_emoney,emoney from dmain_product where hidden=1"&sql_var&" order by "&dmain_list_taxis_sql(taxis)
  call joekoe_cms.exec("",-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then
    rs.move (viewpage-1)*nummer
  end if
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums
  if (li mod 2)=0 then tmp=tmp&"<tr valign=top>"
     name=joekoe_cms.code_html(rs("name"),1,13)
    price=fm_price(rs("price"),0)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    tmp=tmp&"<td width='50%'>"&dmain_list_type(rs("id"),name,rs("smallimg"),rs("brand"),price,price_now,discount,rs("is_emoney"),rs("emoney"))&"</td>"
     if (li mod 2)>0 then tmp=tmp&"</tr>"
     rs.movenext
    li=li+1
  next
  rs.close
  call dmain_center_table("域名列表"&n_name,tmp,2,1)
  call dmain_pagecute(rssum,viewpage,thepages,pageurl,taxis)
end sub

function dmain_pagecute(n_rssum,n_viewpage,n_thepages,n_pageurl,n_taxis)
   response.write vbcrlf&"<table border=0 cellspacing=0 cellpadding=2 width='98%'>" & _
    vbcrlf&"<tr>" & _
    vbcrlf&"<td> 共有<font class=red>"&n_rssum&"</font>个域名，<font class=red>"&n_viewpage&"</font>/<font class=red>"&n_thepages&"</font>页 分页："&jk_pagecute(nummer,n_thepages,n_viewpage,n_pageurl&"taxis="&n_taxis&"&",5,"#ff0000")&"</td>" & _
    vbcrlf&"<td align=right><select name=taxis size=1 onchange=""javascript:dmain_sel_taxis(this.options[this.selectedIndex].value);"">" & _
    vbcrlf&"<option value=''>－请选择显示方式－</option>" & _
    vbcrlf&"<option value='tim'>按上架时间排序</option>" & _
    vbcrlf&"<option value='buy'>按订购次数排序</option>" & _
    vbcrlf&"<option value='price_high'>按价格由高到低排序</option>" & _
    vbcrlf&"<option value='price_low'>按价格由低到高排序</option>" & _
    vbcrlf&"<option value='counter'>按点击次数排序</option>" & _
    vbcrlf&"</select> </td>" & _
    vbcrlf&"</tr>" & _
    vbcrlf&"</table>"&ukong & _
    vbcrlf&"<script language=javascript>" & _
    vbcrlf&"function dmain_sel_taxis(tvar)" & _
    vbcrlf&"{" & _
    vbcrlf&"  if (tvar=="""" || tvar==null) {return;}" & _
    vbcrlf&"  location.href="""&n_pageurl&"taxis=""+tvar;" & _
    vbcrlf&"}" & _
    vbcrlf&"</script>"
end function


sub dmain_main_list(ltype,l_num)
  dim n_tit,price,price_now,discount,name,li,t,tmp
  sql="select top "&(2*l_num)&" id,name,smallimg,brand,price,discount,is_emoney,emoney from dmain_product where hidden=1"
  select case ltype
  case "good"
    sql=sql&" and isgood=1 order by tim desc,id desc"
    n_tit="推荐"
    t=2
  case "hot"
    sql=sql&" order by buy_counter desc,id desc"
    n_tit="热门"
    t=3
  case else
    sql=sql&" order by tim desc,id desc"
    n_tit="最新"
    t=4
  end select
  li=0
  set rs=joekoe_cms.exec(sql,1)
  do while not rs.eof
    if (li mod 2)=0 then tmp=tmp&"<tr valign=top>"
    name=joekoe_cms.code_html(rs("name"),1,13)
    price=fm_price(rs("price"),0)
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    tmp=tmp&"<td width='50%'>"&dmain_list_type(rs("id"),name,rs("smallimg"),rs("brand"),price,price_now,discount,rs("is_emoney"),rs("emoney"))&"</td>"
    if (li mod 2)>0 then tmp=tmp&"</tr>"
    rs.movenext
    li=li+1
  loop
  rs.close
  if (li mod 2)>0 then
    tmp=tmp&"<td width='50%'></td></tr>"
  end if
  call dmain_center_table(n_tit&"域名",tmp,t,1)
end sub

sub dmain_main_nsort(n_num,c_num)
  dim ncid,ncname,crs,csql,sqla,name,hid,iisnum,price_now,discount,price,tmp


  csql="select c_id,c_name from jk_class where nsort='"&n_sort&"' order by c_order"
  set crs=joekoe_cms.exec(csql,1)
  do while not crs.eof
    ncid=crs("c_id")
    ncname=crs("c_name")
    sqla=" and c_id="&ncid
    sql="select top "&n_num&" id,name,hid,iisnum,price,discount,is_emoney,emoney from dmain_product where hidden=1 and c_id="&ncid&" order by id desc"
    set rs=conn.execute(sql)
    tmp="<table border=0 width='100%'><tr class=bg_tds height=25 align=center>" & _
"<td width='20%' align=center>域名名称</td>" & _
"<td width='16%' align=center>DNS管理</td>" & _
"<td width='12%' align=center>二级域名数</td>" & _
"<td width='16%' align=center>现价（元/年）</td>" & _
"<td width='16%' align=center>金币支付</td>" & _
"<td width='20%' align=center>操作属性</td>" & _
"</tr>"
    do while not rs.eof

    name=joekoe_cms.code_html(rs("name"),1,0)
	hid=rs("hid")
	price=fm_price(rs("price"),0)
	iisnum=rs("iisnum")
    discount=rs("discount")
    price_now=fm_price(price*(discount/100),0)
    discount=fm_discount(discount)
    tmp=tmp&dmain_nsort_type(c_num,rs("id"),name,price,hid,iisnum,discount,price_now,1)
    rs.movenext
    loop
    rs.close
    call dmain_center_table(ncname,tmp,1,1)
    tmp=""
    crs.movenext
  loop
  crs.close
  set crs=nothing
    tmp=tmp&"</table>"
end sub

function dmain_nsort_type(b_c_num,b_id,name,price,hid,iisnum,discount,price_now,tcolor)
  dim n_jt,n_img,tim_type,b_ispic

  dmain_nsort_type="" & _

"<tr class=bg_td height=25 align=center>" & _
"<td><a href='dmain_view.asp?id="&b_id&"' target=_blank><font class=blue><b>"&joekoe_cms.code_html(name,1,0)&"</b></font></a></td>" & _
"<td>"&hid&"</td>" & _
"<td>"&iisnum&"&nbsp个</td>" & _
"<td>"&price&"</td>" & _
"<td>"&dmain_emoney_pay(rs("is_emoney"),rs("emoney"),rs("id"),1)&"</td>" & _
"<td><a href='javascript:;' onclick=javascript:open_view('dmain_bag.asp?id="&b_id&"',1);><img src='"&joekoe_cms.web_dir_skin&"main/button_bag.gif' border=0></a><a href='javascript:;' onclick=javascript:open_view('dmain_view.asp?id="&b_id&"',1);><img src='"&joekoe_cms.web_dir_skin&"main/button_view.gif' border=0></a></td>" & _
"</tr>"
end function

sub dmain_bag_close()
  if int(format_mid_num(20))=0 then
    response.write joekoe_cms.js_put("alert(""对不起！本商城盘货整理中，暂时关闭商城购物功能。\n\n请大家谅解！我们将很快恢复购物。\n\n如有急需，请与管理员"&web_dim(3)&"（E_mail："&web_dim(4)&"）联系！"");window.close()",1)
    exit sub
  end if
end sub
%>
