/*
 * Libairy 王庆川 effect: 用于辅助web前端的数据验证及填充
 */
var isAllowReg = false;
// Trim() , Ltrim() , RTrim()
String.prototype.Trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function() {
	return this.replace(/(^\s*)/g, "");
}
String.prototype.RTrim = function() {
	return this.replace(/(\s*$)/g, "");
}

// 异步通信对象
var xmlhttp;
// IE浏览参数
var isIE = true;
// 产品编号
var proNosMove = new Array();
// 创建异步请求对象
function createXMLHttpRequest() {

	if (window.XMLHttpRequest) // 非IE浏览器，用xmlhttprequest对象创建
	{
		xmlhttp = new XMLHttpRequest();
		isIE = false;
	} else if (window.ActiveXObject) // IE浏览器用activexobject对象创建
	{
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
	}
}
// 验证Email通讯
function getbackpassword() {
	var reg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
	var _txt=document.getElementById("userNo_id").value;
	var email=document.getElementById("userEmail_id").value;
email = email.replace(/(^\s*)|(\s*$)/g, "");
if(_txt!=''&&email!=null){

createXMLHttpRequest();
		xmlhttp.open("get", "getBackPassword.action?userNo=" + _txt+"&userEmail="+email);
		xmlhttp.onreadystatechange = getPasswordSeccess;
		xmlhttp.send(null);
}else{

alert("请将信息写正确");
}


}
// 异步对象回调函数
function getPasswordSeccess() {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
				var txt = xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g, "");
	if(txt=="success"){
           alert("你的密码已经发到你的邮箱请注意查收");
	}else{

alert("你的信息有无请重新输入");
	}

		}

	}

}


// 验证Email通讯
function validateEmail(_txt) {
	var reg = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
	_txt = _txt.replace(/(^\s*)|(\s*$)/g, "");
	if (!reg.test(_txt)) {
		document.getElementById("vemailTipc").style.display = "block";
		document.getElementById("vemailTipc").innerHTML = "请输入有效邮箱!";
		document.getElementById("vemailTipcImg").style.display = "none";
		isAllowReg = false;
	} else {
		document.getElementById("vemailTipcImg").style.display = "block";
		document.getElementById("vemailTipcImg").src = "images/accept.png";
		document.getElementById("vemailTipc").style.display = "none";
		isAllowReg = true;
	}
}
function ajaxCheckEMailCall() {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g, "");
			if (txt == "able") {
				document.getElementById("emailTipc").style.display = "none";
				document.getElementById("emailTipcImg").style.display = "block";
				document.getElementById("emailTipcImg").src = "images/accept.png";
				document.getElementById("emailTipcImg").alt = "恭喜！此用户名可以使用!";
				isAllowReg = true;
			} else {
				document.getElementById("emailTipc").style.display = "none";
				document.getElementById("emailTipcImg").style.display = "block";
				document.getElementById("emailTipcImg").src = "images/cross.png";
				document.getElementById("emailTipcImg").alt = "对不起！此用户名已被注册,请更换新用户名!";
				document.getElementById("userNo_Id").select();
				isAllowReg = false;
			}
		}
	}
}
// 后台验证email是否未被注册
function ajaxCheckEMail(_val) {
	if (_val.replace(/(^\s*)|(\s*$)/g, "").length == 0) {
		document.getElementById("emailTipc").style.display = "block";
		document.getElementById("emailTipc").innerHTML = "*必填";
		document.getElementById("emailTipcImg").style.display = "none";
		return;
	}
	if (validateEmail(_val)) {
		createXMLHttpRequest();
		xmlhttp.open("get", "validateEMail.action?vEMail=" + _val);
		xmlhttp.onreadystatechange = ajaxCheckEMailCall;
		xmlhttp.send(null);
	}
}

function ajaxCheckUser() {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText.replace(/(^\s*)|(\s*$)/g, "");
			if (txt == "able") {
				document.getElementById("emailTipc").style.display = "none";
				document.getElementById("emailTipcImg").style.display = "block";
				document.getElementById("emailTipcImg").src = "images/accept.png";
				document.getElementById("emailTipcImg").alt = "恭喜！此用户名可以使用!";
				isAllowReg = true;
				// document.getElementById("emailTipc").innerHTML = "此用户名可以使用!";
			} else {
				// document.getElementById("emailTipc").style.display = "none";
				// document.getElementById("emailTipcImg").style.display =
				// "block";
				// document.getElementById("emailTipcImg").src =
				// "images/cross.png";
				// document.getElementById("emailTipcImg").alt =
				// "对不起！此用户名已被注册,请更换新用户名!";
				document.getElementById("emailTipc").innerHTML = "此用户名已被注册!";
				document.getElementById("userNo_Id").select();
				isAllowReg = false;
			}
		}
	}
}

