
var root;
var lotteryType;
function luck_stake(falg) {
	try {
		root = document.getElementById("root").value;
		var date = new Date();
		var url = root + "/servlet/checkLogin.cl?nn=" + date;
		xmlHttp.open("GET", url, false);
		xmlHttp.onreadystatechange = function () {
			luckstake(falg);
		};
		xmlHttp.send(null);
	}
	catch (e) {
		alert(e);
	}
}
function luckstake(flag) {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var code = xmlHttp.responseText;			
			if (code == "1") {			
				luck_stake_submit(flag);			
			} else {
				window.parent.myAlert();
			}
		}
	}
}


function luck_stake_submit(flag) {
//luckform
 /* var sxStyleValue = document.getElementById("shengXiao02").style.display;
  var xzStyleValue = document.getElementById("xingZuo02").style.display;
  var xmStyleValue = document.getElementById("xingMing02").style.display;
  var srStyleValue = document.getElementById("shengRi02").style.display;
  var sjStyleValue = document.getElementById("shouJiHao02").style.display;
	if(sxStyleValue=='block'){
  		lotteryType= document.getElementById("lotteryType_sx").value;
  	}else if(xzStyleValue=='block'){
  		lotteryType= document.getElementById("lotteryType_xz").value;
  	}else if(xmStyleValue=='block'){
  		lotteryType= document.getElementById("lotteryType_xm").value;
  	}else if(srStyleValue=='block'){
  		lotteryType= document.getElementById("lotteryType_sr").value;
  	}else if(sjStyleValue=='block'){
  		lotteryType= document.getElementById("lotteryType_sj").value;
  	}
  	*/
  	//选择彩种
  	lotteryType = selectLottery();
	if (lotteryType == "") {
		alert("\u8bf7\u9009\u62e9\u5f69\u79cd,\u83b7\u53d6\u5e78\u8fd0\u53f7\u7801");
		return false;
	}
	var form = document.getElementById("luckform");
	var playtype = "";
	var count = "7";
	var splitCode = ",";
	var maxNum = "33";
	var balls = "";
	if ("SSQ" == lotteryType) {
		playtype = "ssqds";
		count = "7";
		maxNum = "33";
		splitCode = ",";
		if (flag == "mobilePurse") {
			form.action = root + "/stake/ssqMobilePurse.action";
		}
		if (flag == "mobileFee") {
			form.action = root + "/stake/ssqMobileFee.action";
		}
	}
	if ("D3" == lotteryType) {
		playtype = "d3dxds";
		count = "3";
		maxNum = "9";
		splitCode = ",";
		if (flag == "mobilePurse") {
			form.action = root + "/stake/3dMobilePurse.action";
		}
		if (flag == "mobileFee") {
			form.action = root + "/stake/3dMobileFee.action";
		}
	}
	if ("QLC" == lotteryType) {
		playtype = "qlcds";
		count = "7";
		maxNum = "30";
		splitCode = ",";
		if (flag == "mobilePurse") {
			form.action = root + "/stake/qlcMobilePurse.action";
		}
		if (flag == "mobileFee") {
			form.action = root + "/stake/qlcMobileFee.action";
		}
	}
	if ("C515" == lotteryType) {
		playtype = "c515ds";
		count = "5";
		maxNum = "15";
		splitCode = ",";
		if (flag == "mobilePurse") {
			form.action = root + "/stake/15x5MobilePurse.action";
		}
		if (flag == "mobileFee") {
			form.action = root + "/stake/15x5MobileFee.action";
		}
	}
	for (var i = 0; i < count; i++) {
		var codeball = document.getElementById("code" + maxNum + i).innerText;
		if (i > 0) {
		if("SSQ" == lotteryType&&i==(count-1)){
			balls += ":";
			}else{
			balls += splitCode;
			}
		}
		balls += codeball;
	}
	if (balls == "") {
		sAlert("\u8bf7\u5148\u83b7\u53d6\u5e78\u8fd0\u53f7\u7801");
		return false;
	}
	var regu = "\\d+";
	var re = new RegExp(regu);
	var flag =re.test(balls);
	if(!flag){
			sAlert("\u8bf7\u5148\u83b7\u53d6\u5e78\u8fd0\u53f7\u7801");
			return false;
		}
	
	form.lotteryId.value = lotteryType;
	form.stakesBalls.value = balls;	
	form.playType.value=playtype;
	form.submit();
}


