
var chooseArray=[14];  //存号
var sapce = {};
var count_C = 0;
sapce.manner = 1;
sapce.muliptile =1;
sapce.countMoney = 0.00;
sapce.zs = 0;
sapce.issue = 0000;


function showDz() {

$.getJSON(""+contextPath+"/letoula/data/winsFlat_trade.jsp?r="+Math.random(),{smalltype:gameid},function($_return){
  	
   	var items=$_return.items;
	var tr = '';
	$('.stoptime').text(setting.axyformatTime(items[0].stoptime));
	var num_S = '<td><span class="sp_w45"><span class="sp_nxz" onclick="create_class.cursorX(this)" order="0">0</span></span></td><td><span class="sp_w45"><span class="sp_nxz" onclick="create_class.cursorX(this)" order="1">1</span></span></td><td><span class="sp_w45"><span class="sp_nxz" onclick="create_class.cursorX(this)" order="2">2</span></span></td><td><span class="sp_w45"><span class="sp_nxz" onclick="create_class.cursorX(this)" order="3">3+</span></span></td>';
	
	for(var i=0;i<items.length;i++){
		
		var spvalue = items[i].spValue.replace(/[" "]/g,"|").split('|');
		if(spvalue[0] == 'null' || spvalue[0] == 'undefined'){
			spvalue = ['0.00','0.00','0.00'];
		}
		var stoptime = items[i].stopselldate.substring(4,6) +'-'+ items[i].stopselldate.substring(6,8)+" "+items[i].stopselldate.substring(8,10)+':'+items[i].stopselldate.substring(10,12);
		
		tr+='<tr class="c'+(i*2)+'" mathNum="'+items[i].mathNum+'" vs="'+items[i].hostteam+' VS  '+items[i].guestdu+'"><td rowspan="2">'+items[i].mathNum+'</td><td style="background: rgb(51, 102, 153);color:#fff;" rowspan="2">'+items[i].legaueName+'</td><td rowspan="2">'+stoptime+'</td><td><span class="gray">主</span><a href="javascript:void(0)" title='+items[i].hostteam+'>'+items[i].hostteam+'</a><sup>'+items[i].b1+'</sup></td><td rowspan="2"><span class="sp_w38">'+spvalue[0]+'</span><span class="sp_w38">'+spvalue[1]+'</span><span class="sp_w38">'+spvalue[2]+'</span></td>'+num_S+'</tr>'+
		'<tr class="c'+(i*2+1)+'" mathNum="'+items[i].mathNum+'" vs="'+items[i].hostteam+' VS  '+items[i].guestdu+'"><td><span class="gray">客</span><a href="javascript:void(0)" title='+items[i].guestdu+'>'+items[i].guestdu+'</a><sup>'+items[i].b2+'</sup></td>'+num_S+'</tr>';
	}
	
	sapce.issue = items[0].issue;
	$('.now_issue').text(items[0].issue);
	$('.dssc').attr('href',$('.dssc').attr('href')+'&issue='+sapce.issue);
	$(tr).appendTo('.conbody');
	
});


}

