function checknum(MaxMyCash,Restrict,MinPrice,MaxPrice)
{
	price=document.form1.price.value;
	if ((price=="") || (isNaN(price)))
	{
		alert("请输入正确的上市股票单价。");
		return false;
	}
	if ((Compute(price,2)<1) || (Compute(price,2)<Compute(MinPrice,2)) || (Compute(price,2)>Compute(MaxPrice,2)))
	{
		alert("请正确输入股票单价，单价范围：["+MinPrice+"]～["+MaxPrice+"]！");
		return false;
	}
	ExportNum=Compute(MaxMyCash,2)/Compute(price,2)
	if (Compute(ExportNum)<Compute(Restrict))
	{
		alert("个股上市要求每次最少上市["+Restrict+"]股！您输入的单价只能上市"+Compute(ExportNum,0)+"股，请降低输入的单价。");
		return false;
	}
	document.getElementById("maxnum").innerHTML="您最多可以上市[<font color=#0000FF>"+Compute(ExportNum,0)+"</font>]股。"
	document.form1.gpnum.value=Compute(ExportNum/100,0)
}
function hlnum(StNum,UserCash,price,sblimit,poundage)
{
	var sblimitshow="";
	honglinum=document.form1.honglinum.value
	if ((honglinum=="") || (isNaN(honglinum)))
	{
		alert("请输入正确的分红数量。");
		return false;
	}
	if (sblimit>0)
	{
		sblimitshow="或小于[0]或负红最大值为当前股票价格的负["+Formatnumber(""+Compute(sblimit*100,2)+"")+"%]（"+Formatnumber(""+Compute(-price*sblimit,2)+"")+"）";
	}else{
		sblimitshow="[0]";
	}
	if ((honglinum==0) || (honglinum<-price*sblimit))
	{
		alert("分红数量必须大于"+sblimitshow+"。");
		return false;
	}
	addmoney=Compute(StNum/10*honglinum,2);
	poundage=Compute(addmoney*poundage,2);
	if (addmoney>0)
	{
		var umoney=addmoney+poundage;
	}else{
		var umoney=addmoney-poundage;
	}
	if (Compute(umoney,2)>Compute(UserCash,2))
	{
		alert("您没有这么多资金提供分红！请减少赠送数量。");
		return false;
	}
	document.getElementById("maxnum").innerHTML="此次分红共需要费用[<font color=blue>"+Formatnumber(""+Compute(umoney,2)+"")+"</font>]元，其中分红费用["+Formatnumber(""+Compute(addmoney,2)+"")+"]元，手续费["+Formatnumber(""+Compute(poundage,2)+"")+"]元。分红后您的资金["+Formatnumber(""+Compute(UserCash-umoney,2)+"")+"]元。<br><br>"
}
function sgnum(StNum,UserCash,price,poundage)
{
	songguNum=document.form1.songgunum.value
	if ((songguNum=="") || (isNaN(songguNum)))
	{
		alert("请输入正确的请输送股数量。");
		return false;
	}
	if (songguNum<=0)
	{
		alert("送股数量不能小于或等于[0]。");
		return false;
	}
	var usnum=Compute(StNum/10*songguNum,0);
	addmoney=Compute(usnum*price,2);
	poundage=Compute(addmoney*poundage,2);
	if (Compute(addmoney+poundage,2)>Compute(UserCash,2))
	{
		alert("您没有这么多资金提供送股！请减少赠送数量。");
		return false;
	}
	document.getElementById("maxnum").innerHTML="此次分红共需要费用[<font color=blue>"+Formatnumber(""+Compute(addmoney+poundage,2)+"")+"</font>]元，共送出["+usnum+"]股股票，其中分红费用["+Formatnumber(""+Compute(addmoney,2)+"")+"]元，手续费["+Formatnumber(""+Compute(poundage,2)+"")+"]元。分红后您的资金["+Formatnumber(""+Compute(UserCash-(addmoney+poundage),2)+"")+"]元。<br><br>"
}
var FastWin=0;
function excheckdata(old)
{
	if (old==1)
	{
		var StCode=document.form1.gpcode.value;
		var OldStCode=0
		var StName=document.form1.gpname.value;
		var OldStName=0
	}
	else
	{
		var StCode=document.form1.gpcode.value;
		var OldStCode=document.form1.gpoldcode.value;
		var StName=document.form1.gpname.value;
		var OldStName=document.form1.gpoldname.value;
	}
	if (FastWin)
	{
		if(!FastWin.closed) FastWin.close();
	}
	var Limit=/^[0-9]{6}$/;
	if (!Limit.exec(StCode))
	{
		alert("请输入正确的股票代码[六位数字]！");
		return false
	}
	if ((StName=="") || (StName.length>8))
	{
		alert("请输入正确的股票名称！");
		return false
	}
	if (ContentFilter(StName))
	{
		alert("请输入正确的股票名称！");
		return false
	}
	FastWin=window.open('ex_sm_help.asp?action=checkdata&stcode='+StCode+'$$$'+OldStCode+'&stname='+StName+'$$$'+OldStName+'','','left=100,top=100,width=430,height=103,resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no');
}
var tradeask=0;
var stocksum=0;
var stockprice=0;
var poundage=0;
var Profit;
function countprice(UserCash,i,SellStcokSum)
{
	if (i==1)
	{
		var StockNum=document.form1.buynum.value;
	}
	else
	{
		var StockNum=document.form1.salenum.value;
	}
	if (UserCash<0)
	{
		alert("您的帐号中资金不足！");
		return false
	}
	if ((StockNum=="") || (isNaN(StockNum)) || (StockNum<=0))
	{
		alert("请输入正确的交易数量。");
		return false;
	}
	StockNum=Compute(StockNum,0)
	if ((tradeask>0) && (StockNum>tradeask))
	{
		alert("本股市限制每次最大交易量为["+tradeask+"]股。");
		return false
	}
	var CountPoundage=StockNum*stockprice*poundage;
	var CountCost=StockNum*stockprice;
	if (i==1)
	{
		if ((stocksum>100) && (StockNum<100))
		{
			alert("请输入正确的交易数量，数量必须大于[100]股。");
			return false;
		}
		if ((stocksum<100) && (stocksum-StockNum>0))
		{
			alert("该股票数量已经不足最少交易量[100]股，您必须全部买入。");
			return false;
		}
		if ((Compute(CountPoundage+CountCost,2)>UserCash) || (StockNum>stocksum))
		{
			alert("请输入正确的买入数量，您没有足够资金购买股票或没有足够的股票提供交易。");
			return false;
		}
		var TradeBackPrice=Compute(UserCash-(CountPoundage+CountCost),2);
		var TotalPrice="支出["+Formatnumber(""+Compute(CountPoundage+CountCost,2)+"")+"]"
	}
	else
	{
		if ((SellStcokSum>100) && (StockNum<100))
		{
			alert("请输入正确的交易数量，数量必须大于[100]股。");
			return false;
		}
		if ((SellStcokSum<100) && (SellStcokSum-StockNum>0))
		{
			alert("该股票数量已经不足最少交易量[100]股，您必须全部卖出。");
			return false;
		}
		if ((SellStcokSum<=0) || (StockNum>SellStcokSum))
		{
			alert("请输入正确的卖出数量，您没有这么多股票出售。");
			return false;
		}
		var TradeBackPrice=Compute(UserCash+(CountCost-CountPoundage),2);
		var TotalPrice="所得["+Formatnumber(""+Compute(CountCost-CountPoundage,2)+"")+"]"
	}
	if (TradeBackPrice>UserCash) Profit="<Font color=red>↑</Font>"
	if (TradeBackPrice<UserCash) Profit="<Font color=green>↓</Font>"
	if (TradeBackPrice==UserCash) Profit="→"
	document.getElementById("cost").innerHTML="计算结果：交易后帐户资金["+Profit+Formatnumber(""+TradeBackPrice+"")+"]元<br>交易数量["+StockNum+"]股，"+TotalPrice+"元，其中股票总值["+Formatnumber(""+Compute(CountCost,2)+"")+"]元，手续费["+Formatnumber(""+Compute(CountPoundage,2)+"")+"]元"
}
