
function updateCheckCode_leaveWord()
{
	if(document.getElementById("checkCode_leaveWord") != null){
		document.getElementById("checkCode_leaveWord").value = "";
		var obj = document.getElementById('checkCodeImg_leaveWord');
		obj.src="image2.jsp";
	}
}

function setNeedRegister(need){
	if(need == "Y"){
		document.getElementById("signUpNumber").disabled = "disabled";
		document.getElementById("signUpUserName").disabled = "disabled";
		document.getElementById("contactMobile").disabled = "disabled";
		document.getElementById("contactPhone").disabled = "disabled";
		document.getElementById("contactQQ").disabled = "disabled";
		if(document.getElementById("address") != null){
			document.getElementById("address").disabled = "disabled";
		}
	}
}

function accountDeliver(type,deliver,money,deliverMoney){
	alert("1");
	if(type == "2" && deliver == "Y"){
		var signUpNumber = document.getElementById("signUpNumber").value;
		if(signUpNumber * money >= deliverMoney){ 
			document.getElementById("addressDIV").style.display = "block";
		}else{
			document.getElementById("addressDIV").style.display = "none";
		}
	}
}

function checkSignUp(){

	var signUpNumber = document.getElementById("signUpNumber").value;
	var signUpUserName = trimString(document.getElementById("signUpUserName").value);
	var contactMobile = document.getElementById("contactMobile").value;

	var contactPhone = document.getElementById("contactPhone").value;
	var contactQQ = document.getElementById("contactQQ").value;
		
	var address =  "";
	if(document.getElementById("address") != null){
		address = trimString(document.getElementById("address").value);
	}
	
		
	//验证宝贝数量
	if (!checkSignUpNumber(signUpNumber)) {
		msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>报名数量填写不正确！</font>"});
		msgBox_alert.open();
		msgBox_alert.callback=function(args){
			document.getElementById("signUpNumber").focus();
			msgBox_alert.close();
		}
		return false;
	}
	//验证真实姓名	
	if (!checkSignUpUserName(signUpUserName)) {
		msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>真实姓名填写不正确！</font>"});
		msgBox_alert.open();
		msgBox_alert.callback=function(args){
			document.getElementById("signUpUserName").focus();
			msgBox_alert.close();
		}
		return false;
	}
	//验证联系手机
	if (!checkContactMobile(contactMobile)) {
		msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写联系手机号码！</font>"});
		msgBox_alert.open();
		msgBox_alert.callback=function(args){
			msgBox_alert.close();
			document.getElementById("contactMobile").focus();
		}
		return false;
	}	
	//验证联系固定电话
	if(contactPhone.length > 0){
		if (!checkContactPhone(contactPhone)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写联系固定电话！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("contactPhone").focus();
			}
			return false;
		}
	}
	//验证联系QQ
	if(contactQQ.length > 0){
		if (!checkContactQQ(contactQQ)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写联系QQ！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("contactQQ").focus();
			}
			return false;
		}
	}
	if(address.length > 0){
		if (!checkAddress(address)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写收货地址！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("address").focus();
			}
			return false;
		}
	}
	var checkCode = document.getElementById("checkCode").value;
	reg = /^[0-9A-Za-z]{1,4}$/;
	if(!reg.test(checkCode)){
		alert("请正确填写验证码！");
		document.getElementById("checkCode").focus();
		return false;
	}
	return true;
}
function checkSignUpNumber(value) {
	reg = /^\d{0,7}(\.\d{0,1})?$/;
	if (!reg.test(value) || value <= 0 || value >= 10000000) {
		return false;
	} else {
		return true;
	}
}
function checkSignUpUserName(value) {
	if(value.length <= 1 || value.length > 5){
		return false;
	}else{
		return true;
	}
}
function checkContactMobile(value){
	reg = /^1[3,5,8]\d{9}$/;
	if(!reg.test(value)){
		return false;
	}
	return true;
}
function checkContactPhone(value){
	reg = /^(\d{3,4}\-)?\d{7,8}$/;
	if(value.length > 0 && !reg.test(value)){
		return false;
	}
	return true;
}
function checkContactQQ(value){
	reg = /^[0-9]{4,22}$/;
	if(value.length > 0 && !reg.test(value)){
		return false;
	}
	return true;
}
function checkAddress(value){
	if(value.length > 100){
		return false;
	}
	return true;
}