// 验证用户名
function ajaxCheckUserNo(_val) {

	if (_val.replace(/(^\s*)|(\s*$)/g, "").length == 0) {
		document.getElementById("emailTipc").style.display = "block";
		document.getElementById("emailTipc").innerHTML = "*必填";
		document.getElementById("emailTipcImg").style.display = "none";
		isAllowReg = false;
		return;
	}
	if (_val) {
		createXMLHttpRequest();
		xmlhttp.open("get", "vlidateUserNo.action?userNo=" + _val);
		xmlhttp.onreadystatechange = ajaxCheckUser;
		xmlhttp.send(null);
	}
}

// 登录密码文本框失去焦点事件
function pwdTipcONBlurs(_val) {
	if (_val.replace(/(^\s*)|(\s*$)/g, "").length == 0) {
		document.getElementById("pwdTipc").style.display = "block";
		document.getElementById("pwdTipc").innerHTML = "*必填";
		document.getElementById("pwdTipcImg").style.display = "none";
		isAllowReg = false;
		return;
	}
	if (_val.replace(/(^\s*)|(\s*$)/g, "").length < 6) {// 长度小于6
		// document.getElementById('pwdTipc').style.display = "none";
		// document.getElementById("pwdTipcImg").style.display = "block";
		// document.getElementById("pwdTipcImg").src = "images/cross.png";
		// document.getElementById("pwdTipcImg").alt = "对不起！密码位数应大于6!";
		document.getElementById('pwdTipc').innerHTML = "密码位数应大于6!";
		isAllowReg = false;
	} else {
		document.getElementById('pwdTipc').style.display = "none";
		document.getElementById("pwdTipcImg").style.display = "block";
		document.getElementById("pwdTipcImg").src = "images/accept.png";
		document.getElementById("pwdTipcImg").alt = "恭喜!密码输入正确!";
		isAllowReg = true;
	}
}
// 密码输入框的change事件
function pwdChange(_val) {
	var length = 45;
	if (_val.replace(/(^\s*)|(\s*$)/g, "").length > length) {// 大于length的位数就只取length位数的参数
		document.getElementById('userPwd_Id').value = _val.replace(
				/(^\s*)|(\s*$)/g, "").substring(0, length);

	} else {
		document.getElementById("pwdTipcImg").style.display = "none";
		document.getElementById('pwdTipc').style.display = "block";
		var count = 0;
		count = _val.replace(/(^\s*)|(\s*$)/g, "").length;
		document.getElementById("pwdTipc").innerHTML = "密码位数:" + count + "!";
	}
}
// common
function imgTipc(_imgId, src, alt, state) {
	document.getElementById(_imgId).style.display = state;
	document.getElementById(_imgId).src = src;
	document.getElementById(_imgId).alt = alt;
}

// 确认密码
function validateRPwd(_rpwd) {
	var pwd = document.getElementById('userPwd_Id').value;
	var rpwd = _rpwd.replace(/(^\s*)|(\s*$)/g, "");
	// 空值
	if (rpwd.length == 0) {
		document.getElementById('rpwdTipc').style.display = "block";
		document.getElementById("rpwdTipc").innerHTML = "*必填";
		document.getElementById("rpwdTipcImg").style.display = "none";
		isAllowReg = false;
		return false;
	}
	if (pwd != rpwd) {
		document.getElementById('rpwdTipc').style.display = "block";
		document.getElementById('rpwdTipc').innerHTML = "*请与密码一致!";
		document.getElementById('rpwdTipcImg').style.display = "none";
		isAllowReg = false;
		return false;
	} else {
		document.getElementById('rpwdTipc').style.display = "none";
		imgTipc("rpwdTipcImg", "images/accept.png", "确认密码输入正确!", "block");
		isAllowReg = true;
		return true;
	}
}
/**
 * 验证用户是否同意协议
 */
function agreeCKXEvent(_ckd) {
	if (_ckd) {// 同意,提交按钮可用
		document.getElementById('regSubmitBtn').removeAttribute("disabled");
	} else {// 提交按钮灰化
		document.getElementById('regSubmitBtn').disabled = true;

	}
}

