
function tongji (tableID,jianlastrows,formrows,formlist,endlist,formwrite)
{
/*方法参数 说明
tableID   表格ID名字
jianlastrows  不要的最后几行数
formrows	从第几行开始统计
formlist	从第几列开始统计
endlist		到第几列结束统计
formwrite	统计从第几行开始写入

*/ 

var cishu = 0			//出现的次数
var temp_1		
var rows_length = 0		// 总行数
var maxyiqi = 0			//历史最大遗漏期数

var lianshow = 0		//连续出现的期数
var lianshow_temp = 0 

var temp_3 = 0			
var meicisum = 0		//每次最大遗漏值相加和

var formtongji=formwrite			//开始写统计的行号


table_o = document.getElementById(tableID);
rows_length = table_o.rows.length - jianlastrows ;				// 得到总行数 - 没用的行数  =  实际行数
//alert(table_o.rows[2].cells.length)
//alert(document.getElementById("ta_1").rows[2].cells[31].innerText);
for (j = formlist ; j<= endlist ;j++ ){					// 列
cishu = 0
maxyiqi = 1
lianshow = 0
lianshow_temp = 0
temp_3 = 0
meicisum = 0

	
for (i = formrows ; i <= rows_length ;i++ )		//行
{
	temp_1 = table_o.rows[i].cells[j].xuan
		
		//alert(table_o.rows[i].cells[j].xuan+"_"+i+"_"+j)
    if(temp_1 != null)
	{
		lianshow_temp += 1 ;
			if(lianshow_temp > lianshow) lianshow = lianshow_temp ;
		if(Number(temp_1)>1) 	cishu = cishu + Number(temp_1)-1 ;
		cishu = cishu + 1;
		meicisum = meicisum + temp_3 ; 
		temp_3 = 0 ;
	}
	else
	{
		lianshow_temp = 0						
		temp_1 = table_o.rows[i].cells[j].innerText ;
		temp_3 = Number(temp_1) ;
		if( Number(temp_1) > maxyiqi) maxyiqi = Number(temp_1) ;
	}
}
meicisum = meicisum + temp_3 ;
document.getElementById('tr_1').cells[formtongji].innerText = cishu;
document.getElementById('tr_2').cells[formtongji].innerText = maxyiqi;
document.getElementById('tr_3').cells[formtongji].innerText = lianshow;

var temp_4 = 0 
if(cishu != 0 )
	temp_4 = Math.floor(Number(meicisum) / Number(cishu)) 
document.getElementById('tr_4').cells[formtongji].innerText = temp_4 ;

//当前遗漏值

temp_2 = table_o.rows[rows_length].cells[j].innerText;

if(temp_2 == "" )  temp_2 = 0
else if (table_o.rows[rows_length].cells[j].xuan != null)   temp_2 = 0 

document.getElementById('tr_5').cells[formtongji].innerText = temp_2;
formtongji++
}
}




//  模拟选号
function bground(obj,number,color,type2,imgpath){
	var o = document.getElementById(obj) ;
	if(type2 == 0){			//
		  if(o.innerHTML==""){
			  o.innerHTML = "<img src='/qiu/"+color+number+".gif'/>";		
		  }
		  else{
			 o.innerHTML='';
		 }
	}
	else if(type2 == 1){
		  if(o.innerHTML == ""){
			  o.background = imgpath ;
			  o.innerHTML = "<span style='font-weight: bold'><font color='#ffffff' >"+number+"</font></span> " ; 
		  }
		  else{
			  o.background = "" ;
			  o.innerHTML =  "" ; 
		 }
	}else if(type2 == 2){
			var temp = imgpath.split("_");
		  if(o.innerHTML == "" && o.style.backgroundColor != temp[0]){
			  o.style.backgroundColor = temp[0] ;
			  o.innerHTML = number ; 
		  }
		  else{
			  o.style.backgroundColor = temp[1];
			  o.innerHTML =  "" ; 
		 }
	}
}

//  模拟选号  非数字

function bground_nonumber(obj1,obj2){
	//obj1,当前 TD 格的ID
	//obj2,要设置的文字或其它
	
	var o = document.getElementById(obj1) ;
  if(o.innerHTML=="")
	  o.innerHTML = obj2 		
  else
	 o.innerHTML="";
 }



//模拟选号  组选 3 6 
function bground_zhu(obj){  
  if(document.getElementById(obj).id.indexOf("zhu_3")>-1)
  
  	if(document.getElementById(obj).innerText =="③")
  		document.getElementById(obj).innerText ="" ;
    else
	   document.getElementById(obj).innerText ="③" ;	
  else
  
	  if(document.getElementById(obj).innerText=="⑥")
	  	 document.getElementById(obj).innerText ="" ;
	  else
	 	 document.getElementById(obj).innerText="⑥";
 }


