<%@ Language=VBScript %>
<!--#include virtual="/inc-freehost-function/FreeHostFunction.asp"-->
<!--#include virtual="/inc-freehost-function/FreeHostFunctionMain.asp"-->
<%
If session("VPSAUID")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。"
elseIf session("agentusername")="" Then
	ef=True
	ec="授权非法，有可能是超时造成的。此功能只有代理可以操作。"
ElseIf not IsNumeric(session("VPSAUID"))  Then
	ef=True
	ec="产品ID应该是数字！"
ElseIf Instr(1, Request("id"), "'", 1)>0 then
	ef=True
	ec="非法产品ID！"
ElseIf not IsNumeric(Request("id"))  Then
	ef=True
	ec="产品ID应该是数字！"
end if

if not ef then
Set conn=Server.CreateObject("ADODB.Connection")
	conn.Open Application("FreeHostDBlink")
	Set dsph = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_Product_VPS where id='"&session("VPSAUID")&"'"
			if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsph.Open Sql,conn,1,1
if dsph.Eof then
	ef=True
	ec="不存在的云服务器产品ID！"
end if
end If

if not ef then
if dsph("agent1")<>session("agentusername") then
	ef=True
	ec="此云服务器产品ID并不是当前代理名下所有！"
end If
end if

if not ef then
	Set ds = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_USER where (agent1='"&session("agentusername")&"' or agent2='"&session("agentusername")&"') and username='"&dsph ("username")&"'"
if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end If

		ds.Open Sql,conn,1,1
if ds.eof then
	ef=True
	ec="用户不存在!"
end if
end If

if not ef then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&ds("agent1")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsagent.Open Sql,conn,1,3
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
end if
end if

