	function fucCheckNUM(NUM)
	{
		var i,j,strTemp;
		strTemp="0123456789";
		if ( NUM.length== 0)
			return 0
		for (i=0;i<NUM.length;i++)
		{
			j=strTemp.indexOf(NUM.charAt(i));	
			if (j==-1)
			{
			//说明有字符不是数字
				return 0;
			}
		}
		//说明是数字
		return 1;
	}

	function clean(){ 
		if (confirm("您确实要取消预定吗?")==1){
			$.getScript("/pro_save.asp?typeid=2&rnd="+Math.random(),function(data,textStatus){});
			window.location.href="list.htm"
		}

	}

	function checknum(theform) 
	{
	//newprice="Q_"&rs("product_Id")
		if ((fucCheckNUM(theform.value)==0) )
		{	
		   theform.value="";
			//theform.newprice.focus();
			return false;
		}
	}
	function getdele(semder){
		if (confirm("您确实删除吗?")==1){
			var tr = $(semder).closest("tr");
			var producttype = tr.find("input[name=producttype]").val();
			var productid = tr.find("input[name=productid]").val();
			$.getScript("/pro_save.asp?typeid=1&productid="+productid+"&producttype="+producttype+"&rnd="+Math.random(),function(data,textStatus){
				if(_html)window.location.href="list.htm";
			});
			tr.remove();
			getTotal();
		}
	}
	function checkNumNull(theform) {
		if (theform.value=="") {	
		   alert("请填写购买产品的数量");
			//theform.newprice.focus();
			theform.focus();
			return false;
		}
	}
	function getTotal(){
		var quanitty = $("#form1 input[name=quantity]");
		var _total = 0;
		for(var i=0;i<quanitty.length;i++){
			var iquanitty = quanitty.eq(i).val();
			var iprice =  $("#form1 #price").eq(i).html();
			_total += Number(iquanitty)*Number(iprice);
		}
		 $("#totalnum").html(_total);
	}
	$(function(){
		$("#form1 input[name=quantity]").change(function(){
			var tr = $(this).closest("tr");
			var producttype = tr.find("input[name=producttype]").val();
			var productid = tr.find("input[name=productid]").val();
			var price = tr.find("#price");
			var totalprice = tr.find("#totalprice");
			var quantity = $(this).val();
			$.getScript("/pro_save.asp?typeid=3&productid="+productid+"&producttype="+producttype+"&quantity="+quantity+"&rnd="+Math.random(),function(data,textStatus){
				if(!_html){
					quantity = _quantity;
					alert("库存不足，共数"+quantity);
					tr.find("input[name=quantity]").val(quantity);
				}

				tr.find("#totalprice").html(Number(price.html())*Number(quantity));

				tr.find("#totalprice").html(Number(price.html())*Number(quantity));
				getTotal();
			});
		});
	});

	function getShopCart(proid,protype){
		$.getScript("/pro_save.asp?typeid=5&productid="+proid+"&producttype="+protype+"&rnd="+Math.random(),function(data,textStatus){
			if(_html){
				window.location.href="/shopCart.asp"
			}
		});
	}


	// Example:
	// alert( readCookie("myCookie") );
	function readCookie(name)
	{
	  var cookieValue = "";
	  var search = name + "=";
	  if(document.cookie.length > 0)
	  { 
		offset = document.cookie.indexOf(search);
		if (offset != -1)
		{ 
		  offset += search.length;
		  end = document.cookie.indexOf(";", offset);
		  if (end == -1) end = document.cookie.length;
		  cookieValue = unescape(document.cookie.substring(offset, end))
		}
	  }
	  return cookieValue;
	}
	// Example:
	// writeCookie("myCookie", "my name", 24);
	// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.

	function writeCookie(name, value)
	{
	  var expire = "";
		expire = new Date((new Date()).getTime() + 24 * 365 * 3600000);
		expire = "; expires=" + expire.toGMTString();
	  document.cookie = name + "=" + escape(value) + expire;
	}

	function changeStyle(n){
		$("#divprstyle").attr("class",n);
		writeCookie("cc_style",n);
	}
	
	$(function(){
		var sCookiesStyle = readCookie("cc_style");
		if(!sCookiesStyle) sCookiesStyle="pr-list01"; 
		changeStyle(sCookiesStyle);
	});


	(function($) {

		$.fn.extend({
			productlist: function(options) {
				return this.each(function() {
					var sender = $(this);
					var url = "search_product.asp?rnd="+Math.random();
					sender.unautocomplete()
					.autocomplete(url, {
						max: 0
						,minChars: 0
						,width: 320
						,matchContains: "word"
						,autoFill: false
						,formatItem: function(row){return row[0]+"/"+row[1]+"/"+row[2];}
						,formatResult: function(row){return row[0];}
					})
					.result(function(event, data, formatted) {
						var product = (data[1]);
						$(this).val(product);
					}).change(function(){
					});


				});
			}

		});

	})(jQuery);


	$(function(){
		$("#indexform input[name=skey]").productlist();
	});
	
	function getbbsreg(UserName,password,UserEmail,PasswordQuestion,PasswordAnswer){
		if(UserName && password && UserEmail){
			$.post("/bbs/CreateUser.asp?UserName="+UserName,{
					menu:"AddUserName",
					UserName:UserName,
					UserPassword:password,
					RetypePassword:password,
					UserEmail:UserEmail,
					PasswordAnswer:PasswordAnswer,
					PasswordQuestion:PasswordQuestion,
					rnd:Math.random()
				},
				function (data){
					//document.write(data);
				}
			);
		}
	}

	function getlogin(){
		var u = $("input[name=Username]").val();
		var p = $("input[name=Password]").val();
		if(u && p){
			$.post("/bbs/login.asp",{
					UserName:u,
					UserPassword:p,
					rnd:Math.random()
				},
				function (data){
					$("#formlogin").submit();
				}
			);
			
		}else{
			alert("用户名密码不能为空");
			return false;
		}
	}