var create_class={
	'cursorX':function(_this){
		
		var clsname = _this.className;
		sapce.manner = 1;
		clsname == 'sp_nxz' ? $(_this).addClass('sp_xs') : $(_this).removeClass('sp_xs');
		
		var rowc = $(_this).parents('tr').attr('class') , rowi = rowc.substring(1,rowc.length) , num = '';
		
		var nowRow = $(_this).parents('tr').find('.sp_xs');
		
		for(var i=0 ; i < nowRow.length ; i++){
			
			num += $(nowRow).eq(i).attr('order') + ',';
		}

		chooseArray[rowi] = num.substring(0,num.length-1);
		
		$(chooseArray).each(function(i,s){
			if(s.length >= 2) {
				sapce.manner = 2;return;
			}
		});
		this.choosefiler(chooseArray);
	},
	'choosefiler':function(args,rowi){
		
		count_C = 0;
	
		var tzMsg = '' , tzNumber = '';sapce.info = '';
		$('#comBody').empty();
		for(var s=0 ; s<args.length; s++){
			
			if(args[s]){
				
				count_C++;
				if(sapce.manner == 2) {
					tzNumber+=chooseArray[s].replace(/[,]/g,'/')+"//";
				}else{
					tzNumber+=chooseArray[s] + '/';
				}
				
				if(chooseArray[s*2]){
					tzMsg += '<tr><td>'+(s+1)+'</td><td>'+$(".c"+(s*2)).attr('vs')+'</td><td class="ct_com">'+chooseArray[s*2]+'</td><td class="ct_com">'+chooseArray[s*2+1]+'</td></tr>';
					sapce.info  += (s+1) + '/' + $(".c"+(s*2)).attr('vs') +'/['+chooseArray[s*2]+']'+'/[' + chooseArray[s*2+1] + ']|';
				}
					
			}
		}
		
		tzNumber = tzNumber.substring(0,tzNumber.length-sapce.manner);
		sapce.info = sapce.info.substring(0,sapce.info.length-1);
		
		$("#cs").html(count_C);
		if(count_C == jsSrc[gameid].cn){
			
			$(tzMsg).appendTo('#comBody');
			sapce.tzNumber = tzNumber;
		
			$.get(""+contextPath+"/letoula/data/calculate_money.jsp?r="+Math.random(),{mcn:sapce.manner,tzNumber:tzNumber,MaxNumber:sapce.muliptile,MaxSp:'maxsp',gameid:gameid},function(zd){
				
				sapce.countMoney=parseInt(zd)*2*sapce.muliptile;
				$("#zs").html(zd);
				$('.pc').text('￥'+parseFloat(sapce.countMoney).toFixed(2));
				sapce.zs = zd;
			});		
		}
	},
	'doArawd':function(){
		
	},
	'seaDetails':function(nd,sh,txt){
		var off_top=document.documentElement.scrollTop;
		var off_left=document.documentElement.scrollLeft; 
        ZQ.$(nd).style.top=(off_top+100)+"px";
        ZQ.$(nd).style.left=(document.body.clientWidth/2-250)+"px";
        $('.eroorMsg').text(txt);
		sh == 's' ? $('#bd,#'+nd+'').show() : $('#bd,#'+nd+'').hide();
	},
	'mltOnkeyUp':function(){
		
		var _this=arguments[0],
			val=parseInt(_this.value);
			
		if(val > 99999) {
			_this.value='99999';
		}
		
		if(isNaN(_this.value) || val <= 0 || _this.value.indexOf('.')!=-1){
		
		   _this.value=1;
		}
		
		sapce.muliptile=_this.value;
		
		sapce.countMoney=parseInt(sapce.zs)*2*sapce.muliptile;
		$("#zs").html(sapce.zs);
		$('.pc').text('￥'+parseFloat(sapce.countMoney).toFixed(2));
				
	},
	'loginCheck':function(url){
		
		var userName = ZQ.$('loginName').value;
		var password = ZQ.$('password').value;
		
		if(userName.length <= 0){
			
			this.seaDetails('blk2','s',betting_yz.lsn);
			return false;
		}else if(password.length <= 0)
		{
			this.seaDetails('blk2','s',betting_yz.lsp);
			return false;
		}else{
			$.get(url+'&r='+Math.random(),{'loginName':userName,'password':password,'code':'ny'},function(su){
				
				su = eval("("+su+")");
				if(su.errorMessage){
					create_class.seaDetails('blk2','s',su.errorMessage);
					return;
				}
				
				window.location.reload();
			})
		}
	},
	/*
	*投注提交
	*/
	'submitInformation':function(mx){
		
		if(count_C < jsSrc[gameid].cn){
			this.seaDetails('blk2','s',jsSrc[gameid].errorMsg);
			return;
		}
	
		ZQ.$('muliptile').value=sapce.muliptile;						//倍数
		ZQ.$('tzNumber').value=sapce.tzNumber; 							//投注号码
		ZQ.$('zhushu').value=sapce.zs;									//注数
		ZQ.$('price').value=sapce.countMoney;							//投注金额
		ZQ.$('ZQMcN').value=sapce.manner;		    					//McN
		ZQ.$('issue').value=sapce.issue;								//期号
		ZQ.$('inf').value=sapce.info;									//投注数据

		mx == 'x' ? this.View_detail(cos) : ZQ.$('myform').submit();
	}
};

