var ctx = "";
var tempM = false;
var tempP = false;
$(document).ready( function() {
	ctx = $("#ctx").val();
	if (!ctx)ctx = "";
	loadall();
	initpic();
	init();
	$("#mensize img").click(chooseSize);
	$(".jqzoom").jqueryzoom( {
		xzoom :245,
		yzoom :245,
		offset :-200,
		position :"right"
	});
	$(".qqServices").mousemove(qqOver);
	$(".qqServices").click(qqClick)
});
function loadall() {
	$("#subcart").click(subProduct);
	$("#product").blur(checkNum);
	displaydesc();
	$("#prodesc2").hide();
	closezx();
	initment();
	initpve()
}
function chooseSize() {
	var g = $(this).attr("src").indexOf("on.gif");
	var j = $(this).attr("id");
	var h = "";
	var f = "";
	var i = 0;
	if (g != -1) {
		$("#mensize img")
				.each(
						function() {
							h = $(this).attr("src");
							if (h.indexOf("act.gif") != -1) {
								f = ctx
										+ "/page/web/product/ProductInfo/css/images/icon/size-"
										+ $(this).attr("id") + "-on.gif";
								$(this).attr("src", f)
							}
						});
		$("#" + j).attr(
				"src",
				ctx + "/page/web/product/ProductInfo/css/images/icon/size-" + j
						+ "-act.gif");
		i = $("#num" + j).val();
		$("#pronumsize").val(j);
		$("#product").val("1");
		$("#num").val("1");
		if (i > 5) {
			$("#maxnum").html(" \u6700\u5927\u8ba2\u8d2d\u91cf5")
		} else {
			$("#maxnum").html(" \u6700\u5927\u8ba2\u8d2d\u91cf" + i)
		}
	}
	return
}
function subProduct() {
	if (checkNum()) {
		var d = ctx + "/page/web/cart/CartInfo/cart.jsp";
		var c = "&action=addCart&pid=" + $("#productnum").val() + "&size="
				+ $("#pronumsize").val() + "&num=" + $("#product").val();
		$.post(d, c, callback);
	}
	return;
}
function callback(b) {
	window.location.href = ctx + "/page/web/cart/CartInfo/productCart.do";
}
function checkNum() {
	var e = parseInt(Number($("#product").val()));
	var h = "0";
	var f = 0;
	var g = $("#cId").val();
	var d = $("#sizesum tr").length;
	if (g == "12"||g =="11") {
		if (d <= 1) {
			h = $("#sumSize").val();
			$("#pronumsize").val(h)
		}
	}
	h = $("#pronumsize").val();
	f = Number($("#num" + h).val());
	return checkshose(f, e, h)
}
function checkshose(e, d, f) {
	if (isNaN(d) || d < 1) {
		d = 1;
		$("#product").val(d)
	}
	if (f != 0) {
		if (d > 5) {
			alert("\u6700\u591a\u53ea\u80fd\u8d2d\u4e70\u4e94\u53cc");
			$("#product").val(5);
			d = 5;
			return false
		} else {
			if (d > e) {
				alert("\u5bf9\u4e0d\u8d77\u8be5\u7801\u53ea\u5269" + e
						+ "\u53cc");
				$("#product").val(e);
				d = e;
				return false
			}
		}
		$("#num").val(d)
	} else {
		alert("\u8bf7\u9009\u62e9\u5c3a\u7801");
		return false
	}
	return true
}
function displaydesc() {
	$("#tabmenu_8").mousemove(function() {
		$("#proTitle .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#prodesc2").hide();
		$("#prodesc3").hide();
		$("#prodesc1").show();
		$("#prodesc4").hide()
	});
	$("#tabmenu_9").mousemove( function() {
		$("#proTitle   .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#prodesc1").hide();
		$("#prodesc3").hide();
		$("#prodesc2").show();
		$("#prodesc4").hide()
	});
	$("#tabmenu_10").mousemove( function() {
		$("#proTitle   .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#prodesc1").hide();
		$("#prodesc3").show();
		$("#prodesc2").hide();
		$("#prodesc4").hide()
	});
	$("#tabmenu_15").mousemove(function(){
		$("#proTitle   .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#prodesc1").hide();
		$("#prodesc2").hide();
		$("#prodesc3").hide();
		$("#prodesc4").show()
	})
}
function initment() {
	$("#showment tr:gt(11)").hide();
	$("#shAM").click( function() {
		if (tempM != true) {
			$("#showment tr:gt(11)").show();
			tempM = true
		} else {
			tempM = false;
			$("#showment tr:gt(11)").hide()
		}
	})
}
function closezx() {
	$("#doment").click( function() {
		var offset=$(this).offset();
		$("#ment").css("top",offset.top+20).css("left",offset.left-($("#ment").width()/2)+20).toggle()
	});
	$("#closment").click( function() {
		$("#ment").hide()
	});
	$("#addment").click(addment);
	$("#menttitle").focus( function() {
		$(this).val("")
	});
	$("#content").focus( function() {
		$(this).val("")
	})
}
function addment() {
	var g = ctx + "/page/web/product/ProductInfo/product.do";
	var j = $("#content").val();
	var f = $("#menttitle").val();
	f = respaceStr(f);
	j = respaceStr(j);
	if (f.length < 1
			|| $("#menttitle").val() == "\u8bf7\u8f93\u5165\u6807\u9898..") {
		alert("\u60a8\u672a\u8f93\u5165\u6807\u9898!");
		return
	}
	if (j.length < 5 || $("#content").val() == "\u6211\u8981\u8bc4\u8bba..") {
		alert("\u8bf7\u8f93\u5165\u66f4\u8be6\u7ec6\u7684\u8bc4\u8bba\u4fe1\u606f\uff0c\u4ee5\u4fbf\u6211\u4eec\u66f4\u597d\u7684\u4e3a\u60a8\u670d\u52a1");
		return
	}
	if (j.length > 100) {
		alert("\u5bf9\u4e0d\u8d77\u8bc4\u8bba\u6700\u591a\u53ea\u80fd\u8f93\u5165100\u4e2a\u5b57\u7b26");
		return false
	}
	if (f.length > 100) {
		alert("\u5bf9\u4e0d\u8d77\u6807\u9898\u6700\u591a\u53ea\u80fd\u8f93\u516550\u4e2a\u5b57\u7b26");
		return false
	}
	$("#content").val(j);
	$("#menttitle").val(f);
	$("#addment").attr("disabled", true);
	var i = $("#productnum").val();
	var h = "action=addMent&"+$("#mentForm").serialize();
	$.post(g, h, disment);
	return
}
function disment(d) {
	$("#addment").attr("disabled", false);
	if (d == "1") {
		var c = "<tr> <td class='ciTitle'> <p class='lName'> <em>\u6807\u9898:</em><span class='fontBlue'><em>"
				+ $("#menttitle").val() + "</em></span> </p> </td> </tr>";
		c += "<tr> <td class='ciInfo'> <p> <em>\u5185\u5bb9:"
				+ $("#content").val() + "</em><span></span> </p> </td> </tr>";
		$("#showment").html($("#showment").html() + c);
		alert("\u8bc4\u8bba\u6210\u529f,\u8c22\u8c22\u60a8\u7684\u53c2\u4e0e")
	} else {
		if (d == "2") {
			alert("\u5bf9\u4e0d\u8d77\uff01\u60a8\u5df2\u8bc4\u8bba\u8fc7\u4e00\u6b21\uff0c\u4f60\u80fd\u518d\u6b21\u8bc4\u8bba")
		} else {
			if (d == "3") {
				alert("\u5bf9\u4e0d\u8d77\uff01\u60a8\u672a\u767b\u5f55\uff0c\u8bf7\u5148\u767b\u5f55")
			} else {
				alert("\u60a8\u672a\u8d2d\u4e70\u4e0d\u80fd\u8bc4\u8bba")
			}
		}
	}
	$("#menttitle").val("");
	$("#contents").val("");
	$("#ment").hide();
	return
}
function initpve() {
	$("#showpve tr:even").addClass("qa_Bk");
	$("#showpve tr:gt(5)").hide();
	$("#shoalp").click( function() {
		if (tempP != true) {
			tempP = true;
			$("#showpve tr:gt(5)").show()
		} else {
			tempP = false;
			$("#showpve tr:gt(5)").hide()
		}
		$("#disment").show();
		$("#payhelp").hide();
		$("#Issuehelp").hide();
		$("#sendhelp").hide()
	});
	$("#contentpve").focus( function() {
		$(this).val("")
	});
	$("#seapve").click(getment);
	$("#wpve").click( function() {
		$("#wpve").val("")
	});
	$("#wpve").blur( function() {
		if ($("#wpve").val().length < 1) {
			$("#wpve").val("\u8bf7\u8f93\u5165\u54a8\u8be2\u5173\u952e\u8bcd")
		}
	});
	$("#addpve").click(addpve);
	$("#clospve").click( function() {
		$("#pve").hide()
	});
	$("#dopve").click(function() {
		var offset=$(this).offset();
		$("#pve").css("left",offset.left-($("#pve").width()/2)+10).css("top",offset.top+20).show();
		$("#disment").show();
		$("#payhelp").hide();
		$("#Issuehelp").hide();
		$("#sendhelp").hide()
	});
	dispve()
}
function addpve() {
	var f = ctx + "/page/web/product/ProductInfo/product.do";
	var e = $("#contentpve").val();
	e = respaceStr(e);
	if (e.length > 5) {
		if (e.length > 100) {
			alert("\u5bf9\u4e0d\u8d77\u60a8\u6700\u591a\u53ea\u80fd\u8f93\u5165100\u4e2a\u5b57\u7b26")
		} else {
			$("#contentpve").val(e);
			var h = $("#productnum").val();
			var g = {
				content :e,
				action :"addPve",
				pid :h
			};
			$.post(f, g, addcheck)
		}
	} else {
		alert("\u8bf7\u8f93\u5165\u66f4\u8be6\u7ec6\u7684\u54a8\u8be2\u4fe1\u606f\uff0c\u4ee5\u4fbf\u6211\u4eec\u66f4\u597d\u7684\u4e3a\u60a8\u670d\u52a1")
	}
	return
}
function addcheck(b) {
	if (b == "true") {
		$("#nonepve").html("");
		$("#showpve")
				.html(
						$("#showpve").html()
								+ "<tr><td><p class='Q'>\u54a8\u8be2\u5185\u5bb9\uff1a"
								+ $("#contentpve").val()
								+ "</p><p class='A fontBlue'>\u8d62\u8005\u56de\u590d\uff1a\u7b49\u5f85\u56de\u590d</p></td></tr>");
		alert("\u6dfb\u52a0\u6210\u529f\uff0c\u8c22\u8c22\u60a8\u6211\u5bf9\u6211\u4eec\u7684\u652f\u6301,\u6211\u4eec\u4f1a\u5c3d\u5feb\u56de\u590d\u60a8\u7684\u7591\u95ee")
	} else {
		alert("\u56e0\u7cfb\u7edf\u7e41\u5fd9\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5")
	}
	$("#contentpve").val("");
	$("#pve").hide();
	return
}
function getment() {
	var f = ctx + "/page/web/product/ProductInfo/product.do";
	var h = $("#productnum").val();
	var e = $("#wpve").val();
	if (e != "\u8bf7\u8f93\u5165\u54a8\u8be2\u5173\u952e\u8bcd") {
		var g = {
			content :e,
			action :"queryPve",
			productnum :h
		};
		$.post(f, g, showpve)
	} else {
		alert("\u8bf7\u8f93\u5165\u67e5\u8be2\u6761\u4ef6")
	}
	return
}
function showpve(q) {
	var j = evalToJson(q);
	var k = new Array();
	var p = "";
	k = j.rows;
	var r = $("#showpve").html();
	var n = $("#showpve tr").length;
	var m = "";
	var l = "";
	for ( var o in k) {
		if (k[o].feedback != undefined) {
			l = k[o].feedback
		} else {
			l = "\u7b49\u5f85\u56de\u590d"
		}
		m += "<tr><td><p class='Q'>\u54a8\u8be2\u5185\u5bb9\uff1a"
				+ k[o].content
				+ "</p><p class='A fontBlue'>\u8d62\u8005\u56de\u590d\uff1a"
				+ l + "</p></td></tr>"
	}
	$("#showpve").html(r + m);
	$("#showpve tr:lt(" + n + ")").hide();
	return
}
function dispve() {
	$("#tabmenu_11").mousemove( function() {
		$("#proT .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#dispve").show();
		$("#payhelp").hide();
		$("#Issuehelp").hide();
		$("#sendhelp").hide()
	});
	$("#tabmenu_12").mousemove( function() {
		$("#proT .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#payhelp").show();
		$("#dispve").hide();
		$("#Issuehelp").hide();
		$("#sendhelp").hide()
	});
	$("#tabmenu_13").mousemove( function() {
		$("#proT .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#sendhelp").show();
		$("#dispve").hide();
		$("#Issuehelp").hide();
		$("#payhelp").hide()
	});
	$("#tabmenu_14").mousemove( function() {
		$("#proT .selected").removeClass("selected");
		$(this).addClass("selected");
		$("#Issuehelp").show();
		$("#dispve").hide();
		$("#sendhelp").hide();
		$("#payhelp").hide()
	})
}
evalToJson = function(str) {
	var json = null;
	if (str == null || str == "") {
		str = "{}"
	}
	json = eval("(" + str + ")");
	return json
};
function makpri() {
	$("#seldpic .bgcl").removeClass("bgcl");
	$("#seldpic .imgborder").removeClass("imgborder");
	$(this).addClass("bgcl");
	$(this).find("a").addClass("imgborder");
	var d = $("#seldpic li").index(this) + 2;
	var c = $("#productnum").val();
	$("#jqzoomprod").attr("src", ctx + "/images/pic/" + c + "_" + d + ".gif");
	$("#jqzoomprod").attr("jqimg", ctx + "/images/pic/" + c + "_" + d + ".gif")
}
function respaceStr(b) {
	b = b.replace(/</g, "");
	b = b.replace(/>/g, "");
	b = b.replace(/\\/g, "");
	b = b.replace(/'/g, "");
	return b
}
function init() {
	$("#sellist li").eq(0).find("a").mouseover( function() {
		$("#sellist .selected").removeClass("selected");
		$(this).parent().addClass("selected");
		$("#distype").css("display", "inline");
		$("#disbrand").css("display", "none")
	});
	$("#sellist li").eq(1).find("a").mouseover( function() {
		$("#sellist .selected").removeClass("selected");
		$(this).parent().addClass("selected");
		$("#distype").css("display", "none");
		$("#disbrand").css("display", "inline")
	})
}
function initpic() {
	$("#seldpic li").mouseover(makpri);
	$("#seldpic li").eq(0).find("a").addClass("imgborder")
}
( function(b) {
	b.fn.jqueryzoom = function(a) {
		var e = {
			xzoom :200,
			yzoom :200,
			offset :10,
			position :"right",
			lens :1,
			preload :1
		};
		if (a) {
			b.extend(e, a)
		}
		var f = "";
		b(this)
				.hover(
						function() {
							var k = b(this).offset().left;
							var c = b(this).offset().top;
							var d = b(this).children("img").get(0).offsetWidth;
							var l = b(this).children("img").get(0).offsetHeight;
							f = b(this).children("img").attr("alt");
							var j = b(this).children("img").attr("jqimg");
							b(this).children("img").attr("alt", "");
							if (b("div.zoomdiv").get().length == 0) {
								b(this).after(
										"<div class='zoomdiv' ><img class='bigimg' src='"
												+ j + "'/></div>");
								b(this).append(
										"<div class='jqZoomPup'>&nbsp;</div>")
							}
							if (e.position == "right") {
								if (k + d + e.offset + e.xzoom > screen.width) {
									leftpos = k - e.offset - e.xzoom
								} else {
									leftpos = k + d + e.offset
								}
							} else {
								leftpos = k - e.xzoom - e.offset;
								if (leftpos < 0) {
									leftpos = k + d + e.offset
								}
							}
							b("div.zoomdiv").css( {
								top :210,
								left :leftpos + 220
							});
							b("div.zoomdiv").width(e.xzoom);
							b("div.zoomdiv").height(e.yzoom);
							b("div.zoomdiv").show();
							if (!e.lens) {
								b(this).css("cursor", "crosshair")
							}
							b(document.body)
									.mousemove(
											function(h) {
												mouse = new MouseEvent(h);
												var g = b(".bigimg").get(0).offsetWidth;
												var i = b(".bigimg").get(0).offsetHeight;
												var p = "x";
												var o = "y";
												if (isNaN(o) | isNaN(p)) {
													var o = (g / d);
													var p = (i / l);
													b("div.jqZoomPup").width(
															(e.xzoom) / o);
													b("div.jqZoomPup").height(
															(e.yzoom) / p);
													if (e.lens) {
														b("div.jqZoomPup").css(
																"visibility",
																"visible")
													}
												}
												xpos = mouse.x
														- b("div.jqZoomPup")
																.width() / 2
														- k;
												ypos = mouse.y
														- b("div.jqZoomPup")
																.height() / 2
														- c;
												if (e.lens) {
													xpos = (mouse.x
															- b("div.jqZoomPup")
																	.width()
															/ 2 < k) ? 0
															: (mouse.x
																	+ b(
																			"div.jqZoomPup")
																			.width()
																	/ 2 > d + k) ? (d
																	- b(
																			"div.jqZoomPup")
																			.width() - 2)
																	: xpos;
													ypos = (mouse.y
															- b("div.jqZoomPup")
																	.height()
															/ 2 < c) ? 0
															: (mouse.y
																	+ b(
																			"div.jqZoomPup")
																			.height()
																	/ 2 > l + c) ? (l
																	- b(
																			"div.jqZoomPup")
																			.height() - 2)
																	: ypos
												}
												if (e.lens) {
													b("div.jqZoomPup").css( {
														top :ypos,
														left :xpos
													})
												}
												scrolly = ypos;
												b("div.zoomdiv").get(0).scrollTop = scrolly
														* p;
												scrollx = xpos;
												b("div.zoomdiv").get(0).scrollLeft = (scrollx)
														* o
											})
						}, function() {
							b(this).children("img").attr("alt", f);
							b(document.body).unbind("mousemove");
							if (e.lens) {
								b("div.jqZoomPup").remove()
							}
							b("div.zoomdiv").remove()
						});
		count = 0;
		if (e.preload) {
			b("body").append(
					"<div style='display:none;' class='jqPreload" + count
							+ "'>sdsdssdsd</div>");
			b(this).each(
					function() {
						var c = b(this).children("img").attr("jqimg");
						var d = jQuery("div.jqPreload" + count + "").html();
						jQuery("div.jqPreload" + count + "").html(
								d + '<img src="' + c + '">')
					})
		}
	}
})(jQuery);
function MouseEvent(b) {
	this.x = b.pageX;
	this.y = b.pageY
}
function qqOver() {
	var b = this.id;
	this.href = getStr(b, true);
	if (b == "qq1") {
		this.children[0].src = "http://wpa.qq.com/pa?p=1:1278206652:8"
	} else {
		this.children[0].src = "http://wpa.qq.com/pa?p=1:913428535:8"
	}
}
function getStr(k, i) {
	var h = "http://sighttp.qq.com/cgi-bin/check?";
	var l = "sigkey=8faba4a0aaee9ca2aaae7f2e8c4b15808ed3935abab515927e2ab33734647705";
	var j = "http://sighttp.qq.com/cgi-bin/check?";
	var g = "sigkey=2b69275783869f63cf17babb271e5ffec4be65ec56cb8d075f4652269271b81f";
	if (k == "qq1") {
		if (i) {
			h += l
		} else {
			return l
		}
	} else {
		if (i) {
			j += g
		} else {
			return g
		}
	}
}
function qqClick() {
	var e = this.id;
	var h = "http://sighttp.qq.com/wpa.js?rantime=" + Math.random() + "&"
			+ getStr(e, false);
	var g = document.getElementById("testJs");
	var f = document.createElement("script");
	f.setAttribute("type", "text/javascript");
	f.setAttribute("id", "testJs");
	f.setAttribute("src", h);
	if (g == null) {
		document.body.appendChild(f)
	} else {
		g.parentNode.replaceChild(f, g)
	}
	return false
}