// 异步对象回调函数
function HandleStateChange() {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var xml = xmlhttp.responseXML;
			// 获得根节点
			var topNod = xml.documentElement;
			// 类似这样去遍历XML的数据，然后给DOM赋值
			var area = xml.getElementsByTagName("area");
			var op = document.createElement("option");
			op.text = "---未知---";
			op.value = -1;
			document.getElementById("city_Id").options.add(op);
			// 循环添加select option 项
			for (var i = 0; i < area.length; i++) {
				var key = area[i].getElementsByTagName("key")[0].firstChild.data;
				var value = area[i].getElementsByTagName("value")[0].firstChild.data;
				var option = document.createElement("option");
				option.text = key;
				option.value = value;
				document.getElementById("city_Id").options.add(option);
				// document.getElementById("SmallClassName").options.add(new
				// Option(text,value));
			}

		}
	}
}

/**
 * 所在城市下拉框联动
 */
function cityLianMove(_val) {

	// 将城市下拉列表框先清空
	var targetCb = document.getElementById('city_Id');
	for (var i = targetCb.options.length; i >= 0; i--) {
		if (isIE) {
			document.getElementById("city_Id").options.remove(i);
		} else {
			document.getElementById("city_Id").remove(i);
		}
	}
	// 执行异步
	if (_val == -1) {
		var op = document.createElement("option");
		op.text = "---未知---";
		op.value = -1;
		targetCb.options.add(op);
	} else {
		createXMLHttpRequest();
		xmlhttp.open("get", "AresBPID.action?pId=" + _val);
		xmlhttp.onreadystatechange = HandleStateChange;
		xmlhttp.send(null);
	}
}
/*
 * 验证必填项
 */
function requireValidate(_val) {
	var array = _val.split(',');
	var isOk = true;
	for (var i = 0; i < array.length; i++) {
		var value = document.getElementById(array[i]).value.replace(
				/(^\s*)|(\s*$)/g, "");
		if (value.length == 0) {
			alert("信息输入不完整!请检查必填项");
			isOk = false;
			break;
		}
	}
	if (isOk) {
		// 验证密码是否一致
		var rpwd = document.getElementById('ruserPwd_Id').value;
		if (validateRPwd(rpwd)) {
			isOk = true;
		} else {
			alert("确认密码请与密码一致！");
			isOk = false;
		}
		if (!isAllowReg) {
			alert('请检查必填项是否正确!');
			return false;
		}
	}
	return isOk;
}
/**
 * 验证用户登录
 */
function requireLogVal() {
	var name = document.getElementById('lgUNo').value.replace(/(^\s*)|(\s*$)/g,
			"");
	var pwd = document.getElementById('lgUPWD').value.replace(/(^\s*)|(\s*$)/g,
			"");
	var  yzCode= document.getElementById('yzCode').value.replace(/(^\s*)|(\s*$)/g,
			"");
	// 姓名为空了
	if (name.length == 0) {
		alert('请输入用户名!');
		document.getElementById('lgUNo').focus();
		document.getElementById('lgUNo').select();
		return false;
	}
	if (pwd.length == 0) {
		alert('请输入登录密码!');
		document.getElementById('lgUPWD').focus();
		document.getElementById('lgUPWD').select();
		return false;
	}
		if (yzCode.length == 0) {
		alert('请输入验证码!');
		document.getElementById('lgUPWD').focus();
		document.getElementById('lgUPWD').select();
		return false;
	}
saveUserInfo();

	return true;
}
function  freshCode(){

	createXMLHttpRequest();
		xmlhttp.open("get", "getCode.action");
		xmlhttp.onreadystatechange = isSuceessgetCode;
		xmlhttp.send(null);
}
function isSuceessgetCode() {

	
		document.getElementById("yangzhengpic").src="getCode.action";

	
}
function checkYanzheng() {

	var yz = document.getElementById("yzCode");
	
		createXMLHttpRequest();
		xmlhttp.open("get", "checkYzCode.action?yzCode=" + escape(yz.value));
		xmlhttp.onreadystatechange = isSuceessYzcode;
		xmlhttp.send(null);
}
function isSuceessYzcode() {

	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText;
			if (txt.replace(/(^\s*)|(\s*$)/g, "") == "true") {
				document.getElementById('sub_login_id').disabled=false;
			} else {
			alert("请输入正确的验证码!");
				document.getElementById('sub_login_id').disabled=true;
			}

		}
	}
}
/**
 * 添加商品的回调函数
 */
