var pageData;
var pageCount = 18;
var currentPage = 1;
var totalCount;
var totalPage;
var pageFirst;
var pageEnd;
var telNumTempOne;
var regionTempOne;
var submitFlag = true;
var reloadRecNum = false;
var bookTelnumRule = 0;
$(document).ready(function() {
	var a = $("#searchCondition").val();
	if ("ruleNum" == a) {
		switchTab($("#ruleNum"))
	} else {
		if ("birNum" == a) {
			switchTab($("#birNum"))
		} else {
			if ("loveNum" == a) {
				switchTab($("#loveNum"))
			} else {
				if ("luckyNum" == a) {
					switchTab($("#luckyNum"))
				} else {
					if ("constellNum" == a) {
						switchTab($("#constellNum"))
					}
				}
			}
		}
	}
	$(".Group li").click(function() {
		switchTab(this)
	});
	$(".stuck table tr td div ul li").click(function() {
		switchConditions(this)
	});
	$(".diy_select").click(function() {
		$(this).children(".diy_select_list").toggle()
	});
	$(".diy_select_list").mouseleave(function() {
		$(this).hide()
	});
	$(".diy_select_list li").hover(function() {
		$(this).addClass("focus")
	}, function() {
		$(this).removeClass("focus")
	});
	$("input[id=notFourCBX]").click(function() {
		if ($(this).attr("checked")) {
			$("#notFourHid").val("yes")
		} else {
			$("#notFourHid").val("")
		}
		$(".stuck table tr td div ul[id=ruleNum] li .current").click()
	});
	$(".wale li").click(function() {
		if ($(this).attr("class") == "") {
			$(this).addClass("elect_up").siblings().removeAttr("class")
		} else {
			if ($(this).attr("class") == "elect_up") {
				$(this).removeAttr("class").addClass("elect_down")
			} else {
				if ($(this).attr("class") == "elect_down") {
					$(this).removeAttr("class").addClass("elect_up")
				}
			}
		}
		var b = $(this).attr("id");
		var c = $("#pSort").val();
		if (b == "") {
			$("#pSort").val("")
		} else {
			if (c == b) {
				$("#pSort").val(Math.abs(b))
			} else {
				$("#pSort").val(b)
			}
		}
		appendArea(b, c)
	});
	init()
});
function init() {
	var a = window.location.href;
	var b = false;
	var r = -1;
	var g = new RegExp("^\\d+$", "");
	if (a.lastIndexOf("?") != -1) {
		var m = a.split("?")[1].split("&");
		for ( var n = 0; n < m.length; n++) {
			var f = m[n].split("=");
			var c = f[0];
			var d = f.length > 1 ? f[1] : "";
			if (c == "area") {
				$("#regionHid").val(d)
			}
			if (c == "num") {
				initInputNum(d);
				$("#selfDefNumHid").val(d);
				$("#notFourHid").val("");
				b = true
			}
			if (c == "endnums") {
				r = 1;
				$("#endNums").val(d);
				var p = d.split(",");
				if (null != p) {
					for ( var k = 0; k < p.length; k++) {
						var h = p[k].split("_");
						if (h.length == 2) {
							if (!(g.test(h[0]) && h[0].length <= 6
									&& g.test(h[1]) && h[1].length <= 6)) {
								r = -1;
								break
							}
						} else {
							r = -1;
							break
						}
					}
				} else {
					r = -1
				}
			}
			if (c == "endnumlen") {
				if (g.test(d) && (parseInt(d) > 0 && parseInt(d) < 7)) {
					$("#endNumLen").val(d)
				} else {
					r = -1
				}
			}
			if (c == "constell") {
				$("#constell").val(d)
			}
		}
		$("#endNumType").val(r);
		if (r != -1 && -1 != $("#endNumLen").val()
				&& "" != $("#endNumLen").val()) {
			if ($("#endNumStart").val() == "") {
				$("#endNumStart").val("0")
			} else {
				if ($("#endNumEnd").val() == "") {
					$("#endNumEnd").val("999999")
				}
			}
			$("endNumType").val(r);
			ajaxSubmit("sefDefQry", "1")
		} else {
			if (b) {
				ajaxSubmit("sefDefQry")
			}
		}
	}
	var o = "531";
	var l = "null";
	var q = $("#sellRegion").val();
	var e = "null";
	if ($("#highQryHid") && null != $("#highQryHid").val()) {
		e = $("#highQryHid").val()
	}
	if ($("#area_hidden") && null != $("#area_hidden").val()) {
		o = $("#area_hidden").val()
	}
	if (null != $("#beginNumHid").val() && "" != $("#beginNumHid").val()) {
		l = $("#beginNumHid").val()
	}
	$(".stuck table tr td ul[id=numRegion] li").each(function() {
		var i = $(this).attr("id");
		var j = i.split("@")[0];
		if (j == o) {
			$(this).click()
		}
		if (j == l) {
			submitFlag = false;
			$(this).click()
		}
	});
	if (q) {
		$(".stuck table tr[id=numRegion] td ul li").each(function() {
			$(this).unbind("click")
		})
	}
	$(".stuck table tr td ul[id=luckyNum] li").each(function() {
		var i = $(this).attr("id");
		var j = i.split("@")[0];
		if (j == o) {
			initVal("highQryHid", j, "highQryType")
		}
		if (j == e && null != e && "null" != e) {
			$(this).click()
		}
	});
	$(".stuck table tr td ul[id=constellNum] li").each(function() {
		var i = $(this).attr("id");
		var j = i.split("@")[0];
		if (j == o) {
			initVal("highQryHid", j, "highQryType")
		}
		if (j == e && null != e && "null" != e) {
			$(this).click()
		}
	});
	$(".stuck table tr td ul[id=birthNum] li").each(function() {
		var i = $(this).attr("id");
		var j = i.split("@")[0];
		if (j == o) {
			initVal("highQryHid", j, "highQryType")
		}
		if (j == e && null != e && "null" != e) {
			$(this).click()
		}
	});
	$("#clickChangeLoveNum span").each(function() {
		var i = $(this).attr("id");
		var j = i.split("@")[0];
		if (j == o) {
			initVal("highQryHid", j, "highQryType")
		}
		if (j == e && null != e && "null" != e) {
			$(this).click()
		}
	});
	if ($("#lovesTxt").val() == "") {
		$("#lovesTxt").val("请输入11位的移动手机号码！")
	}
	$("#lovesTxt").keydown(function(i) {
		if (i.keyCode == 13) {
			$("#lovesTxt").click();
			return false
		}
	});
	$("#lovesTxt").focus(function() {
		if ($("#lovesTxt").val() == "请输入11位的移动手机号码！") {
			$("#lovesTxt").val("")
		}
	});
	$("#lovesTxt").blur(function() {
		if ($("#lovesTxt").val() == "") {
			$("#lovesTxt").val("请输入11位的移动手机号码！")
		}
	})
}
function switchTab(b) {
	if ($(b).hasClass("pick")) {
		return false
	} else {
		var a = $(b).attr("id");
		if (a == "searchNum") {
			$("input[id^=input]").each(function() {
				$(this).val("*")
			});
			$("#highQryHid").val("");
			$("#highQryTypeHid").val("");
			$("#preFeeHid").val("");
			$("#selfDefNumHid").val("138********");
			ajaxSubmit("sefDefQry")
		} else {
			if (a == "ruleNum") {
				$("#beginNumHid").val("");
				$("#selfDefNumHid").val("138********");
				appendArea("", "regExp")
			} else {
				if (a == "birNum") {
					$("#beginNumHid").val("");
					$("#selfDefNumHid").val("138********");
					appendArea("", "birthNum")
				} else {
					if (a == "loveNum") {
						$("#beginNumHid").val("");
						$("#selfDefNumHid").val("138********");
						appendArea("", "loveNum")
					} else {
						if (a == "luckyNum") {
							$("#beginNumHid").val("");
							$("#selfDefNumHid").val("138********");
							appendArea("", "luckyNum")
						} else {
							if (a == "constellNum") {
								$("#beginNumHid").val("");
								$("#selfDefNumHid").val("138********");
								appendArea("", "constellNum")
							}
						}
					}
				}
			}
		}
		$(b).addClass("pick").siblings().removeClass("pick");
		$(".stuck table tr").each(function() {
			if ($(this).attr("forTab").indexOf(a) != -1) {
				$(this).css("display", "block")
			} else {
				$(this).css("display", "none")
			}
		})
	}
}
function switchConditions(d) {
	var j = $(d).parent().attr("id");
	if (j != "lovesNum") {
		$(d).children().addClass("current").parent().siblings().children()
				.removeClass("current")
	}
	if (j == "numRegion") {
		var b = $(d).attr("id");
		var c = b.split("@@");
		var i = c[0];
		var g = c[1];
		cookieMgr(i.split("@")[0]);
		if ($("#highQryTypeHid").val() == "") {
			$("#selfDefNumHid").val("138********")
		}
		appendArea(i, g)
	}
	if (j == "beginNum") {
		var b = $(d).attr("id");
		var c = b.split("@@");
		var i = c[0];
		var g = c[1];
		var e = i.split("@")[1];
		var f = e + $("#input1").val() + $("#input2").val()
				+ $("#input3").val() + $("#input4").val() + $("#input5").val()
				+ $("#input6").val() + $("#input7").val() + $("#input8").val();
		$(d).parents(".diy_select").children(".diy_select_txt").text(
				$(d).text());
		$("#selfDefNumHid").val(f);
		appendArea(i, g)
	} else {
		if (j == "prepayFee") {
			appendArea($(d).attr("id"), "preFee")
		} else {
			if (j == "ruleNum") {
				$("#selfDefNumHid").val("");
				var b = $(d).attr("id");
				var i = b.split("@")[0];
				if (i == null || i == "") {
					$("#selfDefNumHid").val("138********")
				}
				$("#input1").val("*");
				$("#input2").val("*");
				$("#input3").val("*");
				$("#input4").val("*");
				$("#input5").val("*");
				$("#input6").val("*");
				$("#input7").val("*");
				$("#input8").val("*");
				$(".stuck table tr td ul").each(
						function() {
							var k = $(this).attr("id");
							if (k != "prepayFee" && k != "ruleNum"
									&& k != "numRegion") {
								$(this).children("li").first().children("a")
										.addClass("current").parent()
										.siblings().children("a").removeClass(
												"current")
							}
						});
				appendArea(b, "regExp")
			} else {
				if (j == "luckyNum") {
					$("#selfDefNumHid").val("");
					var b = $(d).attr("id");
					var i = b.split("@")[0];
					if (i == null || i == "") {
						$("#selfDefNumHid").val("138********")
					}
					$("#input1").val("*");
					$("#input2").val("*");
					$("#input3").val("*");
					$("#input4").val("*");
					$("#input5").val("*");
					$("#input6").val("*");
					$("#input7").val("*");
					$("#input8").val("*");
					$(".stuck table tr td ul").each(
							function() {
								var k = $(this).attr("id");
								if (k != "prepayFee" && k != "luckyNum"
										&& k != "numRegion") {
									$(this).children("li").first()
											.children("a").addClass("current")
											.parent().siblings().children("a")
											.removeClass("current")
								}
							});
					appendArea(b, "luckyNum")
				} else {
					if (j == "birthNum") {
						$("#selfDefNumHid").val("");
						var b = $(d).attr("id");
						var i = b.split("@")[0];
						if (i == null || i == "") {
							$("#selfDefNumHid").val("138********")
						}
						$("#input1").val("*");
						$("#input2").val("*");
						$("#input3").val("*");
						$("#input4").val("*");
						$("#input5").val("*");
						$("#input6").val("*");
						$("#input7").val("*");
						$("#input8").val("*");
						$(".stuck table tr td ul").each(
								function() {
									var k = $(this).attr("id");
									if (k != "prepayFee" && k != "birthNum"
											&& k != "numRegion") {
										$(this).children("li").first()
												.children("a").addClass(
														"current").parent()
												.siblings().children("a")
												.removeClass("current")
									}
								});
						appendArea(b, "birthNum")
					} else {
						if (j == "loveNum") {
							$("#selfDefNumHid").val("");
							var b = $(d).attr("id");
							var i = b.split("@")[0];
							if (i == null || i == "") {
								$("#selfDefNumHid").val("138********")
							}
							$("#input1").val("*");
							$("#input2").val("*");
							$("#input3").val("*");
							$("#input4").val("*");
							$("#input5").val("*");
							$("#input6").val("*");
							$("#input7").val("*");
							$("#input8").val("*");
							$(".stuck table tr td ul").each(
									function() {
										var k = $(this).attr("id");
										if (k != "prepayFee" && k != "loveNum"
												&& k != "lovesNum"
												&& k != "numRegion") {
											$(this).children("li").first()
													.children("a").addClass(
															"current").parent()
													.siblings().children("a")
													.removeClass("current")
										}
									});
							appendArea(b, "loveNum")
						} else {
							if (j == "lovesNum") {
								var a = /^(((13[4-9]{1})|147|178|(15[0,1,2,7,8,9]{1})|(18[2,3,4,7,8]{1}))+\d{8})$/;
								var h = $("#lovesTxt").val();
								if (h == "" || h.length < 11
										|| !a.test($.trim(h))) {
									showMsg("请输入11位的移动手机号码！", $("#lovesTxt"));
									return false
								}
								$("#selfDefNumHid").val("");
								var b = $(d).attr("id");
								if (b == "") {
									return false
								}
								var i = b.split("@")[0];
								if (i == null || i == "") {
									$("#selfDefNumHid").val("138********")
								}
								$("#input1").val("*");
								$("#input2").val("*");
								$("#input3").val("*");
								$("#input4").val("*");
								$("#input5").val("*");
								$("#input6").val("*");
								$("#input7").val("*");
								$("#input8").val("*");
								$(".stuck table tr td ul").each(
										function() {
											var k = $(this).attr("id");
											if (k != "prepayFee"
													&& k != "numRegion") {
												$(this).children("li").first()
														.children("a")
														.addClass("current")
														.parent().siblings()
														.children("a")
														.removeClass("current")
											}
										});
								$(d).children("a").addClass("current").parent()
										.siblings("li").children("a")
										.removeClass("current");
								appendArea(b, "lovesNum")
							} else {
								if (j == "constellNum") {
									$("#selfDefNumHid").val("");
									var b = $(d).attr("id");
									var i = b.split("@")[0];
									if (i == null || i == "") {
										$("#selfDefNumHid").val("138********")
									}
									$("#input1").val("*");
									$("#input2").val("*");
									$("#input3").val("*");
									$("#input4").val("*");
									$("#input5").val("*");
									$("#input6").val("*");
									$("#input7").val("*");
									$("#input8").val("*");
									$(".stuck table tr td ul")
											.each(
													function() {
														var k = $(this).attr(
																"id");
														if (k != "prepayFee"
																&& k != "constellNum") {
															$(this)
																	.children(
																			"li")
																	.first()
																	.children(
																			"a")
																	.addClass(
																			"current")
																	.parent()
																	.siblings()
																	.children(
																			"a")
																	.removeClass(
																			"current")
														}
													});
									appendArea(b, "constellNum")
								}
							}
						}
					}
				}
			}
		}
	}
}
function ajaxSubmit(c, b) {
	$("#numList").html($("#numLoadingImg").html());
	$("#pageNum").html("");
	if (b != 1) {
		$("#endNumType").val("-1")
	}
	if ($("#highQryTypeHid").val() == "lovesNum") {
		$("#selfDefNumHid").val($("#lovesTxt").val())
	}
	var a = $("#contextPath").val() + "numShowNewAjax.action?";
	a += "region=" + $("#regionHid").val();
	a += "&beginNum=" + $("#beginNumHid").val();
	a += "&endNumType=" + $("#endNumType").val();
	a += "&endNumLen=" + $("#endNumLen").val();
	a += "&endNumStart=" + $("#endNumStart").val();
	a += "&endNumEnd=" + $("#endNumEnd").val();
	a += "&endNums=" + $("#endNums").val();
	a += "&preFee=" + $("#preFeeHid").val();
	a += "&highQryRule=" + $("#highQryHid").val();
	a += "&highQryType=" + $("#highQryTypeHid").val();
	a += "&selfDefType=" + $("#selfDefHid").val();
	a += "&selfDefNum=" + $("#selfDefNumHid").val();
	a += "&selfDefFlag=" + c;
	a += "&notFour=" + $("#notFourHid").val();
	a += "&reloadRecNum=" + reloadRecNum;
	a += "&pSort=" + $("#pSort").val();
	a = a.replace(/undefined/g, "");
	$("#searchurl").html(a);
}
function pageReady(a) {
	pageData = a.newShowNums;
	bookTelnumRule = a.bookTelnumRule;
	if (null == pageData) {
		pageData = new Array()
	}
	if (pageData.length == 0) {
		$("#numList").html($("#numNotFound").html())
	} else {
		currentPage = 1;
		totalCount = pageData.length;
		totalPage = parseInt((totalCount + pageCount - 1) / pageCount);
		pageFirst = (currentPage - 1) * pageCount;
		if (totalCount < pageCount) {
			pageEnd = totalCount
		} else {
			pageEnd = pageFirst + pageCount
		}
		numMsg();
		pageIndex()
	}
}
function numMsg() {
	var d = "";
	if ($("#is_jt").length > 0) {
		var a = $("#is_jt").val()
	} else {
		var a = ""
	}
	for ( var c = pageFirst; c < pageEnd; c++) {
		var b = pageData[c];
		var g = $("#vproductId").val();
		var f = 'preBuy("' + b.telNum + '","' + b.preFee + '","' + b.region
				+ '","' + b.regionName + '","' + b.minCost + '","' + b.signTime
				+ '","' + a + '","normalBuy");';
		var e = 'preBook("' + b.telNum + '","' + b.preFee + '","' + b.region
				+ '","' + b.regionName + '","' + b.minCost + '","' + b.signTime
				+ '","' + b.orgId + '","normalBuy");';
		d += "<div class='consume'>";
		d += "<div class='consume_left'>";
		d += "<p>";
		d += b.telNum.substring(0, 3);
		d += "<span class='color-ff4400'>";
		d += b.telNum.substring(3, 7);
		d += "</span>";
		d += b.telNum.substring(7);
		d += "</p>";
		d += "<span class='font_size_12'>";
		d += "预存";
		d += "<span class='font_size_16 color-ff4400'>";
		d += b.preFee;
		d += "</span>";
		d += "元 最低消费";
		d += "<span class='font_size_16 color-ff4400'>";
		d += b.minCost;
		d += "</span>元";
		d += "</span>";
		d += "</div>";
		d += "<div class='consume_right'>";
		d += "<input type='button' value='购买' class='buy' onclick='javascript:"
				+ f + ";return false;'/><br />";
		if (null != bookTelnumRule && "" != bookTelnumRule
				&& Number(b.minCost) < Number(bookTelnumRule)
				&& (g == null || g == "")) {
			d += "<input type='button' value='预约' class='booking' onclick='javascript:"
					+ e + ";return false;'/>"
		}
		d += "</div>";
		d += "</div>"
	}
	$("#numList").html(d)
}
function pageIndex() {
	var c = parseInt(currentPage);
	var d = parseInt(totalPage);
	var b = "";
	if (c > 1) {
		b += "<ul><a href='javascript:void(0)'><li class='page_home_select' id='pageJumpFirst' onClick='pageJump(1)'>首页</li></a>";
		b += "<a href='javascript:pageJump(" + (c - 1)
				+ ")'><li class='page_next_select'>&lt;</li></a>"
	} else {
		b += "<ul><a href='javascript:void(0)'><li class='page_home' id='pageJumpFirst'>首页</li></a>";
		b += "<a href='javascript:void(0)'><li class='page_next'>&lt;</li></a>"
	}
	if (d < 6) {
		for ( var a = 1; a <= d; a++) {
			b += pageIndexHtml(a, c)
		}
	} else {
		if (c >= 6 && c <= d - 6) {
			for ( var a = (c - 2); a <= (c + 3); a++) {
				b += pageIndexHtml(a, c)
			}
		} else {
			if (c < 6) {
				for ( var a = 1; a <= 6; a++) {
					b += pageIndexHtml(a, c)
				}
			} else {
				for ( var a = d - 5; a <= d; a++) {
					b += pageIndexHtml(a, c)
				}
			}
		}
	}
	if (c < d) {
		b += "<a href='javascript:pageJump(" + (c + 1)
				+ ")'><li class='page_next_select'>&gt;</li></a>";
		b += "<a href='javascript:void(0)'><li class='page_home_select' id='pageJumpEnd' onClick='pageJump("
				+ totalPage + ")'>尾页</li></a></ul>"
	} else {
		b += "<a javascript:void(0)><li>&gt;</li></a>";
		b += "<a href='javascript:void(0)'><li id='pageJumpEnd'>尾页</li></a></ul>"
	}
	b += "<div class='page_all'>共<span>"
			+ d
			+ "</span>页 ， 跳转<span class='marginright5 marginleft5'><input name='' type='text' class='input_24' id='indexInput' /></span>页<span class='marginleft5'><a href='javascript:pageJump(getNowPage())' class='btn_tiaozhuan'>跳转</a></span></div>";
	b += "<div class='clear'></div>";
	$("#pageNum").html(b)
}
function pageJump(a) {
	var b = /^\+?[1-9][0-9]*$/;
	if (!b.test(a)) {
		$("#indexInput").val(currentPage);
		return
	}
	if (a < 1 || a > totalPage) {
		alert("第" + a + "页不存在");
		$("#indexInput").val(currentPage);
		return
	}
	currentPage = a;
	pageFirst = (a - 1) * pageCount;
	if (currentPage == totalPage) {
		pageEnd = totalCount
	} else {
		pageEnd = pageFirst + pageCount
	}
	numMsg();
	pageIndex()
}
function getNowPage() {
	var a = document.getElementById("indexInput");
	if (null != a) {
		return a.value
	} else {
		return 1
	}
}
function pageIndexHtml(b, c) {
	var a = "";
	if (b == c) {
		a += "<a href='javascript:void(0)'><li class='page_select'>" + b
				+ "</li></a>"
	} else {
		a += "<a href='javascript:pageJump(" + b + ")'><li>" + b + "</li></a>"
	}
	return a
}
function initVal(d, b, a) {
	var c = document.getElementById(d);
	if (null != c) {
		if ("null" == b || "-" == b) {
			c.value = ""
		} else {
			c.value = b
		}
	}
	if (null != a && "" != a) {
		$("#highQryTypeHid").val(a)
	}
}
function initInputNum(b) {
	if (null != b && b.length > 3) {
		$("#showNum").html(b.substring(0, 3));
		for ( var a = 3; a < b.length; a++) {
			$("input[id='input" + (a - 2) + "']").val(b.charAt(a))
		}
	}
}
function cookieMgr(a) {
	if ($("#_account").val() == "0") {
		$.cookie("NOTLOGIN_DEFAIL_CITY", a, {
			expires : 30,
			path : "/"
		})
	} else {
		var b = $("#_account").val().replace("@", "_");
		b = b + "_LOGIN_DEFAIL_CITY";
		$.cookie(b, a, {
			expires : 30,
			path : "/"
		})
	}
}
function appendArea(g, d) {
	reloadRecNum = false;
	var a = "";
	var b = "";
	var e = "";
	var c = "";
	var f = $("#regionHid").val();
	if (null != g && "" != g) {
		a = g.split("@")[0];
		b = g.split("@")[1];
		if ($("#_account").val() == "0") {
			$.cookie("NOTLOGIN_NUM_SELECT_CITY", a, {
				expires : 30,
				path : "/"
			})
		} else {
			var h = $("#_account").val() + "_LOGIN_NUM_SELECT_CITY";
			$.cookie(h, a, {
				expires : 30,
				path : "/"
			})
		}
	}
	if ("region" == d) {
		if (null != b && "所有" != b) {
			$("#regionName").val(b)
		}
		e = "regionHid";
		if (f != "" && f != a) {
			reloadRecNum = true
		}
	} else {
		if ("beginNum" == d) {
			e = "beginNumHid"
		} else {
			if ("preFee" == d) {
				e = "preFeeHid"
			} else {
				if ("regExp" == d) {
					e = "highQryHid";
					c = d
				} else {
					if ("luckyNum" == d) {
						e = "highQryHid";
						c = d
					} else {
						if ("constellNum" == d) {
							e = "highQryHid";
							c = d
						} else {
							if ("loveNum" == d) {
								e = "highQryHid";
								c = d
							} else {
								if ("lovesNum" == d) {
									e = "highQryHid";
									c = d
								} else {
									if ("birthNum" == d) {
										e = "highQryHid";
										c = d
									}
								}
							}
						}
					}
				}
			}
		}
	}
	initVal(e, a, c);
	ajaxSubmit()
}
function nextText(d) {
	var c = d.value.length;
	var b = /^[0-9]{1}$/;
	if (c == 1 && b.test(d.value)) {
		if (d.id != "input8") {
			var a = d.nextSibling.nextSibling;
			a.focus()
		}
	} else {
		$(".submit1").focus();
		d.focus()
	}
		immediateSearch();
}
function clearContent(a) {
	if (null != a) {
		a.value = ""
	}
}
function initContent(b) {
	if (null != b) {
		if ("" == b.value) {
			b.value = "*"
		}
		var a = /^[0-9]{1}$/;
		if (!a.test(b.value) && b.value != "*") {
			b.value = "*";
			b.focus();
			alert("请输入0-9之间的任意一个数字")
		}
	}
}
function clearAllContent() {
	$("#input1").val("*");
	$("#input2").val("*");
	$("#input3").val("*");
	$("#input4").val("*");
	$("#input5").val("*");
	$("#input6").val("*");
	$("#input7").val("*");
	$("#input8").val("*");
	$("#selfDefNumHid").val("138********");
	var a = $.trim($(".diy_select_txt").text());
	if (a != "***") {
		$("#selfDefNumHid").val(a + "********")
	}
}
function immediateSearch() {
	var b = $.trim($(".diy_select_txt").text());
	var a = b + $("#input1").val() + $("#input2").val() + $("#input3").val()
			+ $("#input4").val() + $("#input5").val() + $("#input6").val()
			+ $("#input7").val() + $("#input8").val();
	$("#selfDefNumHid").val(a);
	ajaxSubmit("sefDefQry")
}
function showMsg(a) {
	$
			.dialog( {
				title : "信息提示",
				content : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="'
						+ $("#contextPath").val()
						+ 'resources/default/images/popwin/messP.gif"  width="32" height="32" />'
						+ a,
				ok : "确定",
				id : "confirmWindow",
				className : "confirmWindow",
				width : 335,
				modal : true
			})
}
function preBuy(c, i, j, a, d, b, e, g) {
	if ("normalBuy" == g) {
		j = $("#regionHid").val();
		a = $("#regionName").val()
	}
	c = $.trim(c);
	j = $.trim(j);
	var f = c.substring(0, 3);
	var k = c.substring(3, 7);
	var l = c.substring(7, 11);
	var h = new Date().getTime();
	$("#numinfoDialog_telnum").html(
			'号码：<span class="font_size_24 gray5">' + f
					+ '-<span class="red_F40">' + k + "</span>-" + l
					+ "</span><span>(" + a + ")</span></p>");
	$("#numinfoDialog_preSum").html(i);
	$("#numinfoDialog_numMincostfee").html(d);
	$("#vaImage").attr("src",
			$("#contextPath").val() + "image.action?time=" + h);
	if (b != "null" && b != "" && b != "999") {
		$("#numinfoDialog_signTime").html(
				'<span class="red_F40 bold">' + b + "</span> 年 ")
	} else {
		$("#numinfoDialog_signTime").html("长期有效 ")
	}
	$("#lockNum").click(function() {
		sendBuy(c, i, j, a, e);
		return false
	});
	$(".dialogOverlay").show();
	$(".dialogBody").show()
}
function preBook(c, i, j, a, e, b, d, g) {
	if ("normalBuy" == g) {
		j = $("#regionHid").val();
		a = $("#regionName").val()
	}
	c = $.trim(c);
	j = $.trim(j);
	var f = c.substring(0, 3);
	var k = c.substring(3, 7);
	var l = c.substring(7, 11);
	var h = new Date().getTime();
	$("#numinfoDialog_telnum").html(
			'号码：<span class="font_size_24 gray5">' + f
					+ '-<span class="red_F40">' + k + "</span>-" + l
					+ "</span><span>(" + a + ")</span></p>");
	$("#numinfoDialog_preSum").html(i);
	$("#numinfoDialog_numMincostfee").html(e);
	$("#vaImage").attr("src",
			$("#contextPath").val() + "image.action?time=" + h);
	if (b != "null" && b != "" && b != "999") {
		$("#numinfoDialog_signTime").html(
				'<span class="red_F40 bold">' + b + "</span> 年 ")
	} else {
		$("#numinfoDialog_signTime").html("长期有效 ")
	}
	$("#lockNum").click(function() {
		sendBook(c, i, j, a, d);
		return false
	});
	$(".dialogOverlay").show();
	$(".dialogBody").show()
}
var couldSubmit = true;
function sendBuy(c, f, g, a, e) {
	var h;
	var d;
	var b;
	if ($("#cproductId").val()) {
		h = $("#cproductId").val()
	} else {
		h = ""
	}
	if ($("#temp_Id").val()) {
		d = $("#temp_Id").val()
	} else {
		d = ""
	}
	if ($("channel").val()) {
		b = $("channel").val()
	} else {
		b = ""
	}
	$("input[value='确认选定']").attr("disabled", true);
	$("input[value='取消']").attr("disabled", true);
	if (h != null && h != "") {
		if (g != $("#product_region").val()
				&& "999" != $("#product_region").val()) {
			$("#numinfoDialog_info span").html("对不起，您选择的号码所属地市与已选商品地市不一致");
			$("input[value='确认选定']").attr("disabled", false);
			$("input[value='取消']").attr("disabled", false);
			return false
		}
	}
	if (d != null && d != "") {
		if (g != $("#product_region").val()
				&& "999" != $("#product_region").val()) {
			$("#numinfoDialog_info span").html("对不起，您选择的号码所属地市与已选套餐地市不一致");
			$("input[value='确认选定']").attr("disabled", false);
			$("input[value='取消']").attr("disabled", false);
			return false
		}
	}
	if (couldSubmit) {
		couldSubmit = false
	} else {
		return false
	}
	$("#numinfoDialog_info span").html("正在提交……");
	var i = $("#cx_numPreValidatcode").val();
	$.postRequest(
			$("#contextPath").val() + "numAjax/numNewAjax!lockNum.action", {
				telNum : c,
				region : g,
				code : i,
				vproductId : $("#vproductId").val()
			}, function(j) {
				$("#cx_numPreValidatcode").attr("disabled", "");
				$("#cx_numPreValidatcode").val("");
				if (j.toShoppingCart == true) {
					telNumTempOne = c;
					regionTempOne = g;
					if (isLogin()) {
						addToCartDBOfTypeLoginAll(c, g)
					} else {
						addToCartOfTypeNoLoginNet(c, g)
					}
				} else {
					if (j.returnMsg == 1) {
						addVprodIdsToCookie(j.vproductId);
						urlSubmit($("#contextPath").val()
								+ "numshow/productTempChoice.action",
								'{"telNum":"' + c + '","vproductId":"'
										+ j.vproductId + '","cproductId":"' + h
										+ '","tempId":"' + d + '","regions":"'
										+ g + '","code":"' + i
										+ '","regionName":"' + a
										+ '","channel":"' + b + '","isJt":"'
										+ e + '"}')
					} else {
						if (j.returnMsg == 0) {
							if (j.alertMsgBean2 == undefined) {
								$("#numinfoDialog_info span").html(
										"对不起，您选择的号码已经被预占或者售出")
							} else {
								$("#numinfoDialog_info span").html(
										j.alertMsgBean2.msgText)
							}
							$("input[value='确认选定']").attr("disabled", false);
							$("input[value='取消']").attr("disabled", false);
							couldSubmit = true
						} else {
							if (j.returnMsg == 2) {
								if (j.alertMsgBean1 == undefined) {
									$("#numinfoDialog_info span").html("验证码错误")
								} else {
									$("#numinfoDialog_info span").html(
											j.alertMsgBean1.msgText)
								}
								changeImage();
								$("input[value='确认选定']")
										.attr("disabled", false);
								$("input[value='取消']").attr("disabled", false);
								couldSubmit = true
							} else {
								if (j.returnMsg == 5) {
									$("#numinfoDialog_info span").html(
											"网路超时，请稍后再试");
									$("input[value='确认选定']").attr("disabled",
											false);
									$("input[value='取消']").attr("disabled",
											false);
									couldSubmit = true
								} else {
									$("#numinfoDialog_info span").html(
											"对不起，您选择的号码已经被预占或者售出");
									$("input[value='确认选定']").attr("disabled",
											false);
									$("input[value='取消']").attr("disabled",
											false);
									couldSubmit = true
								}
							}
						}
					}
				}
			})
}
function sendBook(b, d, c, e, a) {
	if (couldSubmit) {
		couldSubmit = false
	} else {
		return false
	}
	$("#numinfoDialog_info span").html("正在提交……");
	$("input[value='确认选定']").attr("disabled", true);
	$("input[value='取消']").attr("disabled", true);
	$("#cx_numPreValidatcode").attr("disabled", "disabled");
	$.postRequest($("#contextPath").val()
			+ "numAjax/numNewAjax!lockNum2.action", {
		telNum : b,
		region : c,
		code : $("#cx_numPreValidatcode").val()
	}, function(f) {
		$("#cx_numPreValidatcode").attr("disabled", "");
		$("#cx_numPreValidatcode").val("");
		if (f.returnMsg == 1) {
			urlSubmit($("#contextPath").val()
					+ "numshow/bookingNumShow!init.action",
					'{"vproductId":"' + f.vproductId + '" }')
		} else {
			if (f.returnMsg == 0) {
				$("#numinfoDialog_info span").html("对不起，您选择的号码已经被预占或者售出");
				$("input[value='确认选定']").attr("disabled", false);
				$("input[value='取消']").attr("disabled", false);
				couldSubmit = true
			} else {
				if (f.returnMsg == 2) {
					$("#numinfoDialog_info span").html("验证码错误");
					changeImage();
					$("input[value='确认选定']").attr("disabled", false);
					$("input[value='取消']").attr("disabled", false);
					couldSubmit = true
				} else {
					if (f.returnMsg == 5) {
						$("#numinfoDialog_info span").html("网路超时，请稍后再试");
						$("input[value='确认选定']").attr("disabled", false);
						$("input[value='取消']").attr("disabled", false);
						couldSubmit = true
					} else {
						$("#numinfoDialog_info span").html(
								"对不起，您选择的号码已经被预占或者售出");
						$("input[value='确认选定']").attr("disabled", false);
						$("input[value='取消']").attr("disabled", false);
						couldSubmit = true
					}
				}
			}
		}
	})
}
function changeImage() {
	$("#vaImage")
			.attr(
					"src",
					$("#contextPath").val() + "image.action?dt="
							+ new Date().getTime());
	$("#cx_numPreValidatcode").val("")
}
function addVprodIdsToCookie(b) {
	var a = getVprodIdsFromCookie();
	if (a == null) {
		createVprodIdsCookie(b)
	} else {
		b = a + "," + b;
		createVprodIdsCookie(b)
	}
}
function getVprodIdsFromCookie() {
	var a = $.cookie("vprodIds");
	return a
}
function createVprodIdsCookie(a) {
	$.cookie("vprodIds", a, {
		expires : 2 / 24,
		path : "/"
	})
}
function addToCartDBOfTypeLoginAll(c, e) {
	var f = $("#vproductId").val();
	var d = $("#channel").val();
	var a = "";
	var b = "prodid=" + f + "&rprodid=&prodtype=2&rlgroupid=&bindphone=" + c
			+ "&quantity=1&region=" + e + "&channel=" + d + "&activecode=" + a;
	var g = $("#contextPath").val() + "shoppingCartAjax!addProdToCart.action";
	$
			.ajaxRequest( {
				url : g,
				data : b,
				dataType : "json",
				type : "POST",
				success : function(h) {
					if (h.loginMessage != undefined) {
						window.location.reload();
						return false
					}
					if (h.returnMsg == "PASS") {
						window.location.href = $("#contextPath").val()
								+ "shoppingCart.action"
					} else {
						var i = addToCartMsg(h.returnMsg);
						i += '<div class="clear"></div><span ><a style="cursor: hand;color:#439bfd;" href="' + $(
								"#contextPath").val() + 'shoppingCart.action" target="_blank">查看购物车</font>&nbsp;&nbsp;<a  style="cursor: hand;color:#439bfd;" onclick="clearCart();">清空购物车</a><br></span><span id="clearCartDone" style="color:red;">&nbsp;</span>';
						showMsg(i)
					}
				}
			})
}
function addToCartOfTypeNoLoginNet(b, d) {
	var e = $("#vproductId").val();
	var c = $("#channel").val();
	var a = "";
	if (!isExitsOfPT_23(b)) {
		$
				.ajaxRequest( {
					url : $("#contextPath").val()
							+ "shoppingCartAjax!checkRuleOfType2.action",
					data : "prodid=" + e + "&bindphone=" + b + "&channel=" + c,
					dataType : "json",
					type : "POST",
					success : function(f) {
						if (f.returnMsg == "PASS") {
							var g = selectProductCookie();
							var h = buildOneProduct(e, "", 2, b, 1, d, c, a);
							if (g == null) {
								createProductCookie(h)
							} else {
								h = g + "" + h;
								createProductCookie(h)
							}
							window.location.href = $("#contextPath").val()
									+ "shoppingCart.action"
						} else {
							var i = addToCartMsg(f.returnMsg);
							i += '<div class="clear"></div><span ><a style="cursor: hand;color:#439bfd;" href="' + $(
									"#contextPath").val() + 'shoppingCart.action" target="_blank">查看购物车</font>&nbsp;&nbsp;<a  style="cursor: hand;color:#439bfd;" onclick="clearCart();">清空购物车</a><br></span><span id="clearCartDone" style="color:red;">&nbsp;</span>';
							showMsg(i)
						}
					}
				})
	} else {
		showMsg("购物车中已存在此商品，无需再添加")
	}
}
function isExitsOfPT_23(d) {
	var a = $.cookie("WSSC-CART");
	if (a != null) {
		prodList = a.split("#");
		for ( var b = 0; b < prodList.length; b++) {
			var c = prodList[b];
			if (c.indexOf(d) != -1) {
				return true
			}
		}
		return false
	} else {
		return false
	}
}
function selectProductCookie() {
	var a = $.cookie("WSSC-CART");
	return a
}
function createProductCookie(a) {
	$.cookie("WSSC-CART", a, {
		expires : 30,
		path : "/"
	})
}
function buildOneProduct(d, a, i, e, c, h, g, b) {
	var f;
	if (i == 1) {
		f = d + ":" + a + ":" + i + ":::" + c + ":" + h + ":" + g + ":" + b
				+ "#"
	} else {
		if (i == 2) {
			f = d + "::" + i + "::" + e + ":1:" + h + ":" + g + ":" + b + "#"
		} else {
			if (i == 4) {
				f = d + ":" + a + ":" + i + "::" + e + ":1:" + h + ":" + g
						+ ":" + b + "#"
			}
		}
	}
	return f
}
function addToCartMsg(b) {
	if (b == "NOTPASS-MR") {
		try {
			$("#buyImBtn").attr("disabled", "");
			$("#addToCartBtn").attr("disabled", "")
		} catch (a) {
		}
		return "<span style='text-align:left'>尊敬的用户您好，您购物车中的商品包含有不同地市的业务，请您重新选购。</span>"
	} else {
		if (b == "NOTPASS-MP") {
			try {
				$("#buyImBtn").attr("disabled", "");
				$("#addToCartBtn").attr("disabled", "")
			} catch (a) {
			}
			return "<span style='text-align:left'>尊敬的用户您好，您购物车中有多个号码，请选择一个号码进行结算。</span>"
		} else {
			if (b == "NOTPASS-MF") {
				try {
					$("#buyImBtn").attr("disabled", "");
					$("#addToCartBtn").attr("disabled", "");
					$("div[id='checkPrivilegephoneDiv']").find(
							"input[id='yes']").attr("disabled", "")
				} catch (a) {
				}
				return "<span style='text-align:left;width:220px'>尊敬的用户您好，您购物车内有一件以上商品，请您选择一件商品结算，再选购其他商品。</span>"
			} else {
				if (b == "NOTPASS-SR") {
					try {
						$("#buyImBtn").attr("disabled", "");
						$("#addToCartBtn").attr("disabled", "")
					} catch (a) {
					}
					return "<span style='text-align:left'>简单规则校验未通过,不能加入购物车"
				} else {
					if (b == "NOTPASS-CN") {
						try {
							$("#buyImBtn").attr("disabled", "");
							$("#addToCartBtn").attr("disabled", "");
							$("div[id='checkPrivilegephoneDiv']").find(
									"input[id='yes']").attr("disabled", "")
						} catch (a) {
						}
						return "<span style='text-align:left;width:220px'>尊敬的用户您好，您购物车内有一件以上商品，请您选择一件商品结算，再选购其他商品。</span>"
					} else {
						if (b == "NOTPASS-ES") {
							try {
								$("#buyImBtn").attr("disabled", "");
								$("#addToCartBtn").attr("disabled", "")
							} catch (a) {
							}
							return "<span style='text-align:left;width:220px'>对不起，您选择的商品暂时缺货，请选择其他规格的商品。</span>"
						} else {
							if (b == "NOTPASS-OT") {
								try {
									$("#buyImBtn").attr("disabled", "");
									$("#addToCartBtn").attr("disabled", "")
								} catch (a) {
								}
								return "<span style='text-align:left;width:220px'>尊敬的用户您好，您输入的号码已参加过优惠购机活动，请您输入没有参加过活动的号码。</span>"
							} else {
								if (b == "NOTPASS-NN") {
									try {
										$("#buyImBtn").attr("disabled", "");
										$("#addToCartBtn").attr("disabled", "")
									} catch (a) {
									}
									return "<span style='text-align:left;width:220px'>尊敬的用户您好，您购物车内有一件以上商品，请您选择一件商品结算，再选购其他商品。</span>"
								} else {
									if (b == "NOTPASS-PT") {
										try {
											$("#buyImBtn").attr("disabled", "");
											$("#addToCartBtn").attr("disabled",
													"")
										} catch (a) {
										}
										return "<span style='text-align:left;width:220px'>尊敬的用户您好，您购物车内有一件相同类型的商品，您可以在购物车内编辑此商品的数量。</span>"
									} else {
										if (b == "NOTPASS-NA") {
											try {
												$("#buyImBtn").attr("disabled",
														"");
												$("#addToCartBtn").attr(
														"disabled", "")
											} catch (a) {
											}
											return "<span style='text-align:left;width:220px'>尊敬的用户您好，您已经购买此增值业务，请先结算或删除购物车内的商品。</span>"
										} else {
											if (b == "NOTPASS-MS") {
												try {
													$("#buyImBtn").attr(
															"disabled", "");
													$("#addToCartBtn").attr(
															"disabled", "")
												} catch (a) {
												}
												return "<span style='text-align:left;width:220px'>尊敬的用户您好，您购物车中已经添加了一种型号的手机，请先结算或删除此商品，再选购其他商品。</span>"
											} else {
												if (b == "NOTPASS-EXIST") {
													try {
														$("#buyCBbtn").attr(
																"disabled", "")
													} catch (a) {
													}
													return "<span style='text-align:left;width:220px'>尊敬的用户您好，您购物车内存在商品，请先结算或删除此商品，再选购组合商品。</span>"
												} else {
													try {
														$("#buyImBtn").attr(
																"disabled", "");
														$("#addToCartBtn")
																.attr(
																		"disabled",
																		"")
													} catch (a) {
													}
													return "未知错误:" + b
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
function showMsg(b) {
	var a = '<div id="msgWin" class="popBox_adapt_content"><img src="'
			+ $("#contextPath").val()
			+ 'resources/default/images/cartItem/alert-green.png" width="32" height="32" />'
			+ b;
	a += '<div class="tanchaun_btnbox"><a href="javascript:void(0)" id="closeBtn" class="tanchuan_btn" >确 定</a></div>';
	a += "</br></div>";
	$("body").append(a);
	$("#msgWin").dialog( {
		autoOpen : false,
		width : 350,
		title : "提示",
		zIndex : 999999999,
		draggable : true,
		modal : true,
		resizable : false
	}).dialog("open");
	$("#closeBtn,.ui-icon-closethick").click(function() {
		$("#msgWin").dialog("close");
		$("#msgWin").remove()
	})
}
function clearCart() {
	if (isLogin() == true) {
		$.ajaxRequest( {
			url : $("#contextPath").val()
					+ "shoppingCartAjax!deleteAllProduct.action",
			data : "date=" + new Date(),
			dataType : "json",
			type : "POST",
			success : function(a) {
				$("#clearCartDone").html("购物车清空成功...")
			}
		})
	} else {
		$.ajaxRequest( {
			url : $("#contextPath").val()
					+ "shoppingCartAjax!deleteAllRelationOfCK.action",
			data : "date=" + new Date(),
			dataType : "json",
			type : "POST",
			success : function(a) {
				deleteProductCookie();
				$("#clearCartDone").html("购物车清空成功...")
			}
		})
	}
	if (isLogin()) {
		addToCartDBOfTypeLoginAll(telNumTempOne, regionTempOne)
	} else {
		addToCartOfTypeNoLoginNet(telNumTempOne, regionTempOne)
	}
}
function deleteProductCookie() {
	$.cookie("WSSC-CART", null, {
		path : "/"
	})
};