if not ef then
	Set dsHost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&dsph("VPStype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHost.Open Sql,conn,1,1
if dsHost.Eof then
	ef=True
	ec="产品不存在！"
Else
'读取月付
PAY_DAY=dsHost("PAY_DAY")
PAY_WEEK=dsHost("PAY_WEEK")
PAY_Month=dsHost("PAY_Month")
PAY_Season=dsHost("PAY_Season")
PAY_halfyear=dsHost("PAY_halfyear")
PAY_Nextyear=dsHost("PAY_Nextyear")
if dsph("istest")="y" then PAY_Nextyear="1"
PAY_2year=dsHost("PAY_2year")
PAY_3year=dsHost("PAY_3year")
PAY_4year=dsHost("PAY_4year")
PAY_5year=dsHost("PAY_5year")
end if
end If

if not ef then
if dsHost("cancloud")=false then
Response.Redirect "agn-upvps.asp"
end if
end If

if not ef then
	Set dsserver = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_ServerVPSlist where id='"&dsph ("ServerlistID")&"'"
	dsserver.Open Sql,conn,1,1
if dsserver.Eof then
	ef=True
	ec="服务器不存在！"
Else
dim isAgnHostSer
if dsserver("agent1")=dsph("agent1") then
isAgnHostSer=true
Else
isAgnHostSer=false
end if
end if
end if

if not ef Then

Dim cloudAddmoney
cloudAddmoney=0
if (dsph("CpuNum")>dsHost("CpuNum")) then	cloudAddmoney=cloudAddmoney+((dsph("CpuNum")-dsHost("CpuNum"))/dsHost("addCpuNum"))*dsHost("addCpuCost")
if (dsph("MAXRAM")>dsHost("MAXRAM")) then	cloudAddmoney=cloudAddmoney+((dsph("MAXRAM")-dsHost("MAXRAM"))/dsHost("addRamNum"))*dsHost("addRamCost")
if (dsph("Maxspace")>dsHost("Maxspace")) then	cloudAddmoney=cloudAddmoney+((dsph("Maxspace")-dsHost("Maxspace"))/dsHost("addVHDNum"))*dsHost("addVHDCost")
if (dsph("Maxmbps8")>dsHost("Maxmbps8")) then	cloudAddmoney=cloudAddmoney+((dsph("Maxmbps8")-dsHost("Maxmbps8"))/dsHost("addMbpsNum"))*dsHost("addMbpsCost")
If dsHost("CDNMaxMb")>0 then'如果限制流量
if (dsph("CDNMaxMb")>dsHost("CDNMaxMb")) then	cloudAddmoney=cloudAddmoney+((dsph("CDNMaxMb")-dsHost("CDNMaxMb"))/1000/dsHost("addNGBNum"))*dsHost("addNGBCost")
End If
If dsHost("MaxIOPS")>0 then'如果限制IOPS
if (dsph("MaxIOPS")>dsHost("MaxIOPS")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxIOPS")-dsHost("MaxIOPS"))/dsHost("addIOPSNum"))*dsHost("addIOPSCost")
End if
if (dsph("MaxSNA")>dsHost("MaxSNA")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxSNA")-dsHost("MaxSNA"))/dsHost("addSnaNum"))*dsHost("addSnaCost")
if (dsph("MaxBak")>dsHost("MaxBak")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxBak")-dsHost("MaxBak"))/dsHost("addBakNum"))*dsHost("addBakCost")
if (dsph("MaxIP")>dsHost("MaxIP")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxIP")-dsHost("MaxIP"))/dsHost("addIpNum"))*dsHost("addIPCost")

cloudAddmoney=Clng(FormatNumber(cloudAddmoney,0,-1,0,0))'四舍五入

%>
<!--#include virtual="/inc-freehost-function/template-vpsadm-top.asp"-->
　代理 <%=session("agentusername")%> 管理名下用户 <%=dsph("username")%> 的云服务器


续费/升级<br>
<br>
<table width="98%" border="0" cellpadding="2" cellspacing="1" bgcolor="#C8DAFF" id="t1">
  <tr height="24">
    <td width="17%" align="right" bgcolor="#ECF2FF"> 用户名：</td>
    <td width="83%" align="left" bgcolor="#FAFAFA">　<a href="/agent/searchuser.asp?username=<%=ds("username")%>" target="_blank"><%=ds("username")%></a></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 金额：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("usermoney")%> 元 </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 电子邮件：</td>
    <td align="left" bgcolor="#FAFAFA">　<a href=mailto:<%=ds("email")%>><font color="#000000"><%=ds("email")%></font></a> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> QQ：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("qq")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right">代理名：</td>
    <td align="left" bgcolor="#FAFAFA">　
        <%if ds("agent1")<>"n" then%>
        <a href="searchagent.asp?username=<%=ds("agent1")%>" target="_blank"><font color="blue"><%=ds("agent1")%></font></a>
        <%end if%></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"><div align="right">中文名：</div></td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("truename")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 联系地址：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("address")%> 　邮编：<%=ds("postid")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 电话：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("tel")%> 　传真：<%=ds("fax")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 备注：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("coreinfo")%></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 身份证号码：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("perid")%></td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 注册ip：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("regip")%> </td>
  </tr>
  <tr height="24">
    <td bgcolor="#ECF2FF" align="right"> 注册时间：</td>
    <td align="left" bgcolor="#FAFAFA">　<%=ds("regtime")%> </td>
  </tr>
</table>
<br>
<form action="agn-upvps-time.asp" method="post" name="autoopenY">
<TABLE 
            width="100%" border=1 align=center cellPadding=0 cellSpacing=0 borderColorLight=#cccccc borderColorDark=#fbfbfb>
  <TBODY>
    <TR align="center">
      <TD height="35" colspan="2" vAlign=middle bgColor=#494949>&nbsp; <font color="#FFFFFF">延长使用期限：</font></TD>
      </TR>
    <TR>
      <TD height="28" align="center" vAlign=middle bgColor=#FFFFFF>开通时间：<%=formatdatetime(dsph("starttime"),1)%></TD>
      <TD height="28" align="center" vAlign=middle bgColor=#FFFFFF>到期时间：<%=formatdatetime(dsph("endtime"),1)%></TD>
    </TR>
    <TR>
      <TD height="18" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF>延长：
        <%if dsHost("canday")="y" then%>
        <input type="radio" name="year" value="<%=PAY_DAY%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_DAY*usermoney%>);">
一天
<%end if%>
<%if dsHost("canweek")="y" then%>
<input type="radio" name="year" value="<%=PAY_WEEK%>" onClick="document.autoopen.moneynow.value =Math.round(<%=PAY_WEEK*usermoney%>);">
一周
<%end if%>
<input type="radio" name="year" value="<%=PAY_Month%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_Month%>*document.autoopenY.hidenusermoney.value);">
一个月
<input type="radio" name="year" value="<%=PAY_Season%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_Season%>*document.autoopenY.hidenusermoney.value);">
一季
<input type="radio" name="year" value="<%=PAY_halfyear%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_halfyear%>*document.autoopenY.hidenusermoney.value);">
半年
<input type="radio" name="year" value="<%=PAY_Nextyear%>" checked onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_Nextyear%>*document.autoopenY.hidenusermoney.value);">
一年
<input type="radio" name="year" value="<%=PAY_2year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_2year%>*document.autoopenY.hidenusermoney.value);">
两年
<input type="radio" name="year" value="<%=PAY_3year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_3year%>*document.autoopenY.hidenusermoney.value);">
三年
<input type="radio" name="year" value="<%=PAY_4year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_4year%>*document.autoopenY.hidenusermoney.value);">
四年
<input type="radio" name="year" value="<%=PAY_5year%>" onClick="document.autoopenY.usermoney.value =Math.round(<%=PAY_5year%>*document.autoopenY.hidenusermoney.value);">
五年</TD>
    </TR>
    <TR>
      <TD height="33" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF>        <%

'if dsph("username")=session("agentusername") then '操作自己的云服务器产品
agentname=session("agentusername")
Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"&dsagent("agenttype")&"'" 
		dsagnettype.Open Sql,conn,1,1
	Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent where username='"&agentname&"'"
		dsagent.Open Sql,conn,1,1
if Not dsagent.eof then
if Not dsagnettype.eof Then
canshowagnpric=True
Else
canshowagnpric=false
End if
end If
dsagent.close
'end If	  
'Response.write canshowagnpric

	  if isnull(dsph("repaymoney")) then%><%
agentname=session("agentusername")

usermoney=dsHost("usermoney")+cloudAddmoney'增加弹性部分
if agentname<>"n" then
	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='云服务器产品' and username='"&agentname&"' and id="&dsHost("id")&""
		dsendmoney.Open Sql,conn,1,1
if not dsendmoney.eof then
usermoney=dsendmoney("usermoney")+cloudAddmoney'增加弹性部分
end if
dsendmoney.close
end If%>用户价格：<%=usermoney%>元/年<input type="hidden" name="hidenusermoney" value="<%=usermoney%>"><%

if canshowagnpric then%>　　<font color=red>(代理成本价格
<%
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='云服务器产品' and username='"&agentname&"' and id="&dsHost("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
usermoneyAGN=dsHost("usermoney")*dsagnettype("pers")
If cloudAddmoney>0 Then usermoneyAGN=(dsHost("usermoney")+cloudAddmoney)*dsagnettype("pers") '2014-1-18增加的弹性购买附加代理成本折扣
else
usermoneyAGN=dsagnpri("usermoney")
'If cloudAddmoney>0 Then usermoneyAGN=(usermoneyAGN/dsHost("usermoney"))*(usermoneyAGN+cloudAddmoney) '2014-1-18增加的弹性购买附加代理直价
If cloudAddmoney>0 Then usermoneyAGN=usermoneyAGN+(cloudAddmoney*(usermoneyAGN/dsHost("usermoney"))) '2014-1-18增加的弹性购买附加代理直价
end if
dsagnpri.close
%>)</font><%End if%>
<%
If canshowagnpric And isAgnHostSer then%>
(<font color=red>当前此产品为独立模式产品</font>)
<%
usermoneyAGN=0
End if%>
<%=usermoneyAGN%><%else%>(单独设置的价格)　<%=dsph("repaymoney")%><%end if%> 元/年</TD>
    </TR>
<%if dsph("username")<>session("agentusername") Then'是否处理自己的云服务器产品%>
    <TR>
      <TD height="38" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="chmoney" type="checkbox" id="chmoney" value="y">
        <font color="#000000">从用户金额中自动扣除</font>(不选将以成本价扣除代理自己的钱) 价格：
        <input name="usermoney" type="text" id="usermoney" size="5" maxlength="5"  value="<%=usermoney%>">
元
</TD>
    </TR>
<%else%>
<input name="usermoney" type="hidden" id="usermoney" size="5" maxlength="5"  value="<%=usermoney%>">
<%End if%>
    <TR>
      <TD height="38" colspan="2" align="center" vAlign=middle bgColor=#FFFFFF><input name="id" type="hidden" value="<%=session("VPSAUID")%>">
        <input type="submit" name="Submit" value="马上续期"></TD>
    </TR>
  </TBODY>
</TABLE>
</form>

<%

if not ef then
	Set dsHost = Server.CreateObject("ADODB.Recordset")	
	Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&dsph("VPStype")&"'"
	if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
	dsHost.Open Sql,conn,1,1
if dsHost.Eof then
	ef=True
	ec="产品不存在！"
end if
end If

if not ef then
if dshost("cancloud")=false then
	ef=True
	ec="弹性购买的产品才能使用本功能"
end if
end If

if not ef then
if not isnull(dsph("repaymoney")) then
	ef=True
	ec="由于此产品被管理员设置了单独的续费价格，因此，请您联系管理员帮您手工升级。"
end if
end if

if not ef then
if dsph("istest")="y" then
	ef=True
	ec="试用状态的产品必须延期后成为正式产品才可以升级到高级别！"
end if
end If

if not ef then
agentname=session("agentname")
if session("agentusername")<>"" Or session("AgnRunasUser")=True then 
if session("agentusername")<>"" Then agentname=session("agentusername")
	Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent where username='"&agentname&"'"
		dsagent.Open Sql,conn,1,1
if Not dsagent.eof then
Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"&dsagent("agenttype")&"'" 
		dsagnettype.Open Sql,conn,1,1
if Not dsagnettype.eof Then
canshowagnpric=True
Else
canshowagnpric=false
End if
end If
dsagent.close
end If
end If

if not ef then
if ds("agent1")<>"n" then

if not ef then
  Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_AGENT where username='"&ds("agent1")&"'"
		if Instr(1,sql, ";", 1)>0 or Instr(1,sql, "--", 1)>0 then
Response.Write "非法字符！"
Response.End
end if
		dsagent.Open Sql,conn,1,3
If dsagent.Eof Then
		ef=True
		ec="代理会员名不存在或密码出错了！"
end if
end if

if not ef then
	Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"& session("agenttype")&"'"
		dsagnettype.Open Sql,conn,1,1
if dsagnettype.Eof then
	ef=True
	ec="代理类型折扣为空，请先设置它！"
end if
end if

if not ef then
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='云服务器产品' and username='"&session ("agentname")&"' and id="&dshost("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
myrealcost=dshost("usermoney")*dsagnettype("pers")
else
myrealcost=dsagnpri("usermoney")
end if
dsagnpri.close

	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='云服务器产品' and username='"&session("agentname")&"' and id="&dshost("id")&""
		dsendmoney.Open Sql,conn,1,1
if dsendmoney.eof then
usermoney=dshost("usermoney")
else
usermoney=dsendmoney("usermoney")
end if
dsendmoney.close
end if
end if
end if

if not ef then
if dshost("cancloud")=true then'是弹性购买产品'计算增量部分的普通用户情况下的金额'原来的增量金额

	'PAY_1yearvar=dsHost("usermoney")
	
'默认最小值addcpuMIN
'当前值addcpuNow
'增量每步addcpuNum
'每步需要钱数addCpuCost
'Dim cloudAddmoney
cloudAddmoney=0
if (dsph("CpuNum")>dsHost("CpuNum")) then	cloudAddmoney=cloudAddmoney+((dsph("CpuNum")-dsHost("CpuNum"))/dsHost("addCpuNum"))*dsHost("addCpuCost")
if (dsph("MAXRAM")>dsHost("MAXRAM")) then	cloudAddmoney=cloudAddmoney+((dsph("MAXRAM")-dsHost("MAXRAM"))/dsHost("addRamNum"))*dsHost("addRamCost")
if (dsph("Maxspace")>dsHost("Maxspace")) then	cloudAddmoney=cloudAddmoney+((dsph("Maxspace")-dsHost("Maxspace"))/dsHost("addVHDNum"))*dsHost("addVHDCost")
if (dsph("Maxmbps8")>dsHost("Maxmbps8")) then	cloudAddmoney=cloudAddmoney+((dsph("Maxmbps8")-dsHost("Maxmbps8"))/dsHost("addMbpsNum"))*dsHost("addMbpsCost")
If dsHost("CDNMaxMb")>0 then'如果限制流量
if (dsph("CDNMaxMb")>dsHost("CDNMaxMb")) then	cloudAddmoney=cloudAddmoney+((dsph("CDNMaxMb")-dsHost("CDNMaxMb"))/1000/dsHost("addNGBNum"))*dsHost("addNGBCost")
End If
If dsHost("MaxIOPS")>0 then'如果限制IOPS
if (dsph("MaxIOPS")>dsHost("MaxIOPS")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxIOPS")-dsHost("MaxIOPS"))/dsHost("addIOPSNum"))*dsHost("addIOPSCost")
End if
if (dsph("MaxSNA")>dsHost("MaxSNA")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxSNA")-dsHost("MaxSNA"))/dsHost("addSnaNum"))*dsHost("addSnaCost")
if (dsph("MaxBak")>dsHost("MaxBak")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxBak")-dsHost("MaxBak"))/dsHost("addBakNum"))*dsHost("addBakCost")
if (dsph("MaxIP")>dsHost("MaxIP")) then	cloudAddmoney=cloudAddmoney+((dsph("MaxIP")-dsHost("MaxIP"))/dsHost("addIpNum"))*dsHost("addIPCost")

cloudAddmoney=Clng(FormatNumber(cloudAddmoney,0,-1,0,0))'四舍五入'原来的增量金额

end If
end If

if not ef Then
daytoend=DateDiff("d",NOW,dsph("endtime"))
if daytoend<0 Then
	ef=True
	ec="您原来的产品已过期了，请您先延期原产品后才能升级。"
End If
End If

if not ef Then

oldusermoney=cloudAddmoney+usermoney
if dsph("istest")="y" then  daytoend=0'试用期的产品也要设置为0
oldusermoneyleft=oldusermoney/365*daytoend'原来用户换算留下的钱

end If
%>


<br>
<%
defaultpdID=0
defaultServerlistID=0

agentname=session("agentname")
if session("agentusername")<>"" Or session("AgnRunasUser")=True then 
if session("agentusername")<>"" Then agentname=session("agentusername")
	Set dsagent = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent where username='"&agentname&"'"
		dsagent.Open Sql,conn,1,1
if Not dsagent.eof then
Set dsagnettype = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_Agent_pers where agenttype='"&dsagent("agenttype")&"'" 
		dsagnettype.Open Sql,conn,1,1
if Not dsagnettype.eof Then
canshowagnpric=True
Else
canshowagnpric=false
End if
end If
dsagent.close
end If



	Set VPSpdlist = Server.CreateObject("ADODB.Recordset")	
'		Sql="Select * from FreeHost.FreeHost_VPSProductlist where cancloud=1 and canbyenduser='y' and (onlyusebyagn is null or onlyusebyagn='"&agentname&"') order by orderbyid desc"
		Sql="Select * from FreeHost.FreeHost_VPSProductlist where VPStype='"&dsph("VPStype")&"'"

		VPSpdlist.Open Sql,conn,1,1
If VPSpdlist.Eof Then%>
产品列表为空.
<%else%>

<table width="100%" height="10"  border="0" cellpadding="0" cellspacing="1" bordercolor="#999999">
  <tr>
    <td>
	<%
While not VPSpdlist.eof

If defaultpdID=0 Then defaultpdID=VPSpdlist("id")

PAY_Day=VPSpdlist("PAY_Day")
PAY_WeeK=VPSpdlist("PAY_WeeK")

PAY_Month=VPSpdlist("PAY_Month")
PAY_Season=VPSpdlist("PAY_Season")
PAY_halfyear=VPSpdlist("PAY_halfyear")
PAY_Nextyear=VPSpdlist("PAY_Nextyear")
PAY_2year=VPSpdlist("PAY_2year")
PAY_3year=VPSpdlist("PAY_3year")
PAY_4year=VPSpdlist("PAY_4year")
PAY_5year=VPSpdlist("PAY_5year")

%>

<table width="20%" height="30"  border="0" align="left" cellspacing="1" bgcolor="#CCCCCC">
      <tr>
        <td bgcolor="#FFFFFF" >　
          <%
	info=VPSpdlist("info")
	VPStype=VPSpdlist("VPStype")
isAgnHostSer=false
	Set newname_host = Server.CreateObject("ADODB.Recordset")	
Sql="Select * from FreeHost.FreeHost_VPSProductlist_AGN where agent1='"&agentname&"' and id='"&VPSpdlist("id")&"'"
		newname_host.Open Sql,conn,1,1
if not newname_host.eof then
info=newname_host("info")
VPStype=newname_host("VPStype")
if newname_host ("ServerlistID")<>0 Then isAgnHostSer=True '这是独立模板的产品
newname_host.close
end If

'可选的服务器

	Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_ServerVPSlist where agent1='n' and (id="&VPSpdlist("ServerlistID")&" or id="&VPSpdlist("ServerlistID2")&" or id="&VPSpdlist("ServerlistID3")&" or id="&VPSpdlist("ServerlistID4")&" or id="&VPSpdlist("ServerlistID5")&") order by orderbyid desc"
		dsX.Open Sql,conn,1,1
If dsX.eof then%>
<SCRIPT language=JavaScript type=text/javascript>
var ServerlistIDvar<%=VPSpdlist("id")%>="无可用的节点服务器，请联系管理员先定义！";
</script>
<%else%>
<SCRIPT language=JavaScript type=text/javascript>
var ServerlistIDvar<%=VPSpdlist("id")%>="<select name=ServerlistID id=ServerlistID><%while not dsX.Eof%><option value=<%=dsX("id")%>><%=dsX("netby")%></option><%
dsX.movenext
wend%></select>";
</script>
<%End if%>

<%
Set dsX = Server.CreateObject("ADODB.Recordset")	
		Sql="Select top 1 * from FreeHost.FreeHost_ServerVPSlist where agent1='n' and (id="&VPSpdlist("ServerlistID")&" or id="&VPSpdlist("ServerlistID2")&" or id="&VPSpdlist("ServerlistID3")&" or id="&VPSpdlist("ServerlistID4")&" or id="&VPSpdlist("ServerlistID5")&") order by orderbyid desc"
		dsX.Open Sql,conn,1,1
If dsX.eof then%>
<SCRIPT language=JavaScript type=text/javascript>
var OSAllListvar<%=VPSpdlist("id")%>="<input type=radio name=OSAllList id=OSAllList checked>无可选操作系统";
</script>
<%else%>
<SCRIPT language=JavaScript type=text/javascript>
var OSAllListvar<%=VPSpdlist("id")%>="<select name=OSAllList id=OSAllList><%
y=0
for i=1 to 25
if not isnull(dsX("osfile"&i)) then
y=y+1%><option value=<%=i%> <%if dsph("FirstOSid")=i then%> selected<%end if%>><%=dsX("osname"&i)%></option><%end if
next
'if y=0 then
%></select>";
</script>
<%End if%>

<SCRIPT language=JavaScript type=text/javascript>
<%OSlim=","&VPSpdlist("OSlim")&","
if VPSpdlist("OSlim")="" or isnull(VPSpdlist("OSlim")) then OSlim="NotLim"
%>
var OSlimvar<%=VPSpdlist("id")%>="<%=OSlim%>";
var OSLimbyRam<%=VPSpdlist("id")%>="<%=VPSpdlist("OSLimbyRam")%>";
var OSLimbyCPU<%=VPSpdlist("id")%>="<%=VPSpdlist("OSLimbyCPU")%>";
var defaultMoneyYearvarSTD<%=VPSpdlist("id")%>=<%=VPSpdlist("usermoney")%>;
var defaultMoneyYearvar<%=VPSpdlist("id")%>=<%'普通用户出售价
usermoney=VPSpdlist("usermoney")
if agentname<>"n" then
	Set dsendmoney = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_user_price where prtype='云服务器产品' and username='"&agentname&"' and id="&VPSpdlist("id")&""
		dsendmoney.Open Sql,conn,1,1
if not dsendmoney.eof then
usermoney=dsendmoney("usermoney")
end if
dsendmoney.close
end If%><%=usermoney%>;
var defaultMoneyYearAgnvar<%=VPSpdlist("id")%>=<%'代理成本价
if canshowagnpric then%><%
	Set dsagnpri = Server.CreateObject("ADODB.Recordset")	
		Sql="Select * from FreeHost.FreeHost_Agent_price where prtype='云服务器产品' and username='"&agentname&"' and id="&VPSpdlist("id")&""
		dsagnpri.Open Sql,conn,1,1
if dsagnpri.eof then
usermoney=VPSpdlist("usermoney")*dsagnettype("pers")
else
usermoney=dsagnpri("usermoney")
end if
dsagnpri.close
%><%=usermoney%><%else%>null<%End if%>;
<%if VPSpdlist("cantest")="y" then%>
var Cantestvar<%=VPSpdlist("id")%>=true;
var CantestDayvar<%=VPSpdlist("id")%>=<%=Application("testtime")%>;//试用天数
<%else%>
var Cantestvar<%=VPSpdlist("id")%>=false;
var CantestDayvar<%=VPSpdlist("id")%>=null;
<%end if%>

<%if VPSpdlist("canday")="y" then%>
var PAY_DAYvar<%=VPSpdlist("id")%>=<%=PAY_DAY%>;
<%else%>
var PAY_DAYvar<%=VPSpdlist("id")%>=null;
<%end if%>
<%if VPSpdlist("canweek")="y" then%>
var PAY_WEEKvar<%=VPSpdlist("id")%>=<%=PAY_WEEK%>;
<%else%>
var PAY_WEEKvar<%=VPSpdlist("id")%>=null;
<%end if%>

<%if VPSpdlist("canmonth")="y" then%>
var PAY_Monthvar<%=VPSpdlist("id")%>=<%=PAY_Month%>;
<%else%>
var PAY_Monthvar<%=VPSpdlist("id")%>=null;
<%end if%>
<%if VPSpdlist("canseason")="y" then%>
var PAY_Seasonvar<%=VPSpdlist("id")%>=<%=PAY_Season%>;
<%else%>
var PAY_Seasonvar<%=VPSpdlist("id")%>=null;
<%end if%>
<%if VPSpdlist("canhalfyear")="y" then%>
var PAY_halfyearvar<%=VPSpdlist("id")%>=<%=PAY_halfyear%>;
<%else%>
var PAY_halfyearvar<%=VPSpdlist("id")%>=null;
<%end if%>

var PAY_2yearvar<%=VPSpdlist("id")%>=<%=PAY_2year%>;
var PAY_3yearvar<%=VPSpdlist("id")%>=<%=PAY_3year%>;
var PAY_4yearvar<%=VPSpdlist("id")%>=<%=PAY_4year%>;
var PAY_5yearvar<%=VPSpdlist("id")%>=<%=PAY_5year%>;

var addCpuNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addCpuNum")%>;
var addCpuCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addCpuCost")%>;
var addCpuLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addCpuLim")%>;

var addRamNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addRamNum")%>;
var addRamCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addRamCost")%>;
var addRamLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addRamLim")%>;

var addVHDNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addVHDNum")%>;
var addVHDCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addVHDCost")%>;
var addVHDLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addVHDLim")%>;

var addMbpsNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addMbpsNum")%>;
var addMbpsCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addMbpsCost")%>;
var addMbpsLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addMbpsLim")%>;

var addNGBNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addNGBNum")%>;
var addNGBCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addNGBCost")%>;
var addNGBLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addNGBLim")%>;

var addIPNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addIPNum")%>;
var addIPCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addIPCost")%>;
var addIPLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addIPLim")%>;

var addSNANum<%=VPSpdlist("id")%>=<%=VPSpdlist("addSNANum")%>;
var addSNACost<%=VPSpdlist("id")%>=<%=VPSpdlist("addSNACost")%>;
var addSNALim<%=VPSpdlist("id")%>=<%=VPSpdlist("addSNALim")%>;

var addBakNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addBakNum")%>;
var addBakCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addBakCost")%>;
var addBakLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addBakLim")%>;

var addIopsNum<%=VPSpdlist("id")%>=<%=VPSpdlist("addIopsNum")%>;
var addIopsCost<%=VPSpdlist("id")%>=<%=VPSpdlist("addIopsCost")%>;
var addIopsLim<%=VPSpdlist("id")%>=<%=VPSpdlist("addIopsLim")%>;

var addcpuMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("CpuNum")%>;
var addRamMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("MAXRAM")%>;
var addVHDMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("Maxspace")%>;
var addMbpsMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("Maxmbps8")%>;
var addSNAMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("MaxSNA")%>;
var addBakMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("MaxBak")%>;
var addNGBMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("CDNMaxMb")%>*1000;
var addIPMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("MaxIP")%>;
var addIopsMIN<%=VPSpdlist("id")%>=<%=VPSpdlist("MaxIops")%>;

var vpspdid<%=VPSpdlist("id")%>=<%=VPSpdlist("id")%>;

</script>

            <font size="2"><strong><a href="#" onClick="Minini(addcpuMIN<%=VPSpdlist("id")%>,addRamMIN<%=VPSpdlist("id")%>,
addVHDMIN<%=VPSpdlist("id")%>,addMbpsMIN<%=VPSpdlist("id")%>,addSNAMIN<%=VPSpdlist("id")%>,addBakMIN<%=VPSpdlist("id")%>,
addNGBMIN<%=VPSpdlist("id")%>,addIPMIN<%=VPSpdlist("id")%>,addIopsMIN<%=VPSpdlist("id")%>,<%=VPSpdlist("id")%>,OSlimvar<%=VPSpdlist("id")%>,OSLimbyRam<%=VPSpdlist("id")%>,OSLimbyCPU<%=VPSpdlist("id")%>);
Limini(addCpuNum<%=VPSpdlist("id")%>,
addCpuCost<%=VPSpdlist("id")%>,
addCpuLim<%=VPSpdlist("id")%>,
addRamNum<%=VPSpdlist("id")%>,
addRamCost<%=VPSpdlist("id")%>,
addRamLim<%=VPSpdlist("id")%>,
addVHDNum<%=VPSpdlist("id")%>,
addVHDCost<%=VPSpdlist("id")%>,
addVHDLim<%=VPSpdlist("id")%>,
addMbpsNum<%=VPSpdlist("id")%>,
addMbpsCost<%=VPSpdlist("id")%>,
addMbpsLim<%=VPSpdlist("id")%>,
addNGBNum<%=VPSpdlist("id")%>,
addNGBCost<%=VPSpdlist("id")%>,
addNGBLim<%=VPSpdlist("id")%>,
addIPNum<%=VPSpdlist("id")%>,
addIPCost<%=VPSpdlist("id")%>,
addIPLim<%=VPSpdlist("id")%>,
addSNANum<%=VPSpdlist("id")%>,
addSNACost<%=VPSpdlist("id")%>,
addSNALim<%=VPSpdlist("id")%>,
addBakNum<%=VPSpdlist("id")%>,
addBakCost<%=VPSpdlist("id")%>,
addBakLim<%=VPSpdlist("id")%>,
addIopsNum<%=VPSpdlist("id")%>,
addIopsCost<%=VPSpdlist("id")%>,
addIopsLim<%=VPSpdlist("id")%>);
addcpuNow=<%=dsph("CpuNum")%>;addRamNow=<%=dsph("MAXRAM")%>;addVHDNow=<%=dsph("Maxspace")%>;addMbpsNow=<%=dsph("Maxmbps8")%>;addNGBNow=<%=dsph("CDNMaxMb")%>*1000;addIopsNow=<%=dsph("MaxIops")%>;addSNANow=<%=dsph("MaxSNA")%>;addBakNow=<%=dsph("MaxBak")%>;addIPNow=<%=dsph("MaxIP")%>;Cloudini(ServerlistIDvar<%=VPSpdlist("id")%>,OSAllListvar<%=VPSpdlist("id")%>,OSlimvar<%=VPSpdlist("id")%>,<%=VPSpdlist("OSLimbyRam")%>,<%=VPSpdlist("OSLimbyCPU")%>);Moneyini(defaultMoneyYearvarSTD<%=VPSpdlist("id")%>,defaultMoneyYearvar<%=VPSpdlist("id")%>,defaultMoneyYearAgnvar<%=VPSpdlist("id")%>,Cantestvar<%=VPSpdlist("id")%>,CantestDayvar<%=VPSpdlist("id")%>,PAY_DAYvar<%=VPSpdlist("id")%>,PAY_WEEKvar<%=VPSpdlist("id")%>,PAY_Monthvar<%=VPSpdlist("id")%>,PAY_Seasonvar<%=VPSpdlist("id")%>,PAY_halfyearvar<%=VPSpdlist("id")%>,PAY_2yearvar<%=VPSpdlist("id")%>,PAY_3yearvar<%=VPSpdlist("id")%>,PAY_4yearvar<%=VPSpdlist("id")%>,PAY_5yearvar<%=VPSpdlist("id")%>);"><%=VPStype%></a></strong></font>        </td>
      </tr>
    </table>
<%
VPSpdlist.movenext
wend%>
</td>
  </tr>
</table>
<form name="autoopen" method="post" action="agn-upvps-cloud-type.asp">
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="5%" height="40" align="right" valign="middle"><b>CPU</b></td>
    <td width="88%"><table width="100%"  border="0" cellspacing="0">
      <tr>
        <td width="5%" align="right" onClick="delcpu();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addcpuALLpx>
          <tr>
            <td width="33%" height="24" align="right" class="CloudTDbyCPU" id=addcpuleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyCPU"> </td>
              <td width="" align="left"></td>
          </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addcpu();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td width="3%" align="center">
      <input name="CpuValue" type="text" size="4" maxlength="6"  readonly="true">
    </td>
    <td width="4%" align="center">核心</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>内存</b></td>
    <td><table width="100%"  border="0" cellspacing="0">
      <tr>
        <td width="5%" align="right" onClick="delRam();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addRamALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyRam" id=addRamleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyRam"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addRam();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="RamValue" type="text" size="4" maxlength="6" readonly="true"></td>
    <td align="center">MB</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>硬盘</b></td>
    <td><table width="100%"  border="0" cellspacing="0">
      <tr>
        <td width="5%" align="right" onClick="delVHD();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addVHDALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyVHD" id=addVHDleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyVHD"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addVHD();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="VHDValue" type="text" id="VHDValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">GB</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>带宽</b></td>
    <td><table width="100%"  border="0" cellspacing="0" id="CloudTablebyMbps">
      <tr>
        <td width="5%" align="right" onClick="delMbps();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addMbpsALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyMbps" id=addMbpsleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyMbps"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addMbps();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="MbpsValue" type="text" id="MbpsValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">Mbps</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>快照</b></td>
    <td><table width="100%"  border="0" cellspacing="0" id="CloudTablebySNA">
      <tr>
        <td width="5%" align="right" onClick="delSNA();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addSNAALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbySNA" id=addSNAleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbySNA"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addSNA();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="SNAValue" type="text" id="SNAValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">个</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>备份</b></td>
    <td><table width="100%"  border="0" cellspacing="0" id="CloudTablebyBak">
      <tr>
        <td width="5%" align="right" onClick="delBak();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addBakALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyBak" id=addBakleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyBak"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addBak();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="BakValue" type="text" id="BakValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">个</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>流量</b></td>
    <td><table width="100%"  border="0" cellspacing="0" id="CloudTablebyNGB">
      <tr>
        <td width="5%" align="right" onClick="delNGB();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addNGBALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyNGB" id=addNGBleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyNGB"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addNGB();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="NGBValue" type="text" id="NGBValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">GB</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>IP</b></td>
    <td><table width="100%"  border="0" cellspacing="0" id="CloudTablebyIP">
      <tr>
        <td width="5%" align="right" onClick="delIP();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addIPALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyIP" id=addIPleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyIP"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addIP();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="IPValue" type="text" id="IPValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">个</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>Iops</b></td>
    <td><table width="100%"  border="0" cellspacing="0" id="CloudTablebyIops">
      <tr>
        <td width="5%" align="right" onClick="delIops();" onMouseOver="this.style.cursor='hand';"><font size="6">-</font></td>
        <td width="92%"><table width="100%"  border="0" cellspacing="0" bordercolor="0" background="/style/info/img/cloudtablebg1.gif" id=addIopsALLpx>
            <tr>
              <td width="33%" height="24" align="right" class="CloudTDbyIops" id=addIopsleft onMouseOver="this.style.cursor='default';"><img src="/style/info/img/cloudtablebg2.gif" width="21" height="24" border="0" onMouseOver="this.style.cursor='hand';" onMouseDown="return false;" id="CloudTDbyIops"> </td>
              <td width="" align="left"></td>
            </tr>
        </table></td>
        <td width="3%" align="left" bgcolor="#F5F5F5" onClick="addIops();" onMouseOver="this.style.cursor='hand';"><font size="5">+</font></td>
      </tr>
    </table></td>
    <td align="center"><input name="IopsValue" type="text" id="IopsValue" size="4" maxlength="6" readonly="true"></td>
    <td align="center">次/秒</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>系统</b></td>
    <td><table width="100%"  border="0" cellspacing="0">
      <tr>
        <td width="5%" align="right" >&nbsp;</td>
        <td width="92%"><div id=showOSAllList>
     
        </div></td>
        <td width="3%" align="left" >&nbsp;</td>
      </tr>
    </table>
	
	  </td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>价格</b></td>
    <td><table width="100%"  border="0" cellspacing="0">
        <tr>
          <td width="5%" align="right" >&nbsp;</td>
          <td width="92%"><div id=showMoney> </div></td>
          <td width="3%" align="left" >&nbsp;</td>
        </tr>
    </table></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle"><b>名称</b></td>
    <td><table width="100%"  border="0" cellspacing="0">
        <tr>
          <td width="5%" align="right" >&nbsp;</td>
          <td><%=dsph("vpsname")%></td>
          <td width="83%" align="left" ></td>
        </tr>
    </table></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle">&nbsp;</td>
    <td align="center"><input name="chmoney" type="checkbox" id="chmoney" value="y">
      <font color="#000000">手工强行指定从用户金额中扣除</font>：
      <input name="usermoney" type="text" id="usermoney" size="4" maxlength="4"  value="0">
元 (不选将时按正常扣除用户费用)</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td height="40" align="right" valign="middle">&nbsp;</td>
    <td align="center"><input type="hidden" name="vpspdid" value="<%=dsHost("id")%>"><input type="hidden" name="id" value="<%=dsph("id")%>">
    <input name="Submit" type="button" value="重置" onClick="Setnowpd();NowValuesetini();">
      　　
      <input name="openX" type="submit" value="马上实时升级" onClick="document.autoopen.openX.value ='请等待不要重复刷新！....';document.autoopen.openX.disabled=true;document.autoopen.submit();"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
<SCRIPT language=JavaScript type=text/javascript>
var addCpuCost=null;
var addRamCost=null;
var addVHDCost=null;
var addMbpsCost=null;
var addNGBCost=null;
var addIPCost=null;
var addSNACost=null;
var addBakCost=null;
var addIopsCost=null;

var addcpuMIN=null;
var addRamMIN=null;
var addVHDMIN=null;
var addMbpsMIN=null;
var addSNAMIN=null;
var addBakMIN=null;
var addNGBMIN=null;
var addIPMIN=null;
var addIopsMIN=null;

var OSlimvardefault=null;
var OSLimbyRamdefault=null;
var OSLimbyCPUdefault=null;
var OSAllListvardefault=null;

//document.autoopen.id.value=vpspdid<%=defaultpdID%>不是产品类型，是产品名
Minini(addcpuMIN=addcpuMIN<%=defaultpdID%>,
addRamMIN=addRamMIN<%=defaultpdID%>,
addVHDMIN=addVHDMIN<%=defaultpdID%>,
addMbpsMIN=addMbpsMIN<%=defaultpdID%>,
addSNAMIN=addSNAMIN<%=defaultpdID%>,
addBakMIN=addBakMIN<%=defaultpdID%>,
addNGBMIN=addNGBMIN<%=defaultpdID%>,
addIPMIN=addIPMIN<%=defaultpdID%>,
addIopsMIN=addIopsMIN<%=defaultpdID%>,
//document.autoopen.id.value=vpspdid<%=defaultpdID%>,
OSlimvardefault=OSlimvar<%=defaultpdID%>,
OSLimbyRamdefault=OSLimbyRam<%=defaultpdID%>,
OSLimbyCPUdefault=OSLimbyCPU<%=defaultpdID%>);//初始化

function Minini(addcpuMINin,addRamMINin,addVHDMINin,addMbpsMINin,addSNAMin,addBakMINin,addNGBMIN,addIPMIN,addIopsMIN,CurPDID,OSlimvarin,OSLimbyRamin,OSLimbyCPUin)
{
addcpuMIN=addcpuMINin;
addRamMIN=addRamMINin;
addVHDMIN=addVHDMINin;
addMbpsMIN=addMbpsMINin;
addSNAMIN=addSNAMin;
addBakMIN=addBakMINin;
addNGBMIN=addNGBMIN;
addIPMIN=addIPMIN;
addIopsMIN=addIopsMIN;
//document.autoopen.id.value=CurPDID;
OSlimvardefault=OSlimvarin;
OSLimbyRamdefault=OSLimbyRamin;
OSLimbyCPUdefault=OSLimbyCPUin;
}

function Limini(addCpuNumIN,
addCpuCostIN,
addCpuLimIN,
addRamNumIN,
addRamCostIN,
addRamLimIN,
addVHDNumIN,
addVHDCostIN,
addVHDLimIN,
addMbpsNumIN,
addMbpsCostIN,
addMbpsLimIN,
addNGBNumIN,
addNGBCostIN,
addNGBLimIN,
addIPNumIN,
addIPCostIN,
addIPLimIN,
addSNANumIN,
addSNACostIN,
addSNALimIN,
addBakNumIN,
addBakCostIN,
addBakLimIN,
addIopsNumIN,
addIopsCostIN,
addIopsLimIN)
{
addcpuNum=addCpuNumIN;
addcpuLim=addCpuLimIN;
addRamNum=addRamNumIN;
addRamLim=addRamLimIN;
addVHDNum=addVHDNumIN;
addVHDLim=addVHDLimIN;
addMbpsNum=addMbpsNumIN;
addMbpsLim=addMbpsLimIN;
addNGBNum=addNGBNumIN;
addNGBLim=addNGBLimIN;
addIPNum=addIPNumIN;
addIPLim=addIPLimIN;
addSNANum=addSNANumIN;
addSNALim=addSNALimIN;
addBakNum=addBakNumIN;
addBakLim=addBakLimIN;
addIopsNum=addIopsNumIN;
addIopsLim=addIopsLimIN;

addCpuCost=addCpuCostIN;
addRamCost=addRamCostIN;
addVHDCost=addVHDCostIN;
addMbpsCost=addMbpsCostIN;
addNGBCost=addNGBCostIN;
addIPCost=addIPCostIN;
addSNACost=addSNACostIN;
addBakCost=addBakCostIN;
addIopsCost=addIopsCostIN;
}

var defaultMoneyYearvar=null;
var defaultMoneyYearvarSTD=null;
var defaultMoneyYearAgnvar=null;
var Cantestvar=null;
var CantestDayvar=null;

var PAY_DAYvar=null;
var PAY_WEEKvar=null;

var PAY_Monthvar=null;
var PAY_Seasonvar=null;
var PAY_halfyearvar=null;
var PAY_2yearvar=null;
var PAY_3yearvar=null;
var PAY_4yearvar=null;
var PAY_5yearvar=null;

//计算钱
var PAY_1yearvar=null;
function GetMoney()
{

//升级专用，限制不能小于原来的值
if (addcpuNow<<%=dsph("CpuNum")%>)
	addcpuNow=<%=dsph("CpuNum")%>;
if (addRamNow<<%=dsph("MAXRAM")%>)
	addRamNow=<%=dsph("MAXRAM")%>;
if (addVHDNow<<%=dsph("Maxspace")%>)
	addVHDNow=<%=dsph("Maxspace")%>;
if (addMbpsNow<<%=dsph("Maxmbps8")%>)
	addMbpsNow=<%=dsph("Maxmbps8")%>;
if (addNGBNow<<%=dsph("CDNMaxMb")*1000%>)
	addNGBNow=<%=dsph("CDNMaxMb")*1000%>;
if (addIPNow<<%=dsph("MaxIP")%>)
	addIPNow=<%=dsph("MaxIP")%>;
if (addSNANow<<%=dsph("MaxSNA")%>)
	addSNANow=<%=dsph("MaxSNA")%>;
if (addBakNow<<%=dsph("MaxBak")%>)
	addBakNow=<%=dsph("MaxBak")%>;
if (addIopsNow<<%=dsph("MaxIops")%>)
	addIopsNow=<%=dsph("MaxIops")%>;
NowValuesetini();

	var cloudAddmoney=0;
//默认最小值addcpuMIN
//当前值addcpuNow
//增量每步addcpuNum
//每步需要钱数addCpuCost
if (addcpuNow>addcpuMIN)
	cloudAddmoney+=((addcpuNow-addcpuMIN)/addcpuNum)*addCpuCost
if (addRamNow>addRamMIN)
	cloudAddmoney+=((addRamNow-addRamMIN)/addRamNum)*addRamCost
if (addVHDNow>addVHDMIN)
	cloudAddmoney+=((addVHDNow-addVHDMIN)/addVHDNum)*addVHDCost
if (addMbpsNow>addMbpsMIN)
	cloudAddmoney+=((addMbpsNow-addMbpsMIN)/addMbpsNum)*addMbpsCost
if (addNGBNow>addNGBMIN)
	cloudAddmoney+=((addNGBNow-addNGBMIN)/addNGBNum)*addNGBCost
if (addIPNow>addIPMIN)
	cloudAddmoney+=((addIPNow-addIPMIN)/addIPNum)*addIPCost
if (addSNANow>addSNAMIN)
	cloudAddmoney+=((addSNANow-addSNAMIN)/addSNANum)*addSNACost
if (addBakNow>addBakMIN)
	cloudAddmoney+=((addBakNow-addBakMIN)/addBakNum)*addBakCost
if (addIopsNow>addIopsMIN)
	cloudAddmoney+=((addIopsNow-addIopsMIN)/addIopsNum)*addIopsCost

	PAY_1yearvar=defaultMoneyYearvar+cloudAddmoney;
//alert(addcpuNow-addcpuMIN);
//alert(defaultMoneyYearAgnvar);
//alert(cloudAddmoney);
//alert(<%=cloudAddmoney%>);
	<%if canshowagnpric then%>
//代理的升级成本价=(新增量代理成本价 - 旧增量代理成本售价)/365 x未到期天数) 
//增量代理成本价=(增量基准价　X　比例[比例的算法是代理年付成本除以普通用户年付标准价] ) 
	var oldusermoneyleftAgn=<%=cloudAddmoney%>*(defaultMoneyYearAgnvar/defaultMoneyYearvarSTD)//要算上增量cloudAddmoney
	defaultMoneyYearAgnvarEnd=cloudAddmoney*(defaultMoneyYearAgnvar/defaultMoneyYearvarSTD);//按比例算代理成本//一样的算法
	// (cloudAddmoney-<%=cloudAddmoney%>)*(defaultMoneyYearAgnvar/defaultMoneyYearvarSTD) /365 *<%=daytoend%>
//alert(oldusermoneyleftAgn);
//alert(defaultMoneyYearAgnvarEnd);
	<%end if%>


	var showMoneyvar="";
if (Cantestvar)
//	showMoneyvar+="<input type=radio name=year value=999>试用"+CantestDayvar+"天<font color=red>0</font>元　";
if (PAY_DAYvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_DAYvar+">日付<font color=red>"+Math.round(PAY_1yearvar*PAY_DAYvar)+"</font>元<%if canshowagnpric then%>(代理成本价：<font color=blue>"+Math.round(defaultMoneyYearAgnvarEnd*PAY_DAYvar)+"</font>元)<%end if%>　";
	}

if (PAY_WEEKvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_WEEKvar+">周付<font color=red>"+Math.round(PAY_1yearvar*PAY_WEEKvar)+"</font>元<%if canshowagnpric then%>(代理成本价：<font color=blue>"+Math.round(defaultMoneyYearAgnvarEnd*PAY_WEEKvar)+"</font>元)<%end if%>　";
	}

if (PAY_Monthvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_Monthvar+">月付<font color=red>"+Math.round(PAY_1yearvar*PAY_Monthvar)+"</font>元　";
	}
if (PAY_Seasonvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_Seasonvar+">季付<font color=red>"+Math.round(PAY_1yearvar*PAY_Seasonvar)+"</font>元　";
	}
if (PAY_halfyearvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_halfyearvar+">半年付<font color=red>"+Math.round(PAY_1yearvar*PAY_halfyearvar)+"</font>元　";
	}
if (defaultMoneyYearvar!=null)
	{
		showMoneyvar+="升级费用：<font color=red>"+Math.round(((cloudAddmoney-<%=cloudAddmoney%>)/365)*<%=daytoend%>)+"</font>元　(到期剩余天数<%=daytoend%>天) <%if canshowagnpric then%>(代理成本价：<font color=blue>"+Math.round(((defaultMoneyYearAgnvarEnd-oldusermoneyleftAgn)/365)*<%=daytoend%>)+"</font>元)<%end if%>";
	}
if (PAY_2yearvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_2yearvar+">两年<font color=red>"+Math.round(PAY_1yearvar*PAY_2yearvar)+"</font>元　";
	}
if (PAY_3yearvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_3yearvar+">三年<font color=red>"+Math.round(PAY_1yearvar*PAY_3yearvar)+"</font>元　";
	}
if (PAY_4yearvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_4yearvar+">四年<font color=red>"+Math.round(PAY_1yearvar*PAY_4yearvar)+"</font>元　";
	}
if (PAY_5yearvar!=null)
	{
//		showMoneyvar+="<input type=radio name=year value="+PAY_5yearvar+">五年<font color=red>"+Math.round(PAY_1yearvar*PAY_5yearvar)+"</font>元";
	}

document.getElementById("showMoney").innerHTML=showMoneyvar;
OScanUserlist();
}
//计算钱
function Moneyini(defaultMoneyYearvarSTDIN,defaultMoneyYearvarIN,defaultMoneyYearAgnvarIN,CantestvarIN,CantestDayvarIN,PAY_DAYvarIN,PAY_WEEKvarIN,PAY_MonthvarIN,PAY_SeasonvarIN,PAY_halfyearvarIN,PAY_2yearvarIN,PAY_3yearvarIN,PAY_4yearvarIN,PAY_5yearvarIN)
{
defaultMoneyYearvar=defaultMoneyYearvarIN;
defaultMoneyYearvarSTD=defaultMoneyYearvarSTDIN;
defaultMoneyYearAgnvar=defaultMoneyYearAgnvarIN;
Cantestvar=CantestvarIN;
CantestDayvar=CantestDayvarIN;
PAY_DAYvar=PAY_DAYvarIN;
PAY_WEEKvar=PAY_WEEKvarIN;
PAY_Monthvar=PAY_MonthvarIN;
PAY_Seasonvar=PAY_SeasonvarIN;
PAY_halfyearvar=PAY_halfyearvarIN;
PAY_2yearvar=PAY_2yearvarIN;
PAY_3yearvar=PAY_3yearvarIN;
PAY_4yearvar=PAY_4yearvarIN;
PAY_5yearvar=PAY_5yearvarIN;
GetMoney();
}

function OScanUserlist()
{
	if (OSAllListvardefault!=null)
	{

if ((addcpuNow<OSLimbyCPUdefault)||(addRamNow<OSLimbyRamdefault))//内存太小不能预装部分操作系统
{
	var selectObj = document.getElementById("OSAllList");
		if (selectObj!=null)
	document.getElementById("showOSAllList").innerHTML=OSAllListvardefault;
	selectObj = document.getElementById("OSAllList");
	if (selectObj!=null)
 for(var i = 0,len = selectObj.options.length; i < len; i++)
 {
if (selectObj.options[i] != null)
if (OSlimvardefault.indexOf(","+selectObj.options[i].value+",")>-1)
	 {
		 selectObj.options[i].value = null;
		 selectObj.options[i].text = selectObj.options[i].text+"(当前的配置不可选这个操作系统)";
 		 selectObj.options[i].style.color="gray";
	 }
	 else
	 {
		 selectObj.options[i].text = selectObj.options[i].text;
		 selectObj.selectedIndex=i;

	 }

}
}
else
	{
		if (document.getElementById("OSAllList")!=null)
	document.getElementById("showOSAllList").innerHTML=OSAllListvardefault;
	}
}
}

function Cloudini(INServerlistIDvar,INOSAllListvar,INOSlimvar,INOSLimbyRam,INOSLimbyCPU)
{
//升级不用处理document.getElementById("showserverlistid").innerHTML=INServerlistIDvar;
//升级不用处理document.getElementById("showOSAllList").innerHTML=INOSAllListvar;
OSAllListvardefault=INOSAllListvar;
OSlimvardefault=INOSlimvar;
OSLimbyRamdefault=INOSLimbyRam;
OSLimbyCPUdefault=INOSLimbyCPU;
OScanUserlist();
NowValuesetini();
}

function NowValuesetini()
{

//alert(INOSAllListvar);
addcpuleft.style.width=((addcpuNow/addcpuLim)*100)+'%';
document.autoopen.CpuValue.value=addcpuNow;
addRamleft.style.width=((addRamNow/addRamLim)*100)+'%';
document.autoopen.RamValue.value=addRamNow;



addVHDleft.style.width=((addVHDNow/addVHDLim)*100)+'%';
document.autoopen.VHDValue.value=addVHDNow;
if (addMbpsLim>0)
addMbpsleft.style.width=((addMbpsNow/addMbpsLim)*100)+'%';
var addMbpsshow=document.getElementById("CloudTablebyMbps");
if (addMbpsLim==0)
{
	document.getElementById("addMbpsALLpx").style.background='none';
	document.getElementById("addMbpsleft").innerHTML="<center>不限制</center>";
	addMbpsNow=0;
}
document.autoopen.MbpsValue.value=addMbpsNow;
addSNAleft.style.width=((addSNANow/addSNALim)*100)+'%';
document.autoopen.SNAValue.value=addSNANow;
addBakleft.style.width=((addBakNow/addBakLim)*100)+'%';
document.autoopen.BakValue.value=addBakNow;
if (addNGBLim>0)
addNGBleft.style.width=((addNGBNow/addNGBLim)*100)+'%';
var addNGBshow=document.getElementById("CloudTablebyNGB");
if (addNGBLim==0)
{
document.getElementById("addNGBALLpx").style.background='none';
document.getElementById("addNGBleft").innerHTML="<center>不限制</center>";
	addNGBNow=0;
}
document.autoopen.NGBValue.value=addNGBNow;
addIPleft.style.width=((addIPNow/addIPLim)*100)+'%';
document.autoopen.IPValue.value=addIPNow;
if (addIopsLim>0)
addIopsleft.style.width=((addIopsNow/addIopsLim)*100)+'%';
var addIopsshow=document.getElementById("CloudTablebyIops");
if (addIopsLim==0)
{
document.getElementById("addIopsALLpx").style.background='none';
document.getElementById("addIopsleft").innerHTML="<center>不限制</center>";
	addIopsNow=0;
}
document.autoopen.IopsValue.value=addIopsNow;
}//完成初始化


var addcpuALLpx=document.getElementById("addcpuALLpx");
var addcpuleft=document.getElementById("addcpuleft");
var addcpuNum=1;
var addcpuLim=16;
var addcpuNow=addcpuMIN;
//var addcpushow=document.getElementById("addcpuNow");
function addcpu()
{
if (addcpuNow<addcpuLim)
{
addcpuNow=addcpuNow+addcpuNum;
addcpuleft.style.width=((addcpuNow/addcpuLim)*100)+'%';
//addcpushow.innerHTML=addcpuNow;
document.autoopen.CpuValue.value=addcpuNow;
//alert(addcpuNow);
GetMoney();
}//如果小于最大的
}//addcpu
function delcpu()
{
addcpuNow=addcpuNow-addcpuNum;
	if (addcpuNow<addcpuMIN)
	{
		addcpuNow=addcpuMIN;
	}
addcpuleft.style.width=((addcpuNow/addcpuLim)*100)+'%';
document.autoopen.CpuValue.value=addcpuNow;
GetMoney();
}//delcpu


var addRamleft=document.getElementById("addRamleft");
var addRamNum=10;
var addRamLim=8192;
var addRamNow=addRamMIN;
function addRam()
{
if (addRamNow<addRamLim)
{
addRamNow=addRamNow+addRamNum;
addRamleft.style.width=((addRamNow/addRamLim)*100)+'%';
document.autoopen.RamValue.value=addRamNow;
GetMoney();
}//如果小于最大的
}//addRam
function delRam()
{
addRamNow=addRamNow-addRamNum;
	if (addRamNow<addRamMIN)
	{
		addRamNow=addRamMIN;
	}
addRamleft.style.width=((addRamNow/addRamLim)*100)+'%';
document.autoopen.RamValue.value=addRamNow;
GetMoney();
}//delRam

var addVHDleft=document.getElementById("addVHDleft");
var addVHDNum=10;
var addVHDLim=2048;
var addVHDNow=addVHDMIN;
function addVHD()
{
if (addVHDNow<addVHDLim)
{
addVHDNow=addVHDNow+addVHDNum;
addVHDleft.style.width=((addVHDNow/addVHDLim)*100)+'%';
document.autoopen.VHDValue.value=addVHDNow;
GetMoney();
}//如果小于最大的
}//addVHD
function delVHD()
{
addVHDNow=addVHDNow-addVHDNum;
if (addVHDNow<addVHDMIN)
{
	addVHDNow=addVHDMIN;
}
addVHDleft.style.width=((addVHDNow/addVHDLim)*100)+'%';
document.autoopen.VHDValue.value=addVHDNow;
GetMoney();
}//delVHD

var addMbpsleft=document.getElementById("addMbpsleft");
var addMbpsNum=1;
var addMbpsLim=50;
var addMbpsNow=addMbpsMIN;
//addMbpsLim=0;
function addMbps()
{
if (addMbpsNow<addMbpsLim)
{
addMbpsNow=addMbpsNow+addMbpsNum;
addMbpsleft.style.width=((addMbpsNow/addMbpsLim)*100)+'%';
document.autoopen.MbpsValue.value=addMbpsNow;
GetMoney();
}//如果小于最大的
}//addMbps
function delMbps()
{
addMbpsNow=addMbpsNow-addMbpsNum;
if (addMbpsNow<addMbpsMIN)
{
	addMbpsNow=addMbpsMIN;
}
addMbpsleft.style.width=((addMbpsNow/addMbpsLim)*100)+'%';
document.autoopen.MbpsValue.value=addMbpsNow;
GetMoney();
}//delMbps


var addSNAleft=document.getElementById("addSNAleft");
var addSNANum=1;
var addSNALim=5;
var addSNANow=addSNAMIN;
function addSNA()
{
if (addSNANow<addSNALim)
{
addSNANow=addSNANow+addSNANum;
addSNAleft.style.width=((addSNANow/addSNALim)*100)+'%';
document.autoopen.SNAValue.value=addSNANow;
GetMoney();
}//如果小于最大的
}//addSNA
function delSNA()
{
addSNANow=addSNANow-addSNANum;
if (addSNANow<addSNAMIN)
{
	addSNANow=addSNAMIN;
}
addSNAleft.style.width=((addSNANow/addSNALim)*100)+'%';
document.autoopen.SNAValue.value=addSNANow;
GetMoney();
}//delSNA


var addBakleft=document.getElementById("addBakleft");
var addBakNum=1;
var addBakLim=5;
var addBakNow=addBakMIN;
function addBak()
{
if (addBakNow<addBakLim)
{
addBakNow=addBakNow+addBakNum;
addBakleft.style.width=((addBakNow/addBakLim)*100)+'%';
document.autoopen.BakValue.value=addBakNow;
GetMoney();
}//如果小于最大的
}//addBak
function delBak()
{
addBakNow=addBakNow-addBakNum;
if (addBakNow<addBakMIN)
{
		addBakNow=addBakMIN;
}
addBakleft.style.width=((addBakNow/addBakLim)*100)+'%';
document.autoopen.BakValue.value=addBakNow;
GetMoney();
}//delBak


var addNGBleft=document.getElementById("addNGBleft");
var addNGBNum=10;
var addNGBLim=2048;
addNGBLim=0;
var addNGBNow=addNGBMIN;
function addNGB()
{
if (addNGBNow<addNGBLim)
{
addNGBNow=addNGBNow+addNGBNum;
addNGBleft.style.width=((addNGBNow/addNGBLim)*100)+'%';
document.autoopen.NGBValue.value=addNGBNow;
GetMoney();
}//如果小于最大的
}//addNGB
function delNGB()
{
addNGBNow=addNGBNow-addNGBNum;
if (addNGBNow<addNGBMIN)
{
	addNGBNow=addNGBMIN;
}
addNGBleft.style.width=((addNGBNow/addNGBLim)*100)+'%';
document.autoopen.NGBValue.value=addNGBNow;
GetMoney();
}//delNGB

var addIPleft=document.getElementById("addIPleft");
var addIPNum=1;
var addIPLim=10;
var addIPNow=addIPMIN;
function addIP()
{
if (addIPNow<addIPLim)
{
addIPNow=addIPNow+addIPNum;
addIPleft.style.width=((addIPNow/addIPLim)*100)+'%';
document.autoopen.IPValue.value=addIPNow;
GetMoney();
}//如果小于最大的
}//addIP
function delIP()
{
addIPNow=addIPNow-addIPNum;
if (addIPNow<addIPMIN)
{
		addIPNow=addIPMIN;
}
addIPleft.style.width=((addIPNow/addIPLim)*100)+'%';
document.autoopen.IPValue.value=addIPNow;
GetMoney();
}//delIP



var addIopsleft=document.getElementById("addIopsleft");
var addIopsNum=10;
var addIopsLim=1000;
//addIopsLim=0;
var addIopsNow=addIopsMIN;
function addIops()
{
if (addIopsNow<addIopsLim)
{
addIopsNow=addIopsNow+addIopsNum;
addIopsleft.style.width=((addIopsNow/addIopsLim)*100)+'%';
document.autoopen.IopsValue.value=addIopsNow;
GetMoney();
}//如果小于最大的
}//addIops
function delIops()
{
addIopsNow=addIopsNow-addIopsNum;
if (addIopsNow<addIopsMIN)
{
	addIopsNow=addIopsMIN;
}
addIopsleft.style.width=((addIopsNow/addIopsLim)*100)+'%';
document.autoopen.IopsValue.value=addIopsNow;
GetMoney();
}//delIops

//初始化
Moneyini(defaultMoneyYearvarSTD<%=defaultpdID%>,defaultMoneyYearvar<%=defaultpdID%>,defaultMoneyYearAgnvar<%=defaultpdID%>,Cantestvar<%=defaultpdID%>,CantestDayvar<%=defaultpdID%>,PAY_DAYvar<%=defaultpdID%>,PAY_WEEKvar<%=defaultpdID%>,PAY_Monthvar<%=defaultpdID%>,PAY_Seasonvar<%=defaultpdID%>,PAY_halfyearvar<%=defaultpdID%>,PAY_2yearvar<%=defaultpdID%>,PAY_3yearvar<%=defaultpdID%>,PAY_4yearvar<%=defaultpdID%>,PAY_5yearvar<%=defaultpdID%>);

Limini(addCpuNum<%=defaultpdID%>,
addCpuCost<%=defaultpdID%>,
addCpuLim<%=defaultpdID%>,
addRamNum<%=defaultpdID%>,
addRamCost<%=defaultpdID%>,
addRamLim<%=defaultpdID%>,
addVHDNum<%=defaultpdID%>,
addVHDCost<%=defaultpdID%>,
addVHDLim<%=defaultpdID%>,
addMbpsNum<%=defaultpdID%>,
addMbpsCost<%=defaultpdID%>,
addMbpsLim<%=defaultpdID%>,
addNGBNum<%=defaultpdID%>,
addNGBCost<%=defaultpdID%>,
addNGBLim<%=defaultpdID%>,
addIPNum<%=defaultpdID%>,
addIPCost<%=defaultpdID%>,
addIPLim<%=defaultpdID%>,
addSNANum<%=defaultpdID%>,
addSNACost<%=defaultpdID%>,
addSNALim<%=defaultpdID%>,
addBakNum<%=defaultpdID%>,
addBakCost<%=defaultpdID%>,
addBakLim<%=defaultpdID%>,
addIopsNum<%=defaultpdID%>,
addIopsCost<%=defaultpdID%>,
addIopsLim<%=defaultpdID%>);
Setnowpd();
Cloudini(ServerlistIDvar<%=defaultpdID%>,OSAllListvar<%=defaultpdID%>,OSlimvar<%=defaultpdID%>,OSLimbyRam<%=defaultpdID%>,OSLimbyCPU<%=defaultpdID%>);//初始化

//按当前用的产品初始化
function Setnowpd()
{
addcpuNow=<%=dsph("CpuNum")%>;addRamNow=<%=dsph("MAXRAM")%>;addVHDNow=<%=dsph("Maxspace")%>;addMbpsNow=<%=dsph("Maxmbps8")%>;addNGBNow=<%=dsph("CDNMaxMb")%>*1000;addIopsNow=<%=dsph("MaxIops")%>;addSNANow=<%=dsph("MaxSNA")%>;addBakNow=<%=dsph("MaxBak")%>;addIPNow=<%=dsph("MaxIP")%>;
GetMoney();
}

var theobject = null; 
function resizeObject() {
this.el        = null; 
this.dir    = "";      
this.grabx = null;     
this.width = null;
}
function getDirection(el) {
var xPos, yPos, offset, dir;
dir = "";xPos = window.event.offsetX;
yPos = window.event.offsetY;offset = 21;
if (xPos<offset) dir += "w";
else if (xPos > el.offsetWidth-offset) dir += "e";
return dir;
}

var clickimgid=null;
var el=null;
function doDown() {
if ((event.srcElement.id=="")||(event.srcElement.id=="OSAllList")||(event.srcElement.id=="ServerlistID"))
{	
   theobject = null;
   return;
}
if (event.srcElement.id.indexOf("CloudTDby")==0)
{
	el =getReal(event.srcElement, "className", event.srcElement.id);
}

if (el == null) {
   theobject = null;
   return;
}  dir = getDirection(el);
if (dir == "") return;
theobject = new resizeObject();
theobject.el = el;
theobject.dir = dir;
theobject.grabx = window.event.clientX;
theobject.width = el.offsetWidth;
window.event.returnValue = false;
window.event.cancelBubble = true;
}
function doUp() {
if (theobject != null) {

if (event.srcElement.id=="CloudTDbyCPU")
{
//el = getReal(event.srcElement, "className", "CloudCPU");
addcpuNow=Math.ceil(((parseInt(addcpuleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addcpuLim);
addcpuleft.style.width=parseInt(addcpuALLpx.offsetWidth*(addcpuNow/addcpuLim))+'px';
document.autoopen.CpuValue.value=addcpuNow;
}
if (event.srcElement.id=="CloudTDbyRam")
{
addRamNow=Math.ceil(((parseInt(addRamleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addRamLim);
if (addRamNow%2==1) addRamNow=addRamNow-1;//奇数
if (addRamNow<addRamMIN) addRamNow=addRamMIN;//太小了
addRamleft.style.width=parseInt(addRamALLpx.offsetWidth*(addRamNow/addRamLim))+'px';
document.autoopen.RamValue.value=addRamNow;
} 
if (event.srcElement.id=="CloudTDbyVHD")
{
addVHDNow=Math.ceil(((parseInt(addVHDleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addVHDLim);
//if (addVHDNow%2==1) addVHDNow=addVHDNow-1;//奇数
if (addVHDNow<addVHDMIN) addVHDNow=addVHDMIN;//太小了
addVHDleft.style.width=parseInt(addVHDALLpx.offsetWidth*(addVHDNow/addVHDLim))+'px';
document.autoopen.VHDValue.value=addVHDNow;
} 
if (event.srcElement.id=="CloudTDbyMbps")
{
addMbpsNow=Math.ceil(((parseInt(addMbpsleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addMbpsLim);
if (addMbpsNow<addMbpsMIN) addMbpsNow=addMbpsMIN;//太小了
addMbpsleft.style.width=parseInt(addMbpsALLpx.offsetWidth*(addMbpsNow/addMbpsLim))+'px';
document.autoopen.MbpsValue.value=addMbpsNow;
} 
if (event.srcElement.id=="CloudTDbySNA")
{
addSNANow=Math.ceil(((parseInt(addSNAleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addSNALim);
if (addSNANow<addSNAMIN) addSNANow=addSNAMIN;//太小了
addSNAleft.style.width=parseInt(addSNAALLpx.offsetWidth*(addSNANow/addSNALim))+'px';
document.autoopen.SNAValue.value=addSNANow;
} 
if (event.srcElement.id=="CloudTDbyBak")
{
addBakNow=Math.ceil(((parseInt(addBakleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addBakLim);
if (addBakNow<addBakMIN) addBakNow=addBakMIN;//太小了
addBakleft.style.width=parseInt(addBakALLpx.offsetWidth*(addBakNow/addBakLim))+'px';
document.autoopen.BakValue.value=addBakNow;
} 
if (event.srcElement.id=="CloudTDbyNGB")
{
addNGBNow=Math.ceil(((parseInt(addNGBleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addNGBLim);
if (addNGBNow<addNGBMIN) addNGBNow=addNGBMIN;//太小了
addNGBleft.style.width=parseInt(addNGBALLpx.offsetWidth*(addNGBNow/addNGBLim))+'px';
document.autoopen.NGBValue.value=addNGBNow;
}
if (event.srcElement.id=="CloudTDbyIP")
{
addIPNow=Math.ceil(((parseInt(addIPleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addIPLim);
if (addIPNow<addIPMIN) addIPNow=addIPMIN;//太小了
addIPleft.style.width=parseInt(addIPALLpx.offsetWidth*(addIPNow/addIPLim))+'px';
document.autoopen.IPValue.value=addIPNow;
} 
if (event.srcElement.id=="CloudTDbyIops")
{
addIopsNow=Math.ceil(((parseInt(addIopsleft.offsetWidth)/parseInt(addcpuALLpx.offsetWidth)))*addIopsLim);
if (addIopsNow<addIopsMIN) addIopsNow=addIopsMIN;//太小了
addIopsleft.style.width=parseInt(addIopsALLpx.offsetWidth*(addIopsNow/addIopsLim))+'px';
document.autoopen.IopsValue.value=addIopsNow;
} 


   theobject = null;

   GetMoney();
//进入计算流程....

}

}
function doMove() {
if(theobject != null) {
var el, xPos, yPos, str, xMin, yMin;
xMin = 1; 
//	addcpushow.innerHTML= (theobject.width);
//	addcpushow.innerHTML+= ("<br>");
//	addcpushow.innerHTML+=(window.event.clientX);
//	addcpushow.innerHTML+=("<br>");
//	addcpushow.innerHTML+=(theobject.grabx);
//	addcpushow.innerHTML+=("<br>");
    theobject.el.style.width = Math.max(xMin, theobject.width + window.event.clientX - theobject.grabx) + "px";   
   window.event.returnValue = false;
   window.event.cancelBubble = true;
} 
}
function getReal(el, type, value) {
temp = el;
while ((temp != null) && (temp.tagName != "BODY")) {
   if (eval("temp." + type) == value) {
    el = temp;
    return el;
   }
   temp = temp.parentElement;
}
return el;
}
document.onmousedown = doDown;
document.onmouseup   = doUp;
document.onmousemove = doMove;

var moz;
if (moz) {
extendElementModel();
extendEventObject();
emulateEventHandlers(["mousemove", "mousedown", "mouseup"]);
}

</script>
<%VPSpdlist.close
set VPSpdlist=nothing
end if%>

<br>
<br>

　<a href="selfvpsmodify.asp?id=<%=session("VPSAUID")%>"><font color="#000000">[返回上一页]</font></a>
<!--#include virtual="/inc-freehost-function/template-vpsadm-end.asp"-->
<%end if
if ef then
Response.Redirect "e.asp?e="&ec
end if%>