
var Cart_Container;
var Cart_baseUrl;
var ctx;
$(function () {
	ctx = $("#ctx").val();
	if (!ctx) {
		ctx = "";
	}
	$(".qqServices").each(function () {
		$(this).mousemove(qqOver);
		$(this).click(qqClick);
	});
	Cart_baseUrl = ctx + "/page/web/cart/CartInfo/cart.jsp?timestamp=" + new Date().getTime();
	Cart_Container = new View.Update({panel:"shoppingcart", url:Cart_baseUrl});
});
function Cart_refresh() {
	Cart_Container.refresh();
}
function setProNum(a) {
	$("#cartSize").html(a);
	if (a < 1) {
		$("#overshop").unbind();
	} else {
		$("#overshop").click(function () {
			window.location.href = ctx + "/page/web/order/OrderInfo/orderinfo.do";
		});
	}
}
function addProduct(c, b, d) {
	var a = "&action=addCart&pid=" + c + "&size=" + b + "&num=" + d;
	Cart_Container.update(Cart_baseUrl + a);
}
function Cart_empty() {
	Cart_Container.update(Cart_baseUrl + "&action=empty");
}
function Cart_delProduct(a) {
	Cart_Container.update(Cart_baseUrl + "&action=delCart&key=" + a);
}
function Cart_updateProduct(a, b) {
	Cart_Container.update(Cart_baseUrl + "&action=update&key=" + a + "&num=" + b);
}
function checkNumber(d, g) {
	var e = false;
	var f = $("#" + d).val();
	var a = parseInt($.trim($("#" + d).next().val()));
	var c = parseInt($.trim(f));
	var b = /^[0-9]*[1-9][0-9]*$/;
	e = b.test(c);
	if (c == 0) {
		Cart_delProduct(g);
		return e;
	}
	if (!e || isNaN(c) || c < 0) {
		c = 1;
	}
	if (a > 0 && a < f) {
		c = a;
		alert("\u6700\u5927\u8ba2\u8d2d\u6570\u91cf\u4e3a" + c);
	} else {
		if (c > 5) {
			alert("\u6700\u5927\u8ba2\u8d2d\u6570\u4e3a5");
			c = 5;
		}
	}
	$("#" + d).val(c);
	Cart_updateProduct(g, c);
	return e;
}
var ctx = "";
var num = 0;
$(document).ready(function () {
	ctx = $("#ctx").val();
	if (!ctx) {
		ctx = "";
	}
	Cart_refresh();
	$("#delall").click(function () {
		Cart_empty();
	});
	if ($("#hot li").length > 4) {
		$("#addhot").addClass("curso");
	}
	$("#hot li:lt(0)").hide();
	$("#hot li:gt(4)").hide();
	$("#addhot").click(addNum);
	$("#cuthot").click(cutNum);
	$("#onshop").click(function () {
		window.location.href = ctx + "/page/web/product/ProductList/productList.do?action=produList";
	});
});
function addNum() {
	var a = Number($("#hot li").length) - 5;
	if (num < a) {
		num++;
		$("#cuthot").addClass("curso");
		$("#hot li").eq(num - 1).hide();
		$("#hot li").eq(num + 4).show();
	} else {
		$("#addhot").removeClass("curso");
	}
}
function cutNum() {
	if (num > 0) {
		num--;
		$("#hot li").eq(num).show();
		$("#hot li").eq(num + 5).hide();
	} else {
		$("#cuthot").removeClass("curso");
	}
}
function qqOver() {
	var a = this.id;
	this.href = getStr(a, true);
	if (a == "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(d, f) {
	var a = "http://sighttp.qq.com/cgi-bin/check?";
	var c = "sigkey=8faba4a0aaee9ca2aaae7f2e8c4b15808ed3935abab515927e2ab33734647705";
	var e = "http://sighttp.qq.com/cgi-bin/check?";
	var b = "sigkey=2b69275783869f63cf17babb271e5ffec4be65ec56cb8d075f4652269271b81f";
	if (d == "qq1") {
		if (f) {
			a += c;
		} else {
			return c;
		}
	} else {
		if (f) {
			e += b;
		} else {
			return b;
		}
	}
}
function qqClick() {
	var b = this.id;
	var c = "http://sighttp.qq.com/wpa.js?rantime=" + Math.random() + "&" + getStr(b, false);
	var d = document.getElementById("testJs");
	var a = document.createElement("script");
	a.setAttribute("type", "text/javascript");
	a.setAttribute("id", "testJs");
	a.setAttribute("src", c);
	if (d == null) {
		document.body.appendChild(a);
	} else {
		d.parentNode.replaceChild(a, d);
	}
	return false;
}

