var sizetemp = false;
var colortemp = false;
var dlname = "";
$(document).ready(function() {
	initdis();
	seleche();
	moredate();
	headon();
	$(".qqServices").each( function() {
		$(this).mousemove(qqOver);
		$(this).click(qqClick)
	});
	$("#shseld").click(upseld);
	$("#shseldd").click(upseld);
	init();
	display();
});

function display(){
	if ($("#showsta").val() == "true") {
		$("#sred").text("(点击收缩)");
		$("#seld").removeClass("disseled");
		$("#pintico").attr("src",
				"/page/web/product/ProductList/images/on.gif");
	} else {
		$("#sred").text("(点击展开)");
		$("#seld").addClass("disseled");
		$("#pintico").attr("src",
				"/page/web/product/ProductList/images/off.gif");
	}
}
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 upseld() {
	$("#seld").toggleClass("disseled");
	var b = $("#pintico").attr("src");
	if (b.indexOf("on") == -1) {
		$("#showsta").val("true");
		$("#sred").text("(点击收缩)");
		$("#pintico")
				.attr("src", "/page/web/product/ProductList/images/on.gif");
	} else {
		$("#showsta").val("false");
		$("#sred").text("(点击展开)");
		$("#pintico").attr("src",
				"/page/web/product/ProductList/images/off.gif");
	}
}
function initdis() {
	$("input[@type='radio'][@checked]").each(
			function() {
				$(this).parent().parent().parent().find("dd").eq(0).find("a")
						.removeClass("on");
				$(this).parent().addClass("on")
			});
	var b = $("#proprice").val();
	if (b != "") {
		$("#price dd").eq(0).find("a").removeClass("on");
		$("#price  dd  a input").each( function() {
			if ($(this).val() == b) {
				$(this).parent().addClass("on");
			}
		});
	}
}
function moredate() {
	$("#color dd:gt(15)").hide();
	$("#color dd:last-child").show();
	$("#colormore").click( function() {
		if (colortemp != true) {
			colortemp = true;
			$("#color dd:gt(15)").show();
			$("#color dd:last-child").find("a").html("\u6536\u7f29");
		} else {
			colortemp = false;
			$("#color dd:gt(15)").hide();
			$("#color dd:last-child").show();
			$("#color dd:last-child").find("a").html("\u66f4\u591a>>");
		}
	});
	$("#size dd:gt(15)").hide();
	$("#size dd:last-child").show();
	$("#sizemore").click( function() {
		if (sizetemp != true) {
			sizetemp = true;
			$("#size dd:gt(15)").show();
			$("#size dd:last-child").find("a").html("<<\u6536\u7f29");
		} else {
			sizetemp = false;
			$("#size dd:gt(15)").hide();
			$("#size dd:last-child").show();
			$("#size dd:last-child").find("a").html("\u66f4\u591a>>");
		}
	});
}
function headon() {
	var a = $("#url").val();
	$("#seldon .wnon").removeClass("wnon");
	$("#seldon li").each( function() {
		var b = $(this).find("a").attr("href");
		b = b.substring(b.indexOf("?"));
		if (a.indexOf(b) != -1) {
			$(this).addClass("wnon");
			return;
		}
	});
}
function seleche() {
	$("#brand dd a").click( function() {
		$("#brand .on").removeClass("on");
		$(this).addClass("on");
		$(this).find("input").attr("checked", "checked");
		subsearch();
	});
	$("#protype dd a").click( function() {
		$("#protype .on").removeClass("on");
		$(this).addClass("on");
		$(this).find("input").attr("checked", "checked");
		subsearch();
	});
	$("#color dd a").click( function() {
		if ($(this).attr("id") != "colormore") {
			$("#color .on").removeClass("on");
			$(this).addClass("on");
			$(this).find("input").attr("checked", "checked");
			subsearch();
		}
	});
	$("#size dd a").click( function() {
		if ($(this).attr("id") != "sizemore") {
			$("#size .on").removeClass("on");
			$(this).addClass("on");
			$(this).find("input").attr("checked", "checked");
			subsearch();
		}
	});
	$("#price dd a").click( function() {
		$("#price .on").removeClass("on");
		$(this).addClass("on");
		$("#proprice").val($(this).find("input").val());
		subsearch();
	});
	$("#order dd a").click( function() {
		$("#order .on").removeClass("on");
		$(this).addClass("on");
		$(this).find("input").attr("checked", "checked");
		$("#temppro").val("");
		seldOrder();
		subsearch();
	});
}
function seldOrder() {
	var b = $("#desc").val();
	if (b == "desc") {
		b = "asc";
	} else {
		b = "desc";
	}
	$("#desc").val(b);
}
function subsearch() {
	document.getElementById("seapro").submit();
}
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(i, g) {
	var l = "http://sighttp.qq.com/cgi-bin/check?";
	var j = "sigkey=8faba4a0aaee9ca2aaae7f2e8c4b15808ed3935abab515927e2ab33734647705";
	var h = "http://sighttp.qq.com/cgi-bin/check?";
	var k = "sigkey=2b69275783869f63cf17babb271e5ffec4be65ec56cb8d075f4652269271b81f";
	if (i == "qq1") {
		if (g) {
			l += j;
		} else {
			return j;
		}
	} else {
		if (g) {
			h += k;
		} else {
			return k;
		}
	}
}
function qqClick() {
	var g = this.id;
	var f = "http://sighttp.qq.com/wpa.js?rantime=" + Math.random() + "&"
			+ getStr(g, false);
	var e = document.getElementById("testJs");
	var h = document.createElement("script");
	h.setAttribute("type", "text/javascript");
	h.setAttribute("id", "testJs");
	h.setAttribute("src", f);
	if (e == null) {
		document.body.appendChild(h);
	} else {
		e.parentNode.replaceChild(h, e);
	}
	return false;
}
