function intInput()		//----调整显示界面-----------------------------------
{
	with(document)
	{
		var strValue = intForm.selApply.value;

		if(strValue == 1)
		{
			getElementById("divIntegral").innerText = "奖品编号：";
			getElementById("numPrize").style.display = "";
			getElementById("numTime").style.display = "none";
			getElementById("selPrize").style.display = "";
		}
		else
		{
			getElementById("divIntegral").innerText = "VIP时间：";
			getElementById("numPrize").style.display = "none";
			getElementById("numTime").style.display = "";
			getElementById("selPrize").style.display = "none";
		}
	}
}

function shwIntegral()	//----选中奖品时显示所需要的积分-------------------------
{
	var objSel = document.getElementById("appPrize");
	var objSpan= document.getElementById("numIntegral");
	objSpan.innerHTML = "所需积分：" + objSel.options[objSel.selectedIndex].id;
}

function integralCheck(frm)
{
	if(frm.selApply.value == 0)
	{
		alert("请首先选择兑换的方式");
		frm.selApply.focus();
		return false;
	}
	else if(frm.selApply.value == 2)
	{
		var appTime = frm.appTime.value;
		alert(appTime);
		return false;
	}
	else if(frm.selApply.value == 1)
	{
		var appPrize = frm.appPrize.value;
		if(appPrize == "")
		{
			alert("请输入奖品编号");
			frm.appPrize.focus();
			return false;
		}
	}
	
	return true;
}

function applyHortationCard(id)	//----申请年终推广奖励卡------------------------------------------------
{
	showStatusDiv();
	var ajaxObj      = new AjaxFrame;
	ajaxObj.url      = "index.php?mod=Prize&action=applyHortationCard";
	ajaxObj.method   = "POST";
	ajaxObj.content  = "userid="+id;
	ajaxObj.callback = applyHortCardResult;
	ajaxObj.sendReq();
}
function applyHortCardResult(httpReq,objId)
{
	alert(httpReq.responseText);
	hideStatusDiv();
	window.location.reload();
}
function user_prizeApply()	//----确认后提交奖品申请--------------------------------------------------
{
	showStatusDiv();
	var frm = document.getElementById("applyPrizeForm");
	result = true;
	if(frm.appPrize.value == "")
	{
		alert("输入的奖品编号参数有错误");
		result = false;
	}
	else if (frm.appPrizeType.value == '3')
	{
		if (frm.txtBankId.value == "999")
		{
			alert("请先选择银行");
			frm.txtBankId.focus();
			result = false;
		}
		else if (frm.txtBankCard.value == "")
		{
			alert("银行卡号不能为空");
			frm.txtPayee.focus();
			result = false;
		}
		else if (frm.txtBankName.value == "")
		{
			alert("开户行不能为空");
			frm.txtPayee.focus();
			result = false;
		}
		else if (frm.txtBankAccount.value == "")
		{
			alert("户名不能为空");
			frm.txtPayee.focus();
			result = false;
		}
		else if (frm.txtTel.value == "")
		{
			alert("联系电话不能为空");
			frm.txtPayee.focus();
			result = false;
		}
	}
	else if (frm.appPrizeType.value != '2')
	{
		if(frm.txtPayee.value == "")
		{
			alert("收货人姓名不能为空");
			frm.txtPayee.focus();
			result = false;
		}
		else if(frm.txtAddr.value == "")
		{
			alert("联系地址不能为空");
			frm.txtAddr.focus();
			result = false;
		}
		else if(frm.txtTel.value == "")
		{
			alert("联系电话不能为空");
			frm.txtTel.focus();
			result = false;
		}
		else if(frm.txtPostcode.value == "")
		{
			alert("邮政编码不能为空");
			frm.txtPostcode.focus();
			result = false;
		}
		else if (frm.txtPostcode.value.length > 8)
		{
			alert('邮政编码格式错误');
			frm.txtPostcode.focus();
			result = false;
		}
	}
	re = /\D/;
	if (true == re.test(frm.txtCount.value) || frm.txtCount.value < 1)
	{
		alert('输入的奖品数量有误');
		frm.txtCount.focus();
		result = false;
	}

	if (false == result)
	{
		hideStatusDiv();
		return result;
	}
	
	var ajaxObj      = new AjaxFrame;
	ajaxObj.url      = "index.php?mod=Prize&action=prizeResult";
	ajaxObj.method   = "POST";
	ajaxObj.content  = fetchFormElements('applyPrizeForm');
	ajaxObj.callback = intMoneyResult;
	ajaxObj.sendReq();
	return false;
}

function fetchFormElements(form_name)
{
	str_data = '';
	form_id = document.forms[form_name];
	for (var i = 0; i < form_id.elements.length; i++)
	{
		str_data += '&' + form_id.elements[i].name + '=' + form_id.elements[i].value;
	}
	return str_data;
}

function intMoneyResult(httpReq,objId)
{
	var ajaxObj      = new AjaxFrame;
	ajaxObj.url      = "index.php?mod=Prize&action=displayUserInfo";
	ajaxObj.method   = "GET";
	ajaxObj.callback = function (html_data, tmp_obj_id) { document.getElementById("LoginStatus").innerHTML = html_data.responseText; };
	ajaxObj.sendReq();
	alert(httpReq.responseText);
	hideStatusDiv();
	ChangeGuideUrl("index.php?mod=Prize&action=displayApplyList");
}

function changeTypeAndOrder()
{
	type_value = document.getElementById('select_prize_type');
	order_value = document.getElementById('select_prize_order');
	url = 'index.php?mod=Prize&action=displayPrizeList';
	if (0 != type_value.value) url += '&type=' + type_value.value;
	if (0 != order_value.value) url += '&order=' + order_value.value;
	ChangeGuideUrl(url);
}

function getCardInfo()
{
	showStatusDiv();
	var ajaxObj      = new AjaxFrame;
	ajaxObj.url      = "index.php?mod=Prize&action=displayCardInfo";
	ajaxObj.method   = "POST";
	ajaxObj.content  = fetchFormElements('displayCardInfo');
	ajaxObj.callback = function (html_data,objId) {
		document.getElementById("webGuide").innerHTML = html_data.responseText;
		hideStatusDiv();
	};
	ajaxObj.sendReq();
}