function x3D(){
var clean;
this.nArray=new Array(10);
this.TotArr=new Array();
this.TotStr=new Array();
this.sArray=new Array();
this.isEdit=-1;
this.Items=0;
this.Double=1;
this.isSelect=-1;
this.isDraw=false;
this.onDouble=function(arg){
arg=arg||0;
var obj=$$("Double5");
if(!this.isDraw){
for(var i=1;i<=50;i++){
obj.add(new Option("加 "+i+" 倍",i));
}
this.isDraw=true;
}
obj[arg].selected=true;
}
this.onClick=function(arg){
var value=arg.id;
value=value.replace("x3D_","");
if(this.nArray[parseInt(value)]==1){
if(this.isEdit!=-1){
if(this.TotStr[0]!=null && this.TotStr[0].length>2){
if(this.TotStr[0].split(",").length>=3){
return false;
}}}
this.nArray[parseInt(value)]=0;
}else{
if(this.TotStr[0]!=null && this.TotStr[0].length>2){
if(this.TotStr[0].split(",").length>=3) return;
}
this.nArray[parseInt(value)]=1;
}
this.onStyle();
}
this.onStyle=function(){
this.clTotal();
for(var i=0;i<10;i++){
if(this.nArray[i]==1){
this.onTotal(i);
$$("x3D_"+i).className="BB";
}else{
$$("x3D_"+i).className="GB";
}}
this.onOut();
if(this.isEdit!=-1){
this.Edit();
}}
this.onTotal=function(arg){
this.TotArr[0]++;
if(this.TotStr[0]==null){
this.TotStr[0]=arg;
}else{
this.TotStr[0]=this.TotStr[0]+","+arg;
}}
this.clTotal=function(){
this.TotArr[0]=0;
this.TotStr[0]=null;
}
this.onCompute=function(A){
if(A<3 || A>10) return 0;
var Tot=0;
var k,l
for(var i=0;i<A;i++){
for(k=i;k<A;k++){
for(l=k;l<A;l++){
if(i!=k&&i!=l&&k!=l){
Tot++;
}}}}
return Tot;
}
this.onOut=function(){
this.Items=this.onCompute(this.TotArr[0])
var Obj=$$("d5");
Obj.innerHTML="当前选号：<span class='tre tb'>"+this.Items+"</span>&nbsp;注， <span class='tre tb'>"+this.Double+"</span>&nbsp;倍，金额： <span class='tre tb'>"+this.Items*2*this.Double+"</span>元";
}
this.onInArray=function(){
if(this.isEdit!=-1) return;
if(this.TotStr[0]==null) return;
if(typeof(this.TotStr[0])=="number") return;
if (this.TotStr[0].length<4) return;
var Len=this.sArray.length;
this.sArray[Len]=new Array(this.TotStr[0],this.Double);
this.onIn();
}
this.onIn=function(){
var arg="x3DContent";
this.clIn(arg);
var obj=$$(arg);
var Len=this.sArray.length;
var Text,Value;
for(var i=0;i<Len;i++){
if(this.sArray[i]!=null){
Text=this.sArray[i][0]+"　　×"+this.sArray[i][1];
Value=i+"|"+this.sArray[i][0]+"|"+this.sArray[i][1];
obj.add(new Option(Text,Value));
}}
this.clAll();
}
this.clIn=function(arg){
var obj=$$(arg);
var Len=obj.length;
for(var i=Len-1;i>=0;i--){
obj.remove(i);
}}
this.Edit=function(){
this.sArray[this.isEdit]=new Array(this.TotStr[0],this.Double);
var arg="x3DContent";
var obj=$$(arg);
obj[this.isSelect].value=this.isEdit+"|"+this.TotStr[0]+"|"+this.Double;
obj[this.isSelect].text=this.TotStr[0]+"　　×"+this.Double;
}
this.clAll=function(){
for(var i=0;i<10;i++){
this.nArray[i]=0;
}
this.Double=1;
this.onDouble();
if(this.isEdit==-1){
this.onStyle();
}}
this.onChange=function(arg){
	if (clean==arg.options.selectedIndex){
	this.onBlur();
	clean=-1;
			} else {
	clean=arg.options.selectedIndex;
this.clAll();
var obj=arg.options;
this.isSelect=obj.selectedIndex;
var value=obj[this.isSelect].value;
var Arr=value.split("|");
this.isEdit=parseInt(Arr[0]);
this.TotStr[0]=Arr[1];
this.Double=Arr[2];
this.onDouble(this.Double-1);
var Arr=this.TotStr[0].split(",")
var Len=Arr.length;
for(var i=0;i<Len;i++){
this.nArray[parseInt(Arr[i])]=1;
}
this.onStyle();
}}
this.onDel=function(){
if(this.isEdit==-1) return;
this.sArray[this.isEdit]=null;
this.isEdit=-1;
this.onIn();
}
this.seDouble=function(){
var obj=$$("Double5");
var value=obj[obj.selectedIndex].value;
this.Double=value;
this.onStyle();
if(this.isEdit!=-1){
this.Edit();
}}
this.Clean=function(){
this.isEdit=-1;
this.sArray=new Array();
this.onIn();
}
this.onBlur=function(){
	clean="";

this.isEdit=-1;
this.onIn();
}
this.reData=function(arg){
if(arg=="") return;
this.clAll();
this.sArray=new Array();
var TArr=arg.split("|");
var Arr;
var Len=TArr.length;
var SubArr=null;
for(var i=0;i<Len;i++){
Arr=TArr[i].split("×");
SubArr=Arr[0].split(",");
this.sArray[this.sArray.length]=new Array(Arr[0],Arr[1]);
}
this.onIn();
}
this.getData=function(){
var Len=this.sArray.length;
var TempStr="";
for(var i=0;i<Len;i++){
if(this.sArray[i]!=null){
TempStr=TempStr+"|"+this.sArray[i][0]+"×"+this.sArray[i][1];
}}
if(TempStr==""){
return false;
}else{
$$("Content").value=TempStr.substr(1);
return true;
}}}
var x3D=new x3D();