function callBackJoinSC() {

	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText;
			if (txt.replace(/(^\s*)|(\s*$)/g, "") == "true") {
				alert("成功将商品添加到购物车!");
			} else {
				alert("添加商品到购物车失败!");
			}

		}
	}
}

/**
 * 将商品添加到购物车
 */
function joinShopCart(proId) {

	var countobj = document.getElementById("itemCount");
	var count = '1';
	if (countobj) {
		count = countobj.value;
	}
	if (count.replace(/(^\s*)|(\s*$)/g, "").length == 0) {
		// alert("请输入所需商品数数量");
		// document.getElementById("itemCount").focus();
		// document.getElementById("itemCount").select();
		count = '1';
	} else {
		createXMLHttpRequest();
		xmlhttp.open("get", "ajaxJoinSCart.action?n=" + escape(new Date())
						+ "&proNo=" + proId + "&proCount=" + count);
		xmlhttp.onreadystatechange = callBackJoinSC;
		xmlhttp.send(null);
	}
}

/**
 * 编辑商品数量的回调函数
 */
function callBackModityPST(count, price) {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText;
			if (txt.replace(/(^\s*)|(\s*$)/g, "") == "true") {
				if (!count) {
					count = 0;
				}
				document.getElementById('subtotal_id').innerHTML = "￥"
						+ (parseInt(count) * parseInt(price));

			} else {
				alert("商品数量编辑失败!");
			}
		}
	}
}
/**
 * 修改购物车中商品数量
 */
function modityProductQt(count, _value, price) {

	if (isNaN(count)) {
		alert('请输入数字');
		document.getElementById('pdtcount_id').value = '';
		count = 0;
	}
	var url = "ajaxModitySCart.action?n=" + escape(new Date()) + "&proNo="
			+ _value + "&count=" + count;
	createXMLHttpRequest();
	xmlhttp.open("get", url);
	xmlhttp.onreadystatechange = function() {
		callBackModityPST(count, price)
	};
	xmlhttp.send(null);

}
/**

会员退出

**/
function logoutdo() {

	
	var url ="logout.action?option=rdt";
	createXMLHttpRequest();
	xmlhttp.open("get", url);
	xmlhttp.onreadystatechange =logoutSeccess;
	xmlhttp.send(null);

}
var  islogout="false";
function logoutSeccess() {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		
		if (xmlhttp.status == 200) {
			var exp = new Date(); 
exp.setTime(exp.getTime() - 1); 
var userName = document.cookie.match(new RegExp("(^| )UserName=([^;]*)(;|$)")); 

var  userN=userName[2];

if(userName!=null) document.cookie= "UserName" + "="+userN+";expires="+exp.toGMTString(); 

var cvalPass=document.cookie.match(new RegExp("(^| )"+userN+"=([^;]*)(;|$)")); 

if(cvalPass!=null) document.cookie= userN + "="+cvalPass[2]+";expires="+exp.toGMTString(); 

		}
	}
}

/**
 * 删除商品的回调函数
 */
function callBackRemovePST() {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText;
			if (txt.replace(/(^\s*)|(\s*$)/g, "") == "true") {
				alert("商品数量删除成功!");
			} else {
				alert("商品数量删除失败!");
			}
		}
	}
}
/**
 * 删除指定购物车中商品
 */
function removeProduct() {

	// 获取被选中的checkbox
	var obj = document.getElementsByName('shopcart_chk_Name');
	var qiandao = '';
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked == true) {
			qiandao = qiandao + obj[i].value + ',';
		}
	}
	if (qiandao.length == 0) {
		alert("请选择要删除的商品条目!");
		return;
	}
	qiandao = qiandao.substring(0, qiandao.length - 1);

	var url = "ajaxRemoveCItme.action?n=" + escape(new Date()) + "&proNo="
			+ qiandao;
	createXMLHttpRequest();
	xmlhttp.open("get", url);
	xmlhttp.onreadystatechange = callBackRemovePST;
	xmlhttp.send(null);

	location.reload();

}

// checkbox集合的全选即取消
function checkBoxAllOption(_value) {
	var obj = document.getElementsByName('shopcart_chk_Name');
	for (var i = 0; i < obj.length; i++) {
		obj[i].checked = _value;
	}
}

