
$(function () {
	$("#materialTree ul").hide().prev("span").addClass("handle closed").click(function () {
		$(this).toggleClass("opened").nextAll("ul").toggle();
	});
	selectNode();
});
function selectNode() {
	$("#node_" + $("#nodeId").val()).parents("ul").show().addClass("opened");
}
$.fn.doCountDown = function (g, b) {
	$this = $("#" + g);
	if (b <= 0) {
		b = 0;
		if ($.data("timer")) {
			clearTimeout($.data("timer"));
			$this.html("\u5269\u4f59\u65f6\u95f4\uff1a\u5df2\u8fc7\u671f");
		}
	}
	var c = b % 60;
	var d = Math.floor(b / 60) % 60;
	var a = Math.floor(b / 60 / 60) % 24;
	var f = Math.floor(b / 60 / 60 / 24);
	$this.find("#days").html(f);
	$this.find("#minutes").html(d);
	$this.find("#hours").html(a);
	$this.find("#seconds").html(c);
	if (b > 0) {
		e = $this;
		t = setTimeout(function () {
			e.doCountDown(g, b - 1);
		}, 1000);
		$.data("timer", t);
	}
};
$.fn.inputComment = function (a) {
	$this = $(this);
	if (!a) {
		return $this.get(0) ? $this.get(0)["inputCommentString"] : "";
	}
	if ($this.get(0)) {
		$this.get(0)["inputCommentString"] = a;
	}
	if ($this.val() == "") {
		$this.val(a);
	}
	$this.addClass("inactive").val(a).focus(function () {
		$(this).removeClass("inactive");
		if ($(this).val() == a || "") {
			$(this).val("");
		}
	}).blur(function () {
		if ($(this).val() == "") {
			$(this).addClass("inactive");
			$(this).val(a);
		}
	});
};
$.fn.strLimit = function (a) {
	$(this).each(function () {
		$this = $(this);
		var b = 0;
		var c = 0;
		var f = $this.text();
		if (f.length > 0) {
			while ((c < a) && (b <= f.length)) {
				if ((f.charCodeAt(b) >= 0) && (f.charCodeAt(b) <= 255)) {
					c = c + 1;
				} else {
					c = c + 2;
				}
				if (c <= a) {
					b++;
				}
			}
		}
		var d = $this.text().substring(0, b);
		$this.text(d);
	});
};
function AddFavorite(a, c) {
	var b = $(a);
	option = {path:c || location.href, infood:b.attr("infood"), infotype:b.attr("infotype")};
	$.postJSON("/favorites/addFavorites/1-1.html", option, function (d) {
		if (d.success == false && d.usernull == true) {
			showUserLoginFast(function () {
				b.click();
			});
		} else {
			if (d.success == false) {
				alert("\u60a8\u6682\u65f6\u4e0d\u80fd\u8fdb\u884c\u6b64\u64cd\u4f5c\uff01");
			} else {
				if (d.success == true) {
					alert("\u6210\u529f\u52a0\u5165\u6536\u85cf\uff01");
				}
			}
		}
	});
}
function addFriends(a) {
	var b = $(a);
	option = {useridInfo:b.attr("userInfo")};
	$.postJSON("/favorites/addFriends/1-1.html", option, function (c) {
		if (c.success == false && c.usernull == true) {
			showUserLoginFast(function () {
				b.click();
			});
		} else {
			if (c.fall == "0") {
				alert("\u5bf9\u4e0d\u8d77,\u60a8\u4e0d\u80fd\u52a0\u81ea\u5df1\u4e3a\u5546\u53cb!");
			} else {
				if (c.fall == "1") {
					alert("\u5bf9\u4e0d\u8d77,\u60a8\u5df2\u7ecf\u52a0\u5165\u8fc7\u6b64\u5546\u53cb!");
				} else {
					if (c.success == true) {
						alert("\u6210\u529f\u52a0\u5165\u5546\u53cb\uff01");
					}
				}
			}
		}
	});
}
function AddFavoriteOld(a) {
	if (!a) {
		a = {sURL:location.href, sTitle:document.title};
	}
	if (!a.sURL) {
		a.sURL = location.href;
	}
	if (!a.sTitle) {
		a.sTitle = document.title;
	}
	try {
		window.external.addFavorite(a.sURL, a.sTitle);
	}
	catch (b) {
		try {
			window.sidebar.addPanel(a.sTitle, a.sURL, "");
		}
		catch (b) {
			alert("\u52a0\u5165\u6536\u85cf\u5931\u8d25\uff0c\u8bf7\u4f7f\u7528Ctrl+D\u8fdb\u884c\u6dfb\u52a0");
		}
	}
}
String.prototype.trim = function () {
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
$.fn.serializeObject = function () {
	var c = {};
	var b = this.serializeArray();
	$.each(b, function () {
		if (c[this.name]) {
			if (!c[this.name].push) {
				c[this.name] = [c[this.name]];
			}
			c[this.name].push(this.value || "");
		} else {
			c[this.name] = this.value || "";
		}
	});
	return c;
};
$.postJSON = function (a, b, c) {
	$.post(a, b, c, "json");
};
function showdate(b) {
	var a = new Date();
	if (b >= 30) {
		a.setMonth(a.getMonth() + (b / 30));
	} else {
		a.setDate(a.getDate() + parseInt(b));
	}
	a = a.getFullYear() + "-" + (a.getMonth() + 1) + "-" + a.getDate();
	return a;
}


//校验会员登录后会员可见联系方式 最新修改
function checkUserLogin() {
	$.postJSON("/favorites/userhomeOpen/1-1.html", null, function (result) {
		if (result && result.usernull == true) {
			showUserLoginFast(function () {
				location.reload();
			});
		} else {
			return false;
		}
	});
	return false;
}