//012彩路 012sc.asp bground_nonumber('r_1_<%=ss%>','<span class=red2 style=font-size:14px>◎</span>',)
function click_bground_nonumber(obj1_xuan,obj2,obj3,content,rowID,qf){
		if (document.getElementById(obj1_xuan).innerHTML != "")
		{
			document.getElementById(obj1_xuan).innerHTML = "" ;
		}
		else
		{
			document.getElementById(obj1_xuan).innerHTML = content;
		}

		document.getElementById(obj2).innerHTML = "" ;
		document.getElementById(obj3).innerHTML = "";

		var co_ = obj1_xuan.substr(obj1_xuan.length-1,obj1_xuan.length)			//行到大的行数 3 2 1 
		var id_temp_1 = "scolor"+co_

		if(qf == 0){
			var a_temp_ = getTaContent(rowID,1,10) 
			var a_a =  a_temp_.substr(0,1)
			var b_b = a_temp_.substr(1,1)
			var c_c = a_temp_.substr(2,3)
			
			clearColor(id_temp_1,5)
			if(a_a != "" && b_b != "" && c_c != ""){
				
				getColor(a_a,b_b,c_c,co_,id_temp_1)
			}
			

		}else if(qf == '1'){
			var temp_p = getTaContent(rowID,1,10) ;
				temp_p = temp_p.replace("◎","0").replace("①","1").replace("②","2")
				temp_p = temp_p.replace("◎","0").replace("①","1").replace("②","2")
				temp_p = temp_p.replace("◎","0").replace("①","1").replace("②","2")
			kljlk(temp_p,co_)
		}

}
//清除现有颜色 012 
function clearColor(id,i){
	for (var j = 1; j<=i ; j++ )
	{			
				//alert(id+j)
				document.getElementById(id+j).innerHTML = ""
				document.getElementById(id+j).style.backgroundColor = ""
	}
}
//

//得到012彩路颜色 
function getColor(a1,a2,a3,trli,id_temp_1){	
	var j_temp = a1+"_"+a2+"_"+a3
	
	if(a1 != null && a2 != null && a3 !=null){
		if(a1 == a2 && a1 == a3) 
		{
				document.getElementById("scolor"+trli+"4").innerHTML = "<span  style=font-size:14px>◎</span>组"
				document.getElementById("scolor"+trli+"4").style.backgroundColor = "#c0c0c0"
				
		}else if(j_temp.indexOf("◎") < 0)
		{
				document.getElementById("scolor"+trli+"2").innerHTML = "<span  style=font-size:14px>①②</span>组"
				document.getElementById("scolor"+trli+"2").style.backgroundColor = "#ccffcc"
		}else if(j_temp.indexOf("①") < 0)
		{
				document.getElementById("scolor"+trli+"5").innerHTML = "<span  style=font-size:14px>◎②</span>组"
				document.getElementById("scolor"+trli+"5").style.backgroundColor = "#ccffff"		
		}else if(j_temp.indexOf("②") < 0)
		{
				document.getElementById("scolor"+trli+"3").innerHTML = "<span  style=font-size:14px>◎①</span>组"
				document.getElementById("scolor"+trli+"3").style.backgroundColor = "#99ccff"		
		}else{
				document.getElementById("scolor"+trli+"1").innerHTML = "<span  style=font-size:14px>◎①②</span>"
				document.getElementById("scolor"+trli+"1").style.backgroundColor = "#ffff99"		
			}
	}
}
//012走势  "scolor_id_27"
function kljlk(obj,id){
	
	var obj_1 = document.getElementById("ta_1");
	var cells_ji = 0
	//alert(document.getElementById("td12").style.backgroundColor)
var temp_te = "scolor"+id ; 
clearColor(temp_te,27)

	for ( var j=9;j< 36;j++ )
	{
		cells_ji++ ;
		if(obj_1.rows[1].cells[j].innerText == obj){
			//alert(obj+"_"+"scolor"+id+""+cells_ji)
			document.getElementById("scolor"+id+""+cells_ji).innerText =  obj
document.getElementById("scolor"+id+""+cells_ji).style.backgroundColor = document.getElementById("td"+cells_ji).style.backgroundColor
		}
	}		
}
//得到指定表格中内容
function getTaContent(trID,formtd,endtd){
	var returnobj = ""	

	for ( var j = formtd ; j< endtd ;j++ )
	{		
		var temp = document.getElementById(trID).cells[j].innerText ;
		if( temp != ""){
			//alert(obj+"_"+"scolor"+id+""+cells_ji)
			returnobj = returnobj + "" + temp 
		}
	}	
	return returnobj
}
//3d大小 
function ewrew(id1,id2,id1img,rowsid){
	var o = document.getElementById(id1) ;
	var o2 = document.getElementById(id2) ;
	var rowid = document.getElementById(rowsid) ;
	var temp_o = ""
	var temp_p = ""
var co_ = id1.substr(id1.length-1,id1.length)

		  if(o.background == ""){
			  o.background = id1img ;
			  o2.background = "" ;
		  }
		  else{
			  o.background = "";
			  o2.background = "";
		 }
//	alert(o.pih)
var jishu_1 = 0
	for (var j = 1 ;j < 7 ;j++ )
	{
		//alert(rowid.cells[j].id)
		temp_o = document.getElementById(rowid.cells[j].id)
		if(temp_o.background != ""){
			jishu_1++
			temp_p = temp_p + temp_o.pih
		}	
	}
		var id_temp_1 = "scolor"+co_
		clearColor(id_temp_1,8)

	if(jishu_1 == 3 ){
		oukkn(temp_p,co_)
	}
}

//3d 大小走势
function oukkn(obj,co_){

var obj_1 = document.getElementById("ta_1");
var cells_ji = 0

	for ( var j=10;j< 18;j++ )
	{
		cells_ji++ ;
		if(obj_1.rows[1].cells[j].innerText == obj){
			//alert(obj+"_"+"scolor"+id+""+cells_ji)
document.getElementById("scolor"+co_+""+cells_ji).innerText = obj
document.getElementById("scolor"+co_+""+cells_ji).style.backgroundColor = document.getElementById("td"+cells_ji).style.backgroundColor
		}
	}	
}