// 删除收货人信息
function deleteBCongnees() {
	// 组织数据
	var obj = document.getElementsByName('congneechk');
	var cid = document.getElementById("chkhiddencid").value;
	var bcId = '';
	var isdo = false;
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked == true) {
			bcId = bcId + obj[i].value + ',';
			isdo = true;
		}
	}
	// 是否执行删除
	if (!isdo) {
		alert("请选择要删除的商品条目!");
		return;
	}
	// 执行删除
	window.location = 'deleteBCgn.action?cusId=' + cid + '&bcId=' + bcId;
}
// 保存订单
function saveBillSell() {

	var rdios = document.getElementsByName("cnradio");
	var rd;
	for (var i = 0; i < rdios.length; i++) {
		if (rdios[i].checked == true) {
			rd = rdios[i].value;
		}
	}
	document.getElementById('consignIdHidden').value = rd;
	document.getElementById('svbillform').submit();
}
// ---------------------------------------------------------------------------异步级联问题类型begin

// 异步对象回调函数
function ajaxLinkAgeQuesCateHandleStateChange(tid) {
	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var xmlt = xmlhttp.responseXML;
			// 获得根节点
			var topNod = xmlt.documentElement;
			// 类似这样去遍历XML的数据，然后给DOM赋值
			var area = xmlt.getElementsByTagName("BQuestionCategory");
			var op = document.createElement("option");
			op.text = "---未知---";
			op.value = -1;
			document.getElementById(tid).options.add(op);
			// 循环添加select option 项
			for (var i = 0; i < area.length; i++) {
				var key = area[i].getElementsByTagName("name")[0].firstChild.data;
				var value = area[i].getElementsByTagName("value")[0].firstChild.data;
				var option = document.createElement("option");
				option.text = key;
				option.value = value;
				document.getElementById(tid).options.add(option);
				// document.getElementById("SmallClassName").options.add(new
				// Option(text,value));
			}

		}
	}
}

/**
 * 所在城市下拉框联动 arg1 arg2 _val select选中的值
 */
function ajaxLinkAgeQuesCate(arg1, arg2, _val) {

	// 将城市下拉列表框先清空
	var targetarg1 = document.getElementById(arg1);
	var targetarg2 = document.getElementById(arg2);

	for (var i = targetarg1.options.length; i >= 0; i--) {
		try {
			targetarg1.options.remove(i);
		} catch (e) {
			targetarg1.remove(i);
		}
	}
	for (var i = targetarg2.options.length; i >= 0; i--) {
		try {
			targetarg2.options.remove(i);
		} catch (e) {
			targetarg2.remove(i);
		}
	}
	// 执行异步
	if (_val == -1) {
		var op = document.createElement("option");
		op.text = "---未知---";
		op.value = -1;
		targetarg1.options.add(op);
		targetarg2.options.add(op);
	} else {
		createXMLHttpRequest();
		xmlhttp.open("get", "ajaxGetQCAteData.action?qcateid=" + _val);
		xmlhttp.onreadystatechange = function() {
			ajaxLinkAgeQuesCateHandleStateChange(arg1);
		};
		xmlhttp.send(null);
	}
}
// ---------------------------------------------------------------------------异步级联问题类型end
// 验证悬赏分数
function validatePriz(arg1, arg2) {
	var t1 = document.getElementById(arg1).value;
	var t2 = document.getElementById(arg2).value;

	if (isNaN(t1))
		return false;
	if (isNaN(t2))
		return false;

	if (!t1) {
		t1 = 0;
	}// 无分数

	t1 = parseInt(t1);
	t2 = parseInt(t2);

	if (t1 > t2) {
		alert("对不起！你的积分不够支付此次提问悬赏!");
		document.getElementById(arg1).select();
		return false;
	} else {
		return true;
	}
}
// -----------------答案回复
function expandRep(divId) {
	// div object
	var divobj = document.getElementById('part_pl_id' + divId);
	var dis = divobj.style.display;
	// img object
	var imgobj = document.getElementById('img_part_pl_id' + divId);
	// 闭合 & 展开
	if (dis == "none") {
		imgobj.src = "images/img_expand.gif";
		divobj.style.display = "block";
	} else {
		imgobj.src = "images/img_expand_r.gif";
		divobj.style.display = "none";
	}
}

// 调节搜索项
function validateDatumSerch() {

	var cols = document.getElementsByName("columname");
	var param;
	for (var i = 0; i < cols.length; i++) {
		if (cols[i].checked) {
			param = cols[i].value;
			break;
		}
	}
	if (param == 'datum') {
		document.getElementById('search_form_index').action = 'souinnav.action';
	}
	return true;
}
// lddate

