

var http_request,http_request2;
var sendnum_all,succeednum_all,failingnum_all;
function SetMailSendState(mailserverid,mailclassid,mailcontentid,mailobjectid){
	sendnum_all=0;
	succeednum_all=0;
	failingnum_all=0;
	document.getElementById('total_allnum').innerHTML=sendnum_all;
	document.getElementById('succeed_allnum').innerHTML=succeednum_all;
	document.getElementById('failing_allnum').innerHTML=failingnum_all;
	send_request("http_request",'ajax_mailgroupsend.asp?gettype=chksubmit&mailserverid='+ mailserverid +'&mailclassid=' + mailclassid +'&mailcontentid=' + mailcontentid +'&mailobjectid=' + mailobjectid,"GET","doMailSendState()");
}
function doMailSendState(){
	if (http_request.readyState == 4) 
	{ // 判断对象状态
		
		if (http_request.status == 200) 
		{ // 信息已经成功返回，开始处理信息
				//alert(http_request.responseText);
				var retext=http_request.responseText;
				if (retext == "Err1"){
					alert("提交选项选择不完整，请检查完重试！");
				}else if(retext == "Err2"){
					alert("提交选项信息验证有误，请检查完重试！");
				}else{
					document.onload = doHtmlAlert();
					var Arr_Retext = retext.split("$");
					sendnum_all=Arr_Retext[0];document.getElementById('total_allnum').innerHTML=sendnum_all;
					eval(Arr_Retext[1]);
				}
		}  
		else 
		{ 
			alert("服务无法接受您的请求，请稍候再试1！");
		}
	}	
}
function doStartSendMail(){
	
	if (http_request2.readyState == 4) 
	{ // 判断对象状态
		//alert(http_request2.responseText);//  此输出供测试asp语句
		if (http_request2.status == 200) 
		{ // 信息已经成功返回，开始处理信息
				var retext2=http_request2.responseText;
			
				if(retext2=="sendend"){
					var sendendstr="<span class='blue'>邮件全部发送完毕，点击确定返回。</span><br /><br />总 数 量："+ sendnum_all +" 条，成功发送："+ succeednum_all +" 条，失败发送："+ failingnum_all +" 条";
					document.getElementById('div_content').innerHTML=sendendstr;
					document.getElementById('div_btnOK').value=" 确 定 ";
				}else{
					var Arr_Retext2 = retext2.split("$");
						
					//Arr_Retext[1]=1则发送成功
					if(Arr_Retext2[0]=="1"){
						
						succeednum_all+=1;
						document.getElementById('succeed_allnum').innerHTML=succeednum_all;
						
						
					}else{
						failingnum_all+=1;
						document.getElementById('failing_allnum').innerHTML=failingnum_all;
						
					}
					eval(Arr_Retext2[1]);
				}
		}  
		else 
		{ 
			
			alert("服务无法接受您的请求，请稍候再试2！");
		}
	}
}


function SetContinueSend(mailserverid,mailclassid,mailcontentid,mailobjectid,startid,mailhistoryid){
	document.onload = doHtmlAlert();
	document.getElementById('total_allnum').innerHTML=sendnum_all;
	document.getElementById('succeed_allnum').innerHTML=succeednum_all;
	document.getElementById('failing_allnum').innerHTML=failingnum_all;
	send_request("http_request2",'ajax_mailgroupsend.asp?gettype=startsend&mailserverid='+ mailserverid +'&mailclassid=' + mailclassid +'&mailcontentid=' + mailcontentid +'&mailobjectid=' + mailobjectid +'&getoverid=' + startid +'&mailhistoryid=' + mailhistoryid,"GET","doStartSendMail()");
}


function doHtmlAlert(){
	var divHAContainer = document.getElementById("SendStateContent");						

	divHAContainer.style.width = document.body.clientWidth;
	divHAContainer.style.height = document.body.clientHeight;
	divHAContainer.style.top = document.body.scrollTop;
	divHAContainer.style.left = 0;
	divHAContainer.style.display = 'block';	
	selectCol('hidden');
	document.getElementById("div_btnOK").focus();
}
function selectCol(d){
	var colSelects = document.getElementsByTagName('SELECT');
	for(var i=0; i<colSelects.length; i++){							
		colSelects[i].style.visibility = d;
	}
}