function setPageNum(pageNum){
	document.getElementById("pageNum2").value=pageNum;
	document.getElementById("pageForm").action="campaign.jsp#campaignDIV";
	document.getElementById("pageForm").submit();
}
function setPageNum_apply(pageNum_apply){
	document.getElementById("pageNum_apply2").value=pageNum_apply;
	document.getElementById("pageForm").action="campaign.jsp#campaignApplyDIV";
	document.getElementById("pageForm").submit();
}



function showApplyTR(index){
	var tr = index + "_TR";
	var a = index + "_A"
	var style = document.getElementById(tr).style.display;
	if(style == "block"){
		document.getElementById(a).innerHTML = "+";
		document.getElementById(tr).style.display = "none";
	}else{
		document.getElementById(a).innerHTML = "－";
		document.getElementById(tr).style.display = "block";
	}
}


function orderByCampaignApply(orderBy){
	document.getElementById("orderBy2").value=orderBy;
	document.getElementById("pageForm").action="campaign.jsp#campaignApplyDIV";
	document.getElementById("pageForm").submit();	
}

function anonymityAbet(id){
	document.getElementById("applyID_abet").value=id;
	document.getElementById("abetForm").submit();	
}
function realAbet(id,name){
	document.getElementById("applyID_abet").value=id;
	document.getElementById("applyNameSpan").innerHTML=name;
	document.getElementById("abetFormDIV").style.display = "block";	
}

function checkRealAbet(){
	var abetUserName = document.getElementById("abetUserName").value;
	var abetMobile = document.getElementById("abetMobile").value;
	var abetPhone = document.getElementById("abetPhone").value;
	var abetQQ = document.getElementById("abetQQ").value;
	//验证真实姓名
	if(abetUserName.length > 0){
		if (!checkAbetUserName(abetUserName)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写真实姓名！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("abetUserName").focus();
			}
			return false;
		}
	}
	
	//验证联系手机
	if(abetMobile.length > 0){
		if (!checkAbetMobile(abetMobile)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写联系手机号码！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("abetMobile").focus();
			}
			return false;
		}
	}
	//验证联系固定电话
	if(abetPhone.length > 0){
		if (!checkAbetPhone(abetPhone)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写联系固定电话！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("abetPhone").focus();
			}
			return false;
		}
	}
	//验证联系QQ
	if(abetQQ.length > 0){
		if (!checkAbetQQ(abetQQ)) {
			msgBox_alert = new miniWindow({obj:"msgBox_alert",windowType:'alert',title:'系统提示：',hint:"<font color='red'>请正确填写联系QQ！</font>"});
			msgBox_alert.open();
			msgBox_alert.callback=function(args){
				msgBox_alert.close();
				document.getElementById("abetQQ").focus();
			}
			return false;
		}
	}
}

function checkAbetUserName(value) {
	if(trimString(value).length == 0 || value.length > 5){
		return false;
	}else{
		return true;
	}
}
function checkAbetMobile(value){
	reg = /^1[3,5,8]\d{9}$/;
	if(!reg.test(value)){
		return false;
	}
	return true;
}
function checkAbetPhone(value){
	reg = /^(\d{3,4}\-)?\d{7,8}$/;
	if(value.length > 0 && !reg.test(value)){
		return false;
	}
	return true;
}
function checkAbetQQ(value){
	reg = /^[0-9]{4,22}$/;
	if(value.length > 0 && !reg.test(value)){
		return false;
	}
	return true;
}