function CalDays(year, month) {
	var days = 0;
	switch (month) {
		case 1 :
		case 3 :
		case 5 :
		case 7 :
		case 8 :
		case 10 :
		case 12 :
			days = 31;
			break;
		case 4 :
		case 6 :
		case 9 :
		case 11 :
			days = 30;
			break;
		case 2 :
			if (isLeapYear(year))
				days = 29;
			else
				days = 28;
			break;
	}
	return days;
	// var date = new Date(year, month, 0);
	// return date.getDate();
}

function isLeapYear(year) {
	if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
		return true;
	else
		return false;
}
// 日期联动验证闰年
function lddate() {
	// 获取参数对象
	var ryear = document.getElementById('reg_year_id');
	var rmonth = document.getElementById('reg_month_id');
	var rday = document.getElementById('reg_day_id');
	//
	var year = parseInt(ryear.value);
	var month = parseInt(rmonth.value);
	var days = CalDays(year, month);
	// 清空day的select option
	for (var i = rday.options.length; i >= 0; i--) {
		try {
			rday.options.remove(i);
		} catch (e) {
			rday.remove(i);
		}
	}
	for (var i = 1; i <= days; i++) {
		var option = document.createElement("option");
		option.text = i;
		option.value = i;
		document.getElementById('reg_day_id').options.add(option);
	}
}
// 处理投票操作
function callBackProcessPoll() {

	// 回掉函数
	if (xmlhttp.readyState == 4) {
		// 请求成功
		if (xmlhttp.status == 200) {
			var txt = xmlhttp.responseText;
			if (txt != 'error') {
				document.getElementById('grantval').innerHTML = txt;
				document.getElementById('grantansdiv_id').disable = true;
			}
		}
	}
}
// 执行最佳答案的投票操作
function ajaxdopoll(_ansid) {
	// 获取答案编号
	var url = "dopoll.action?proname=1&ansId=" + _ansid;
	createXMLHttpRequest();
	xmlhttp.open("get", url);
	xmlhttp.onreadystatechange = callBackProcessPoll;
	xmlhttp.send(null);
}
// 订单确认的收货人折叠
function dispalyRecAct(_val) {

	if (_val == 'addconsign') {
		document.getElementById('addsingmandiv_id').style.display = 'block';
	} else {
		document.getElementById('addsingmandiv_id').style.display = 'none';
	}
}
// 用于打开/关闭指定div
function expandDialog(id) {
	var divobj = document.getElementById(id);
	var dis = divobj.style.display;

	if (dis == "none") {
		
		document.getElementById('fade').style.display='block';
		divobj.style.display = "block";
	} else{
		document.getElementById('fade').style.display='none';
		divobj.style.display = "none";
	}


}

function expandDialogImg(id) {

	var divobj = document.getElementById(id);
	var dis = divobj.style.display;

	if (dis == "none") {
		divobj.style.display = "block";
		document.getElementById(id + "_img").src = "img/answdown.gif";
	} else {
		divobj.style.display = "none";
		document.getElementById(id + "_img").src = "img/answup.gif";
	}

}

// 验证评论文本域
function validateTxtArea(val) {
	var value = val.value;
	value = value.replace(/\s/g, "");
	if (value == "请输入您想说的话!") {
		val.value = "";
	}
}

// 验证回复不能为空
function validateReplay(id) {
	var val = document.getElementById(id);
	var value = val.value.replace(/\s/g, "");
	if (value == "") {
		alert("请输入您要说的话!");
		val.focus();
		return false;
	} else if (value.length < 5) {
		alert("回复字数不能低于5个!");
		val.focus();
		val.select();
		return false;
	}
	return true;
}

function editAnswer(id) {
	var val = document.getElementById(id);
	var value = val.value.replace(/\s/g, "");
	if (value == "") {
		alert("答案不能为空!");
		val.focus();
		return false;
	} else if (value.length < 5) {
		alert("回答字数不能低于5个！");
		val.focus();
		val.select();
		return false;
	}
	return true;
}

function clearDefECom(val) {
	var value = val.value;
	value = value.replace(/\s/g, "");
	if (value == "我觉得问题和答案都不错!") {
		val.value = "";
	}
}

function validateExpertComment(id) {
	var val = document.getElementById(id);
	var value = val.value;
	value = value.replace(/\s/g, "");
	if (value == "") {
		alert("请认真点评问题和游客的回答!");
		val.focus();
		return false;
	} else if (value.length < 5) {
		alert("点评字数不能低于5个");
		val.focus();
		val.select();
		return false;
	}
	return true;
}

function validateAnswer(id) {
	//var val = document.getElementById(id);
	//var value = val.value;
	//value = value.replace(/\s/g, "");
	//if (value == "") {
		//alert("请认真回答楼主的问题!");
		//val.focus();
		//return false;
	///} else if (value.length < 5) {
		//alert("回答字数不能低于5个!");
		//val.focus();
		//val.select();
	//	return false;
	//}
	return true;
}
function anSwerTwo(div) {
	//window.location="http://www.fire114.cn/explorerui/iask/quiz.html";
	window.location="http://www.fire114.cn/iask/quiz.html";
	/*
	if (window.XMLHttpRequest) {
		javascript : window.location.href = 'iask/quiz.html';
	}// 在IE浏览器中创建一个XMLHttpRequest对象实例
	else {
		var urlName="quiz.html";
		switch(div){
			case 1:
			urlName="iask/quiz.html";
			break;
			case 2:
			urlName="quiz.html";
			break;
			case 3:
			urlName="../quiz.html";
			break;
			case 4:
			urlName="../../quiz.html";
			break;
			default:
			urlName="quiz.html";
		}
	
		javascript : window.location.href =urlName;
	}
	*/
}
// 浏览器判断
function anSWer() {
	//window.location="http://localhost:8088/iask/quiz.html";
	window.location="http://www.fire114.cn/iask/quiz.html";
	/*
	if (window.XMLHttpRequest) {
		javascript : window.location.href = 'iask/quiz.html';

	}// 在IE浏览器中创建一个XMLHttpRequest对象实例
	else {

		javascript : window.location.href = 'quiz.html';

	}
	/*
	 * var Sys = {}; var ua = navigator.userAgent.toLowerCase(); if
	 * (window.ActiveXObject) Sys.ie = ua.match(/msie ([\d.]+)/)[1] else if
	 * (document.getBoxObjectFor) Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1]
	 * else if (window.MessageEvent && !document.getBoxObjectFor) Sys.chrome =
	 * ua.match(/chrome\/([\d.]+)/)[1] else if (window.opera) Sys.opera =
	 * ua.match(/opera.([\d.]+)/)[1] else if (window.openDatabase) Sys.safari =
	 * ua.match(/version\/([\d.]+)/)[1];
	 * 
	 * //以下进行测试 if(Sys.ie) alert('IE: '+Sys.ie); if(Sys.firefox) alert('Firefox:
	 * '+Sys.firefox); if(Sys.chrome) alert('Chrome: '+Sys.chrome);
	 * if(Sys.opera) alert('Opera: '+Sys.opera); if(Sys.safari) alert('Safari:
	 * '+Sys.safari);
	 * 
	 * //javascript:window.location.href='iask/quiz.html
	 * 
	 */
	/*
	 * function userBrowser(){ var
	 * browserName=navigator.userAgent.toLowerCase();
	 * if(/msie/i.test(browserName) && !/opera/.test(browserName)){ alert("IE");
	 * return ; }else if(/firefox/i.test(browserName)){ alert("Firefox"); return ;
	 * }else if(/chrome/i.test(browserName) && /webkit/i.test(browserName) &&
	 * /mozilla/i.test(browserName)){ alert("Chrome"); return ; }else
	 * if(/opera/i.test(browserName)){ alert("Opera"); return ; }else
	 * if(/webkit/i.test(browserName) &&!(/chrome/i.test(browserName) &&
	 * /webkit/i.test(browserName) && /mozilla/i.test(browserName))){
	 * alert("Safari"); return ; }else{ alert("unKnow"); } }
	 * 
	 */

}

function myAnswer(id) {
				javascript : window.location.href ="http://www.fire114.cn/"+'iask/questions/detail/' + id
				+ '#ANS';
	/*
	if (window.XMLHttpRequest) {
			javascript : window.location.href =id + '#ANS';
	}// 在IE浏览器中创建一个XMLHttpRequest对象实例
	else {
		javascript : window.location.href = 'iask/questions/detail/' + id
				+ '#ANS';
	}
	*/
}
//搜索答案
function isSearch(questionId){
	var question=document.getElementById(questionId).value;
	if(question.length>0){
		return true;
	}else{
		alert('请您输入搜索问题！');
		return false;
	}
}



function toAnswer(){
	window.location.href="logon";
}

function checkchan(){
if(document.getElementById("ischakan").value!="true"){
alert("你没有权限查看他的资料请返回");
history.back(-1);

}
}
function SetCookie(name,value)//两个参数，一个是cookie的名子，一个是值 
{ 
	var Days = 30; 
var exp = new Date(); //new Date("December 31, 9998"); 
exp.setTime(exp.getTime() + Days*24*60*60*1000); //此 cookie 将被保存 30 天 
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString(); 
}// escape拿来干嘛？记住解决中文问题的。 
//上面就算新定义了一个cookie 
//取cookies函数 
function getCookie() 
{



} 

function delCookie(name) 
{ 
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); 
var exp = new Date(); 
exp.setTime(exp.getTime() - 1); 
var cval=unescape(arr[2]);
if(cval!=null) document.cookie= name + "="+cval+";expires=0"; 
} 

function changeCookie(){

var UserName=document.getElementById("lgUNo").value;
var passwords=document.getElementById("lgUPWD").value;
var issave=document.getElementById("savapwd");

if(issave.checked){
SetCookie(UserName,passwords);
}else{
delCookie(UserName);
}
}


function antoLogin(){
	//var option=document.getElementById("User_Name_id");
	//alert(option.value);
	//if(option==null){
var arr = document.cookie.match(new RegExp("(^| )"+'fire114_UserName'+"=([^;]*)(;|$)")); 

if(arr!=null&&document.getElementById("User_Name_id").value==""){
var  Username=unescape(arr[2]);
var   password;

var arrpwd = document.cookie.match(new RegExp("(^| )fire114_pwd=([^;]*)(;|$)"));
if(arrpwd!=null){
password=unescape(arrpwd[2]);
location.href="validateLogin.action?uiuser.userNo="+Username+"&uiuser.userPwd="+password+"&isauto=true&option=showIASK";
}
}else{

return;
}
	//}else{
//return;
//	}
}

function saveUserInfo(){

if(confirm("是否不存密码下次自动登录")){
var UserName=document.getElementById("lgUNo").value;
var passwords=document.getElementById("lgUPWD").value;
SetCookie("fire114_UserName",UserName);
SetCookie("fire114_pwd",passwords);
}

}

function  logout_id(){
var arr = document.cookie.match(new RegExp("(^| )"+'fire114_UserName'+"=([^;]*)(;|$)")); 

if(arr!=null){
delCookie("fire114_UserName");
delCookie("fire114_pwd");

}
//window.location.href="exit";
}



function adddate(){

var today=new Date();
var year=(today.getYear() > 200) ? today.getYear() : 1900 + today.getYear();
var day=today.getDate();

var showday;

var month=today.getMonth()+1;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
showday=31;
}else if(month==4||month==6||month==9||month==11){

showday=30;
}else if(month==2){

showday=28;
}

var optionstr="";

var zhengday=day;
var  jiemonth=""+month;
if(month<10){
jiemonth="0"+month;

}

for (var i =0; i<day; i++) {
	var option1 = document.createElement("option");
	if(zhengday<10){
option1.text = year+"-"+jiemonth+"-0"+zhengday;
option1.value ="%"+year+"-"+jiemonth+"-0"+zhengday+"%";
	}else{
	option1.text =year+"-"+jiemonth+"-"+zhengday;
option1.value ="%"+year+"-"+jiemonth+"-"+zhengday+"%";
	
	}
document.getElementById("dateoption_id").options.add(option1);
zhengday--;
}


var chaday=showday-day;
if(chaday>0){

var neshowday=0;
var newmonth=month-1;
var  jiesmonth=""+newmonth;
if(month<10){
jiesmonth="0"+newmonth;

}
if(newmonth==6||newmonth==9||newmonth==11||newmonth==4){
neshowday=30;
}else if (newmonth==1||newmonth==3||newmonth==5||newmonth==7||newmonth==8||newmonth==10||newmonth==12)
{neshowday=31;
}else if(newmonth==2)
{
	neshowday=28
	
	}

for(var i=0;i<chaday;i++){
		var option = document.createElement("option");
				
				
	if(neshowday<10){
		
	option.value ="%"+year+"-"+jiesmonth+"-0"+neshowday+"%";
				option.text =year+"-"+jiesmonth+"-0"+neshowday;
	}else{
		option.text =year+"-"+jiesmonth+"-"+neshowday;
				option.value ="%"+year+"-"+jiesmonth+"-"+neshowday+"%";

	}
	document.getElementById("dateoption_id").options.add(option);
neshowday--;


}

}


}