﻿EWS.ESHOP = {};//定义命名空间:EWS.ESHOP

//公共方法
EWS.ESHOP.common = function(){};

EWS.ESHOP.common.prototype = {

	IsEmpty : function(v){
		return $.trim(v).length?true:false;
	}
		
	/**
	 * 分页组件
	 */
	,createPage : function(pageNum , pageTotal,parents,part){

		var pageGroup = 5;//设定分页页码组数量
		var groupNum = parseInt( (pageNum - 1) / pageGroup , 10) + 1;//计算出当前页码所在分组
		var start = (groupNum - 1) * pageGroup + 1;//起始点
		var end = groupNum * pageGroup > pageTotal ? pageTotal : groupNum * pageGroup;//结束点
		var nextGroupNum = start + pageGroup;//下一组分页页码
		nextGroupNum = nextGroupNum > pageTotal ? pageTotal : nextGroupNum;
		var prevGroupNum = pageGroup * (groupNum - 1);//上一组分页页码
		prevGroupNum = prevGroupNum < 1 ? 1 : prevGroupNum;
		var nextNum = pageNum+1;
		nextNum = nextNum > pageTotal ? pageTotal : nextNum;
		var prevNum = pageNum-1;
		prevNum = prevNum < 1 ? 1 : prevNum;
	
		var nextGroup = "javascript:eshop_"+this.config.objId+".jumpPage("+nextGroupNum+","+pageNum+","+pageTotal+",'"+part+"');";
		var nextPage = "javascript:eshop_"+this.config.objId+".jumpPage("+nextNum+","+pageNum+","+pageTotal+",'"+part+"');";//下一页
	//	var nextText = "第 "+nextGroupNum+" 页";
		var prevPage = "javascript:eshop_"+this.config.objId+".jumpPage("+prevNum+","+pageNum+","+pageTotal+",'"+part+"');";//上一页
		var prevGroup = "javascript:eshop_"+this.config.objId+".jumpPage("+prevGroupNum+","+pageNum+","+pageTotal+",'"+part+"');";
	//	var prevText = "第 "+prevGroupNum+" 页";
		
		var a = "";
		for(var i=start; i <= end; i++){
			var href = "javascript:eshop_"+this.config.objId+".jumpPage("+i+","+pageNum+","+pageTotal+",'"+part+"');";
			if( i == pageNum ){
				a += '<a hidefocus="true" title="" href="'+href+'" class="status">'+i+'</a>';
			}else{
				a += '<a hidefocus="true" title="" href="'+href+'">'+i+'</a>';
			}
		}
		var code = '<a hidefocus="true" title="第一页" href="'+prevGroup+'" class="first"></a><a hidefocus="true" title="上一页" href="'+prevPage+'" class="previous"></a>' +
				'<span>'+a+'</span>' +
				'<a hidefocus="true" title="下一页" href="'+nextPage+'" class="next"></a><a hidefocus="true" title="最后一页" href="'+nextGroup+'" class="last"></a>';
		
		if(!parents){
			var obj = $('#'+this.config.objId);
			var parents = obj.find('.page_list2');
			var parents = parents.eq(0);
		}
		parents.html(code);
	}

	/**
	 * 跳转到指定页码
	 * @param {Number} jumpPage  跳转页码
	 * @param {Number} pageNum   当前页页码
	 * @param {Number} pageTotal 总页数
	 */
	,jumpPage : function(jumpPage , pageNum , pageTotal,part){
		
		if(jumpPage == pageNum){
			return;
		}
		
		//设置锚点标记，第一位：分类ID，第二位：页码

		if(this.type == 'eshop_productDetail'){
			if(part)
				this.getPageData(part,jumpPage);
		}

	}
	
	/**
	 * 设置缩略图大小及居中
	 * img {Object} 
	 * img.src : 图片地址
	 * img.id  : 图片id
	 */
	,setSmallPicSize : function(img,size,overPic){
		var oimg = new Image();
		oimg.src = img.src;
		if(oimg.width){
			var scale = this.getImageScale(oimg.width,oimg.height,size[0],size[1]);
			$(img).css({position:'relative',top:(size[1]-scale[1])/2,width:scale[0],height:scale[1]});
			if(overPic){
				img.width = oimg.width;
				img.height = oimg.height;
				this.setImageLayer(img);
			}
		}else{
			var self = this;
			setTimeout(function(){self.setSmallPicSize(img,size);},20);
		}
	}
	
	
	/**
	 * 计算出比例值，若含有小数点则取出小数点两位
	 * 
	 * @param {Number}
	 *            num1 原始值
	 * @param {Number}
	 *            num2 参考值
	 * @return {Number}
	 */
	,getImageScale : function(originalWidth, originalHeight, maxWidth, maxHeight) {
		var _CalculateScale = function(num1, num2) {
			var Temp = num2 / num1;
	
			if (Temp.length > 1) {
				return num2;
			} else {
				return parseFloat(Temp.toString().substring(0, 4));
			};
		};
		
	    if(originalWidth>0 && originalHeight>0){   
		    if(originalWidth/originalHeight>= maxWidth/maxHeight){   
		        if(originalWidth>maxWidth){   
		        	newWidth = maxWidth;
		        	newHeight = (originalHeight*maxWidth)/originalWidth;
		        }else{   
		        	newWidth = originalWidth;
		        	newHeight = originalHeight;
		        }   
		     }else{   
		        if(originalHeight>maxHeight){  
		        	newWidth = (originalWidth*maxHeight)/originalHeight;
		        	newHeight = maxHeight;
		        }else{   
		        	newWidth = originalWidth;
		        	newHeight = originalHeight;
		        }   
		    }   
	    }  
		return [newWidth, newHeight];
	}
	
    ,setImageLayer : function(img){
		var src = img.src.split('/');
		if(src[src.length-1] != 'noImg.png'){
			var _this = this;
			var target  = $(img);
			target.mouseover(function(event){
		
				var x = event.pageX == null ? event.clientX : event.pageX;
				var y = event.pageY == null ? event.clientY : event.pageY;
				_this.showImgLayer(this,x,y);
			});
			
			target.mouseout(function(event){
				_this.hideImgLayer(img);
			});
		};
	}
	
	,hideImgLayer : function(){
		$("#"+this.config.objId+"_zoomPic").remove();
	}
	
	,showImgLayer : function(img,_x,_y){
		var id = this.config.objId+"_zoomPic";
		var div = $.find("#"+id);
		var maxWidth = 200;
		var maxHeight = 100;
		var pageSize = EWS.GetPageSize();
		var scrollSize = EWS.GetPageScroll();
		var scale = this.getImageScale(img.width , img.height , maxWidth , maxHeight);		
		var x = _x + 50;
		var y = _y + 50;
		var originalX = scale[0] + x;
		var maxY = pageSize.WinH + scrollSize.Y;
		var originalY = scale[1] + y;
		y = maxY >= originalY ? y : y - (originalY - maxY) - 50;
		
		x = (_x+531)>pageSize.WinW?(_x-((_x+531)-pageSize.WinW)):_x;
		if(div.length==0){
			var target = $('<div id="'+id+'" class="ord_zoomPic">' +
					'<img src="/theme/order/img/indicator.gif" width="20px" height="20px"/>' +
				'</div>'
			).css({width:maxWidth,height:maxHeight,"z-index":1,top:y,left:x,display:'none'}).appendTo("body");
			target.fadeIn("fast");
		}else{
			$("#"+id).css({width:maxWidth,height:maxHeight,"z-index":1,top:y,left:x});
		};
	
		if(this.IsInterResource(img.src)){
			img.src = img.src.replace('_s.','.');
		}
		this.getOriginalPicSize(img);
	}
	
	,IsInterResource : function(url){
		if(url){
			if(url.indexOf('ipc.local')>0||url.indexOf('ipc.com')>0){
				return true;
			}
		}
		return false;
	}
	
	,getOriginalPicSize : function(img){
		var oimg = new Image();
		oimg.src = img.src;
		if(oimg.width){
			var maxWidth = 531;
			var maxHeight = 384;
			var scale = this.getImageScale(oimg.width,oimg.height,maxWidth,maxHeight);
			var id = this.config.objId+"_zoomPic";
			var imgObj = $('#'+id).find('img');
			imgObj.attr('src','');
			imgObj.attr('src',img.src);
			imgObj.css({width:scale[0],height:scale[1]});
			$('#'+id).css({width:scale[0],height:scale[1]});
		}else{
			var self = this;
			setTimeout(function(){self.getOriginalPicSize(img);},20);
		}
	}
	
	/**
	 * 返回图片最大尺寸
	 * obj参数内容由其所属项决定
	 */
	,returnWidthHeight : function(obj){
		var width = '';
		var height = '';
		var styleid = this.config.styleid;
		switch(this.type){//p
			case 'eshop_productDetail' :
				if(obj.isBig == true){//大图
					return styleid == '1'?[328,284]:[338,284];
				}else{//小图
					return styleid == '1'?[73,57]:[71,63];
				}
			break;
		}
		
		styleid = styleid?Number(styleid):1;
	 	switch(this.type){
	 		case 'GetCatalogProductList' :
	 		    if(typeof(p) == 'string'){
	 		    	return [406,269];
	 		    }else if(typeof(p) == 'boolean'){
	 		    	return [55,56];
	 		    }else{
		 		    switch(styleid){
						case 1:
							return [177,128];   
						case 2:
							return [111,111];   
						case 3:
							return [130,113];   
						case 4:
							return [177,168];   
						case 5:
							return [117,93];   
						case 6:
							return [85,68];   
		 		    };
	 		    }
	 			break;
	 			
	  		case 'getDetailSelfPage':
	 		case 'GetProductDetail' :
	 			if(p == 'bigImg'){//显示大图
					switch(styleid){
				 		    	case 1 :
				 		    		return [328,284];
				 		        case 2 :
				 		        	return [338,284];
				 		        case 3 :
				 		        	return [370,269];
				 		    };
				};
	 		    switch(styleid){
	 		    	case 1 :
	 		    		return p?[89,84]:[328,284];
	 		        case 2 :
	 		        	return p?[55,56]:[338,284];
	 		        case 3 :
	 		        	return p?[49,40]:[370,269];
	 		    };
	 			break;
	 		//商品列表
	 		case 'eshop_showCatalogProduct' :
//			    if(p == 'bigImg'){
//			    	return [406,269];
//			    }else if(p == true){
//			    	return [55,56];
//			    };
	 		    switch(styleid){
					case  1 :
						return [185,166];   
					case  2 :
						return [130,122];   
					case  3 :
						return [114,114];   
					case  4 :
						return [157,130];   
					case  5 :
						return [173,152];   
					case  6 :
						return [120,130];   
					case  8 :
						return [177,128];   
				};
				break;
			//所谓的混搭
			case 'eshop_showMoreProduct' :
//			    if(p == 'bigImg'){
//			    	return [406,269];
//			    }else if(p == true){
//			    	return [55,56];
//			    };
				switch(styleid){ 
					case  1 :
						return [130,122];   
					case  3 :
						return [114,114]; 
					case  4 :
						return [157,130];   
					case  5 :
						return [173,152];  
					case  6 :
						return [120,130];  
					case  8 :
						return [185,166];
					case 2 :
					    return [73,75];  
					default:
					    return [354,216];
				};
				break;
			//多功能商品列表	
			case 'eshop_multiFunProducts' :
				switch(styleid){ 
					case  1 :
						return [112,112];
					case  2 :
						return [129,129];
					case  3 :
						return [114,110]; 
				}
			break;
			//最近浏览商品	
			case 'eshop_newReadProducts':
				switch(styleid){ 
					case  1 :
						return [90,90];
					case  2 :
						return [80,80];
					case  3 :
						return [80,80]; 
				}
			break;
			
			//会员中心 留言商品图片	
			case 'eshop_memberCenter':
				switch(styleid){ 
					case  1 :
						return [56,56];
					case  2 :
						return [80,80];
					case  3 :
						return [80,80]; 
				}
			break;
			
			
			case 'orders_productOrdersSearch':
			case 'orders_fullearch':
			    if(p == 'bigImg'){
			    	return [406,269];
			    }else if(p == true){
			    	return [55,56];
			    };
			    break;
	 	}
}
		
};

/**
 * 订单搜索
 */
EWS.ESHOP.eshop_searchOrder = function(config){
 	this.config = config;
	this.type = 'eshop_searchOrder';
	$("#"+config.objId).find('input').bind('click',function(){
		if(this.value == '请输入订单号'){
			this.value = '';
		}
	});
	$('#'+this.config.objId).find('.searchBtn').bind('click',function(){
		var dom = $("#"+config.objId).find('input');
		var input = $.trim(dom.val());
		if(input&&input!="请输入订单号"){
		    if(config.openType == '1'){
		    	window.open('Shop_OrderDetail.aspx?SearchWord='+input);
		    }else{
		    	window.location.href = 'Shop_OrderDetail.aspx?SearchWord='+input;
		    }
		}else{
			dom.val('请输入订单号');
		};;
	});
	
};

EWS.ESHOP.eshop_searchOrder.prototype = {
	
};


/**
 * 购物车列表
 */
EWS.ESHOP.eshop_shopCarList = function(config){
 	this.config = config;
	this.type = 'eshop_shopCarList';
	
};

EWS.ESHOP.eshop_showCatalogProduct = function(config){
 	this.config = config;
	this.type = 'eshop_showCatalogProduct';	
	this.IsExtend = false;
	if(this.IsExtend == false){
		$.extend(EWS.ESHOP.eshop_showCatalogProduct.prototype,EWS.ESHOP.common.prototype);
		this.IsExtend = true;
	}
	var size = this.returnWidthHeight(config.styleid||1);
	var img = $('#'+this.config.objId +' img.shop_dealImg');
	var len = img.length;
	for(var i=0;i<len;i++){
		this.setSmallPicSize(img[i],size,'overPic');
	}
	
};


/**
 * 商品搜索
 */
 EWS.ESHOP.eshop_searchProduct = function(config){
	this.config = config;
	this.type = 'eshop_searchProduct';
	

	$("#"+config.objId).find('input[name="searchword"]').bind('click',function(){
		if(this.value == '请输入商品名称'){
			this.value = '';
		}
	});
	var self = this;
	
	$('#'+this.config.objId).find('.searchBtn').bind('click',function(){
		var dom = $("#"+config.objId).find('input[name="searchword"]');
		var input= $.trim(dom.val());
//		if(input&&input!="请输入商品名称"){
	//	v = v=="请输入商品名称"?"":v;
	    if(config.openType == '1'){
	    	window.open('Shop_ProductSearch.aspx?SearchWord='+encodeURIComponent(encodeURIComponent(input))+'&CategoryID=0');
	    }else{
	    	window.location.href = 'Shop_ProductSearch.aspx?SearchWord='+encodeURIComponent(encodeURIComponent(input))+'&CategoryID=0';
	    }
//		}else{
//			dom.val('请输入商品名称');
//		};
	});
	$('#'+this.config.objId).find('#showNode').bind('click',function(){
			var b = this; 
		    if(!self.JsTree){
				var JsTree = new EWS.ESHOP.JsTree("showNode", "hideNode",config.HttpUrl,config.objId);
				JsTree.newtree2("/Interface/Shop_Catalog_ListALL.aspx?cid="+self.config.CID+"&parentid=0",JsTree,config.objId,function(){
					$(b).click();
				});
				self.JsTree = JsTree;
		    }
	});
 };

EWS.ESHOP.eshop_searchProduct.prototype = {
	init : function(){}
};


/**
 * 全功能搜索
 */
EWS.ESHOP.eshop_allFunSearch = function(config){
	this.config = config;
	this.type = 'eshop_allFunSearch';
	var part = $('#'+config.objId);
	var self = this;
	
	//第一款样式选择按键事件
 	var btn = part.find('.ord_searchBar_bar a');
 	btn.eq(0).attr('key',1); 
 	btn.eq(1).attr('key',2); 
 	btn.bind('click',function(evt){
 		evt.preventDefault();
 		var obj = $(this);
 		if(obj.parent().hasClass('status')) return;
		var dom = $('#'+config.objId);
		var key = obj.attr('key');
		if(config.styleid == '1'){//商品搜索
	 		if(key == 1){
	 			dom.find('input[name="orderId"]').hide();
	 			dom.find('input[name="productName"]').show();
	 			dom.find('.ord_treediv').show();
	 		}else{//订单搜索
	 			dom.find('input[name="productName"]').hide();
	 			dom.find('.ord_treediv').hide();
	 			dom.find('input[name="orderId"]').show();
	 		}
			var div = dom.find('.bar_center_bg>div');
			if(key == '1'){
				div[0].className = 'status';
				div[1].className = '';
			}else{
				div[1].className = 'status';
				div[0].className = '';
			}
		}
		
 	});
 	
 	var productSearch = function(s){
	 	var v = part.find('input[name="productName"]').val();
	 	var CategoryID = 0;
	 	if(s.JsTree){
	 		CategoryID = s.JsTree.curId;
	 	}
//		if(v&&v!="请输入商品名称"){
		v = v=="请输入商品名称"?"":v;
		if(config.openType == '1'){
	    	window.open('Shop_ProductSearch.aspx?SearchWord='+encodeURIComponent(encodeURIComponent(v))+'&CategoryID='+CategoryID);
	    }else{
	    	window.location.href = 'Shop_ProductSearch.aspx?SearchWord='+encodeURIComponent(encodeURIComponent(v))+'&CategoryID='+CategoryID;
	    }
//		}else{
//			part.find('input[name="productName"]').val('请输入商品名称');
//		}
 	};
 	
 	var orderSearch = function(){
	 	var v = part.find('input[name="orderId"]').val();
		if(v&&v!="请输入订单号"){
			if(config.openType == '1'){
		    	window.open('Shop_OrderDetail.aspx?SearchWord='+v);
		    }else{
		    	window.location.href = 'Shop_OrderDetail.aspx?SearchWord='+v;
		    }
		}else{
			part.find('input[name="orderId"]').val('请输入订单号');
		}
 	} 
 	
 	var searchBtn = part.find('.searchBtn');
 	if(config.styleid == '1'){//第一种样式
 		searchBtn.bind('click',function(){
	 		var key = part.find('.bar_center_bg .status a').attr('key');
	 		if(key == '1'){//商品搜索
				productSearch(self);
	 		}else{//订单搜索
				orderSearch();
	 		}
 			
 		});
 	}
 	
 	if(config.styleid == '2'||config.styleid == '3'){
 		searchBtn.eq(0).bind('click',function(){
 			productSearch(self);
 		});
 		searchBtn.eq(1).bind('click',function(){
 			orderSearch();
 		});
 	}
 	
 	if(config.styleid == '4'){
 		var button = part.find('button');
 		button.eq(0).bind('click',function(){
 			productSearch(self);
 		});
 		button.eq(1).bind('click',function(){
 			orderSearch();
 		});
 	}
	
	part.find('.shoppingBtn').bind('click',function(){
		 window.open("Shop_Cart.aspx");
	});
	
	part.find('input[name="orderId"]').bind('click',function(){
		if(this.value == '请输入订单号'){
			this.value = '';
		}
	}).bind('blur',function(){
		if(this.value == ''){
			this.value = '请输入订单号';
		}
	});
	
	part.find('input[name="productName"]').bind('click',function(){
		if(this.value == '请输入商品名称'){
			this.value = '';
		}
	}).bind('blur',function(){
		if(this.value == ''){
			this.value = '请输入商品名称';
		}
	});
	
	part.find('#showNode').bind('click',function(){
		var b = this; 
	    if(!self.JsTree){
			var JsTree = new EWS.ESHOP.JsTree("showNode", "hideNode",config.HttpUrl,config.objId);
			JsTree.newtree2("http://"+config.HttpUrl+"/Interface/Shop_Catalog_ListALL.aspx?cid="+config.CID+"&parentid=0",JsTree,config.objId,function(){
				$(b).click();
			});
			self.JsTree = JsTree;
	    }
	});
   
};

/**
 * 购物车
 */
EWS.ESHOP.eshop_shopCar = function(config){
	this.config = config;
	this.type = 'eshop_shopCar';
	$('.shop_shoppingBtn').bind('click',function(){
		 window.open("Shop_Cart.aspx");
	});
};


/**
 * 生成订单号
 */
 
EWS.ESHOP.eshop_completedOrder = function(config){
	this.config = config;
	this.type = 'eshop_completedOrder';
};

/**
 * 订单详细
 */
EWS.ESHOP.eshop_orderDetail = function(config){
	this.config = config;
	this.type = 'eshop_orderDetail';
}; 


/**
 * 提交打单(确认购物车信息)
 */
EWS.ESHOP.eshop_referOrder = function(config){
	this.config = config;
	this.type = 'eshop_referOrder';
	
	$('input[name="IsInvoice"]').bind('click',function(){//税率
		 var oPrice = $('#eshop_TotalProductPrice').html();
		 var price = Number(Invoice)*Number(oPrice);
		 with(Math){
		 	price = round(price*pow(10,2))/pow(10,2);
		 }
	     if(this.checked){
			$('#eshop_InvoicePrice').html(price+'');
	     }else{
	     	$('#eshop_InvoicePrice').html('0');
	     }
	     //计算最终价格
	     getTotalPrice();
	     
	});
	
	
	
	
	$('input[name="IsSellFen"]').bind('click',function(){//积分抵消
		 var sellPrice = $('#sellPrice').html();
	     if(this.checked){
			$('#eshop_SellPrice').html(sellPrice+'');
	     }else{
	     	$('#eshop_SellPrice').html('0.00');
	     }
	     //计算最终价格
	     getTotalPrice();
	});
	
	
	var getTotalPrice = function(){//计算最终价格
		var oPrice = $('#eshop_TotalProductPrice').html();
		
	    //积分抵销
		var pr1 = $('#eshop_SellPrice').html();
		
		var pr2 = $('#eshop_InvoicePrice').html();
		
		var pr3 = $('#eshop_ExpressPrice').html();
		
//		$('#eshop_TotalPrice').html((Number(oPrice)- Number(pr1)+Number(pr2)+Number(pr3)).toFixed(2)+'');
		$('#eshop_TotalPrice').html((Number(oPrice)- Number(pr1)+Number(pr2)+Number(pr3)).toFixed(2)+'');
	
	}
	
	$('select[name="ExpressType"]').bind('change',function(){//选择运送方式
		var v = this.value.split(',')[1];
		
		$('#eshop_ExpressPrice').html(v);
		//计算最终价格
		getTotalPrice();
		
	});
	
	
	$('input[name="order_invoice"]').bind('click',function(){//需要发票输入内容
		if(!this.key){
		    this.value = '';
		    this.key = 1;
		}
	});
	

	
	//初始化状态
	$('select[name="ExpressType"]')[0].options[0].selected=true;
	$('input[name="IsInvoice"]').attr('checked',false);
	$('input[name="IsSellFen"]').attr('checked',false);
	$('input[name="order_invoice"]').val('请输入发票抬头');
	
	//隐藏提交验证提示问题
	var dom = $('#'+config.objId);
	$('.shop_info .errortips').hide();
	
	
	//提交前要验证数据
//	$('.payBtn').bind('click',function(){
//		alert('in');
//		var dom = $('#'+config.objId);
//		var errortips = $('.shop_info .errortips');
//		
//		return false;
//	});
	
	
		
	$('input[name="SubmitOrder"]').bind('click',function(){//提交表单
		var dom = $('#'+config.objId);
		var errortips = $('.shop_info .errortips');
		if($('input[name="IsInvoice"]').attr('checked')){
			var v = $.trim($('input[name="order_invoice"]').val());
			if(v == ''||v == '请输入发票抬头'){
			    alert('请输入发票抬头');
			    $('input[name="order_invoice"]').val('').focus();
			    return false;
			}
		}
		var input = $('.shop_info .shop_info_input');
		
		var name = input.eq(0).val().Trim();
		if(name == ''){
			errortips.eq(0).html('请填写收货人').show();
			return false;
		}else{
			errortips.eq(0).hide();
		}
		
		var tel = input.eq(1).val().Trim();
		if(tel == ''){
			errortips.eq(1).html('请填写联系电话').show();
			return false;
		}else{
			var reg = /^\d+(\.\d+)?$/;
			if(!reg.test(tel)){
				errortips.eq(1).html('请填写联系电话').show();
				return false;
			}
			errortips.eq(1).hide();
		}
		
		
		var mail = input.eq(2).val().Trim();
		if(mail == ''){
			errortips.eq(2).html('请填写电子邮箱').show();
			return false;
		}else{
			var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
			if(!reg.test(mail)){
				errortips.eq(2).html('请正确填写电子邮箱').show();
				return false;
			}
		}
		
		var address = input.eq(3).val().Trim();
		if(address == ''){
			errortips.eq(3).html('请填写联系地址').show();
			return false;
		}else{
			errortips.eq(3).hide();
		}
		
		
		var post = input.eq(4).val().Trim();
		if(post == ''){
			errortips.eq(4).html('请填写邮政编码').show();
			return false;
		}else{
			errortips.eq(4).hide();
		}
		
		
		return true;
//		$(this).parent().parent()[0].submit();
	});
	
	
};

/**
 * 最近浏览商品
 */
EWS.ESHOP.eshop_newReadProducts = function(config){
	this.config = config;
	this.type = 'eshop_newReadProducts';
	this.IsExtend = false;
	
	if(this.IsExtend == false){
		$.extend(EWS.ESHOP.eshop_newReadProducts.prototype,EWS.ESHOP.common.prototype);
		this.IsExtend = true;
	}
	var size = this.returnWidthHeight(config.styleid||1);
	var img = $('#'+this.config.objId +' img.shop_dealImg');
	var len = img.length;
	for(var i=0;i<len;i++){
		this.setSmallPicSize(img[i],size,'overPic');
	}
	$('#'+config.objId).find('li').bind('mouseover',function(){
		 this.className = 'shop_zindex';
	}).bind('mouseout',function(){
		 this.className = '';
	});
	
	
	//解决第三种样式在IE情况下点击问题（点击li没反应）
	if(config.styleid == '3'){
		if($.browser.msie){
			var a = $('#'+this.config.objId +' li>a');
			if(a.length){
				$('#'+this.config.objId +' li').bind('click',function(evt){
					var url = $(this).find('a')[0].href;
					if(config.openType == '1'){
						window.open(url);
					}else{
						window.location.href = url;
					}
				});

			}
			
			a.bind('click',function(evt){
				evt.preventDefault();
			});
		}
	}
	
};


/**
 * 会员注册
 */
EWS.ESHOP.eshop_memberRegister = function(config){
	this.config = config;
	this.type = 'eshop_memberRegister';	
	var dom = $('#'+config.objId);
	this.checkEmail = false;//检查邮件状态
	this.checkAccount = false;//检查帐号状态
	var self = this;
	dom.find('input[name="email"]').bind('blur',function(){//检查邮件
	    var thisInput = this;
		var v = $.trim(this.value);
		var check = self.checkEmailval(v);
		if(check == false)return;
		$.ajax({
			url:"interface/Shop_Register_CheckEmail.aspx",//考虑到适应所有域名访问，所以使用绝对路径
			type:'get',
			data:{cid:config.CID,email:dom.find('input[name="email"]').val()},
			cache:false,
			dataType:'json',
			complete:function(result){
				var data = eval("("+result.responseText+")");
				var parent = $(thisInput.parentNode);
				if(data.success){
					self.checkEmail = false;
					parent.find('.key').show();
					parent.find('.rowError').remove();
				}else{
					parent.find('.rowError').remove();
					parent.find('.key').hide();
					parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">'+data.info+'</div></div>');					
				}
			}
		});
	});
	
	
	dom.find('input[name="account"]').bind('blur',function(){//检查帐号
	    var thisInput = this;
		var v = $.trim(this.value);
		self.checkAccount = true;
		if(v == '') return;
		$.ajax({
			url:"interface/Shop_Register_CheckMember.aspx",//考虑到适应所有域名访问，所以使用绝对路径
			type:'get',
			data:{cid:config.CID,member:dom.find('input[name="account"]').val()},
			cache:false,
			dataType:'json',
			complete:function(result){
				var data = eval("("+result.responseText+")");
				var parent = $(thisInput.parentNode);
				if(data.success){
					self.checkAccount = false;
					parent.find('.key').show();
					parent.find('.rowError').remove();
				}else{
					parent.find('.key').hide();
					parent.find('.rowError').remove();
					parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">'+data.info+'</div></div>');					
				}
			}
		});
	});
	//提交
	dom.find('.register_btn').bind('click',function(){
		self.checkEmail = true;
		var email = $.trim(dom.find('input[name="email"]').val());
		if(self.checkEmailval(email)){
			self.checkEmail = false;
		}else{
			var parent = dom.find('input[name="email"]').parent();
			parent.find('.key').hide();
			parent.find('.rowError').remove();
			parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">请正确输入邮件地址</div></div>');
			return;					
		};
		
		if($.trim(dom.find('input[name="account"]').val())){
			self.checkEmail = false;
		}else{
			var parent = dom.find('input[name="account"]').parent();
			parent.find('.key').hide();
			parent.find('.rowError').remove();
			parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">请正确输入帐号</div></div>');	
			return;				
		};
		
		if(!self.checkAccount&&!self.checkEmail){//邮箱,帐号通过后
			var pwd1 = $.trim(dom.find('input[name="pwd1"]').val());
			var pwd2 = $.trim(dom.find('input[name="pwd2"]').val());
			if(pwd1!=pwd2){
				var parent = dom.find('input[name="pwd1"]').parent();
				parent.find('.key').hide();
				parent.find('.rowError').remove();
				
				var parent = dom.find('input[name="pwd2"]').parent();
				parent.find('.key').hide();
				parent.find('.rowError').remove();
				parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">两次密码不一致。</div></div>');	
				return;
			}
			if(pwd1== ''){
				var parent = dom.find('input[name="pwd2"]').parent();
				parent.find('.key').hide();
				parent.find('.rowError').remove();
				var parent = dom.find('input[name="pwd1"]').parent();
				parent.find('.key').hide();
				parent.find('.rowError').remove();
				parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">请填写密码</div></div>');	
				return;
			}
			var vilidate = $.trim(dom.find('input[name="code"]').val());
			if(vilidate == ''){
				var vDom = dom.find('input[name="code"]');
				var d = vDom.parent().find('.rowError');
				if(d.length){
					d.find('.shop_errorTips').html('请填写验证码');
					d.show();
				}else{
					vDom.parent().append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">请填写验证码</div></div>');
				}
				return;
			}
			if(dom.find('input[type="checkbox"]')[0].checked == false){
				alert('请浏览并确认使用协议');
				return;
			}
			$.ajax({
				url:"interface/Shop_Register.aspx",//考虑到适应所有域名访问，所以使用绝对路径
				type:'get',
				data:{cid:config.CID,email:email,member:dom.find('input[name="account"]').val(),pwd:pwd1,code:vilidate,submit:''},
				cache:false,
				dataType:'json',
				complete:function(result){
					var data = eval("("+result.responseText+")");
					if(data.success){
						if(data.data == '-2'){
							alert('激活邮件已经发送到您填写的注册邮箱，请到邮箱中激活账号');
							window.location.href="Shop_Login.aspx";
						}else{
							window.location.href="Shop_Member.aspx";
						}
					}else{
						if(data.data == 'error001'||data.data == 'error002'||data.data == 'error003'){//邮箱问题
							var parent = dom.find('input[name="email"]').parent();
							parent.find('.key').hide();
							parent.find('.rowError').remove();
							parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">'+data.info+'</div></div>');	
							self.checkEmail = false;
							return;
						}
						if(data.data == 'error004'||data.data == 'error005'||data.data == 'error006'){//帐号问题
							var parent = dom.find('input[name="account"]').parent();
							parent.find('.key').hide();
							parent.find('.rowError').remove();
							parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">'+data.info+'</div></div>');	
							self.checkAccount = false;
							return;
						}
						
						if(data.data == 'error007'||data.data == 'error009'){//密码问题
							dom.find('.rowError').show();
							dom.find('.shop_errorTips').show(data.info);
						}
						
						if(data.data == 'error008'){
							var vDom = dom.find('input[name="code"]');
							var d = vDom.parent().find('.rowError');
							if(d.length){
								d.find('.shop_errorTips').html('验证码不正确!');
								d.show();
							}else{
								vDom.parent().append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">验证码不正确!</div></div>');
							}
						}
			
					}
				}
			});
		}
	});
	
	
	this.checkEmailval = function(v){
		var regm = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;//验证Mail的正则表达式,^[a-zA-Z0-9_-]:开头必须为字母,下划线,数字,
		self.checkEmail = true;
		if(v == '') return false;
		if (!v.match(regm)){
			var parent = dom.find('input[name="email"]').parent();
			parent.find('.key').hide();
			parent.find('.rowError').remove();
			parent.append('<div class="rowError"><span class="error_icon"></span><div class="shop_errorTips">邮箱地址格式错误或含有非法字符!</div></div>');	
			return false;				
		}
		return true;
	};
	
	
	$('#'+config.objId).find('.validate_div>img').bind('click',function(){
    	this.src = 'InterFace/Shop_Validate.aspx?v=login&c='+new Date();
    });
	
}

/**
 * 会员登录
 */
EWS.ESHOP.eshop_memberLogin_rich = function(config){
	this.config = config;
	this.type = 'eshop_memberLogin_rich';
	

	
	var login_btn = $('#'+config.objId+' .login_btn');
	login_btn.bind('click',function(){
		 var dom = $('#'+config.objId);
		 var input = dom.find('input');
		 var userName = $.trim(input.eq(0).val());
		 var pwd = $.trim(input.eq(1).val());
		 var validate = $.trim(input.eq(2).val());
		 
		 var tips = dom.find('.shop_errorTips');
		 
		 if(userName == ""){
		 	tips.html("请填写帐号!").show();
		 	return;
		 }
		 
		 if(pwd == ""){
		 	tips.html("请填写密码!").show();
		 	return;
		 }
		 
		 if(validate == ""){
		 	tips.html("请填写验证码!").show();
		 	return;
		 }
		 
//		 var isWriteCookies = dom.find('input[type="checkbox"]').attr('checked');
		 tips.hide();
		 $.ajax({
			url:"interface/Shop_Sigin.aspx",//考虑到适应所有域名访问，所以使用绝对路径
			type:'get',
			data:{CID:config.CID,Member:userName,PassWord:pwd,ValidateCode:validate},
			cache:false,
			dataType:'json',
			complete:function(result){
				var data = eval("("+result.responseText+")");
				if(data.success){
					 if(typeof EWS.Monitor.V.SendNickName_Shop == 'function'){
						EWS.Monitor.V.SendNickName_Shop();
					 }
					 window.location.href = 'Shop_Member.aspx';

				}else{
					 if(data.data == '-1'){
					 	alert("您的账号未进行激活，请检查您注册账号时的邮箱进行激活");
					 }else{
						tips.html(data.info).show();
					 }
				}
			}
		});
		 
		 
	});
	 
	function keyListener(e){ 
	    e = e ? e : event; 
	    if(e.keyCode == 13){ 
	      login_btn.click();  
	    } 
	}
	document.onkeydown=keyListener;  
	 
    $('#'+config.objId).find('img').bind('click',function(){
    	this.src = 'InterFace/Shop_Validate.aspx?v=reg&c='+new Date();
    });
};

EWS.ESHOP.eshop_memberLogin_text = function(config) { };


EWS.ESHOP.eshop_memberForgotPassword = function(config){
	this.config = config;
	this.type = 'eshop_memberForgotPassword';
	$('#'+config.objId).find('.validate_div img').bind('click',function(){
    	this.src = 'InterFace/Shop_Validate.aspx?v=forgetpassword&c='+new Date();
    });
};

EWS.ESHOP.eshop_memberCenter = function(config){
	this.config = config;
	this.type = 'eshop_memberCenter';
	this.IsExtend = false;
	if(this.IsExtend == false){
		$.extend(EWS.ESHOP.eshop_memberCenter.prototype,EWS.ESHOP.common.prototype);
		this.IsExtend = true;
	}
	var template = getParam('template');
	
	$('#'+config.objId).find('.submitBtn').bind('click',function(){
    	var table = $('#'+config.objId).find('.infoTable');
//    	var name = $.trim(table.find('input[name="Name"]').val());
//    	var Sex = table.find('select[name="Sex"]').val();
//    	var year = table.find('select[name="year"]').val();
//    	var month = table.find('select[name="month"]').val();
//    	var day = table.find('select[name="day"]').val();
//    	
//    	var province = table.find('select[name="province"]').val();
//    	var city = table.find('select[name="city"]').val();
//    	var area = table.find('select[name="area"]').val();
    	
    	var Tel = table.find('input[name="Tel"]').val();
    	
    	var Phone = table.find('input[name="Phone"]').val();
    	
//    	var NumberID = table.find('input[name="NumberID"]').val();
//    	
//    	var Address = table.find('input[name="Address"]').val();
//    	
    	var post = table.find('input[name="post"]').val();
//    	var Content = table.find('textarea[name="Content"]').val();
    	
    	var reg = /^\d+(\.\d+)?$/;
		if($.trim(Tel)&&!reg.test($.trim(Tel))){
			alert('请正确填写固定电话!');
			return false;
		}
		
		if($.trim(Phone)&&!reg.test($.trim(Phone))){
			alert('请正确填写手机号码!');
			return false;
		}
		
		if($.trim(post)&&!reg.test($.trim(post))){
			alert('请正确填写邮编!');
			return false;
		}
//    	
//    	var param = {
//    		cid: config.CID
//    		,name: name
//    		,sex:Sex
//    		,age:year+'-'+month+'-'+day
//    		,province:province
//    		,city:city
//    		,area:area
//    		,address:Address
//    		,tel:Tel
//    		,phone: Phone
//    		,post:post
//    		,content:Content
//    	}
//    	var self = this;
//    	this.disabled = true;
//    	$.ajax({
//			url:"interface/Shop_EditUser.aspx",//考虑到适应所有域名访问，所以使用绝对路径
//			type:'get',
//			data:param,
//			cache:false,
//			dataType:'json',
//			complete:function(result){
//				self.disabled = false;
//				var data = eval("("+result.responseText+")");
//				if(data.success){
//					alert('修改成功');
//				}else{
//					alert(data.Info);
//				}
//			}
//		});
		return true;
    });
    
    var setArea = function(_this){
    	    if(_this.setAreaFlag) return;
    	    _this.setAreaFlag = true;
	    	var p = $('select[name="province"]').val();
	    	var c = $('select[name="city"]').val();
	    	var a = $('select[name="area"]').val();
	    	$('select[name="province"]')[0].innerHTML ='';
	    	//$('select[name="city"]')[0].innerHTML ='';
	    	//$('select[name="area"]')[0].innerHTML ='';
	    	if(p == ''){//初始化状态（没有填写过地区数据）
	    		new PCAS("province","city",'area');
	    	}else{
	    		new PCAS("province","city",'area',p,c,a);
	    	}
    };

	
	var initDate = function(){
		var table = $('#'+config.objId).find('.infoTable');
		var year = table.find('select[name="year"]');
    	var month = table.find('select[name="month"]');
    	var day = table.find('select[name="day"]');
    	
    	var year_v = year.val();
    	var month_v = month.val();
    	var day_v = day.val();
    	
    	
    	var nowTime = new Date();
    	var maxYear = nowTime.getFullYear();
    	var minYear = 1950;
    	
    	//年份
    	createSelect(year[0],minYear,(maxYear-minYear),year_v);
    	year.bind('change',function(){
    		var m = month.val();
			var thisYear = this.value;
			var daysInMonth = new Date(thisYear, m, 0).getDate();
			createSelect(day[0],1,daysInMonth,2009);
    	});
    	year[0].value = year_v;
    	
    	
    	//月份
    	createSelect(month[0],1,12,month_v);
    	month.bind('change',function(){
    		var y = year.val();
			var daysInMonth = new Date(y, this.value, 0).getDate();
			createSelect(day[0],1,daysInMonth,1);
    	});
    	month[0].value = month_v;
    	
    	//日
    	createSelect(day[0],1,31,1);
    	day[0].value = day_v;
    	
    	
		var script = document.createElement('script');
		script.id = 'p2_10_preview_js';
		script.src = '/Theme/Script/100801/PCASClass.js';
		script.type = "text/javascript";
		script.language = "javascript";
		
		var target = document.getElementsByTagName("head")[0];
		target.appendChild(script);
		
		this.setAreaFlag = false;
		var self = this;
		script.onload = script.onreadystatechange = function(){
			if($.browser.msie){
					setArea(self);
			}else{
				window.setTimeout(function(){
					setArea(self);
				},100);
			}
		};
	};
	
	//生成下拉选择
	var createSelect = function(oSelect, iStart, iLength, iIndex){
		if(oSelect!=undefined){
			oSelect.innerHTML = '';
			//添加option
			oSelect.options.length = iLength;
			for (var i = 0; i < iLength; i++) { 
				oSelect.options[i].text = oSelect.options[i].value = iStart + i; 
			}
		}
		//设置选中项
//		oSelect.selectedIndex = iIndex;
	};
    
	//会员资料修改
	if(template == 'InfoMation'){
    	initDate(config);
	}
    
    	
    //会员公告
    if(template == 'Bulletin'){
	   
	    //绑定点击标题时，显示内容
	    $(".showList .hover").bind('click',function(){
	        var id=	$(this).attr('key');
	         $(".showList .detail_msg").hide();
	         $("#notice_Content" + id).show();
	    });
    }
    
    //留言管理
    if(template == 'Comment'){
    	var size = this.returnWidthHeight(1);
		var img = $('.showList td a>img');
		var len = img.length;
		for(var i=0;i<len;i++){
			this.setSmallPicSize(img[i],size,'overPic');
		}
    }
    
};

/**
 * 多功能商品列表
 */
EWS.ESHOP.eshop_multiFunProducts = function(config){
	this.config = config;
	this.type = 'eshop_multiFunProducts';
	this.IsExtend = false;
	
	if(this.IsExtend == false){
		$.extend(EWS.ESHOP.eshop_multiFunProducts.prototype,EWS.ESHOP.common.prototype);
		this.IsExtend = true;
	}
	var size = this.returnWidthHeight(config.styleid||1);
	var img = $('#'+this.config.objId +' img.shop_dealImg');
	var len = img.length;
	for(var i=0;i<len;i++){
		this.setSmallPicSize(img[i],size,'overPic');
	}
	
	//解决第三种样式在IE情况下点击问题（点击li没反应）
	if(config.styleid == '3'){
		var param = getParam(this.config.objId+'_View');
		param = (param == ''||param == '0')?0:1;
		if($.browser.msie&&param==0){
			var a = $('#'+this.config.objId +' li>a');
			if(a.length){
				$('#'+this.config.objId +' li').bind('click',function(evt){
					var url = $(this).find('a')[0].href;
					if(config.openType == '1'){
						window.open(url);
					}else{
						window.location.href = url;
					}
				});

			}
			
			a.bind('click',function(evt){
				evt.preventDefault();
			});
		}
		
		if(param == 1){
			if($.browser.msie){
				$('#'+this.config.objId +' li div.goodsImg').bind('click',function(evt){
					var url = $(this).find('a')[0].href;
					if(config.openType == '1'){
						window.open(url);
					}else{
						window.location.href = url;
					}
				});
			}
		}
	}

};

/**
 * 混搭
 */
EWS.ESHOP.eshop_showMoreProduct = function(config){
	this.config = config;
	this.type = 'eshop_showMoreProduct';
	this.IsExtend = false;
	
	if(this.IsExtend == false){
		$.extend(EWS.ESHOP.eshop_showMoreProduct.prototype,EWS.ESHOP.common.prototype);
		this.IsExtend = true;
	}
	var size = this.returnWidthHeight(config.styleid||1);
	var img = $('#'+this.config.objId +' img.shop_dealImg');
	var len = img.length;
	for(var i=0;i<len;i++){
		this.setSmallPicSize(img[i],size,'overPic');
	}
};

EWS.ESHOP.eshop_showMoreProduct.prototype = {
	overShowProduct : function(obj,id){
		var dom = $('#'+this.config.objId);
		if(!this.config.current){
			var li = $('#'+this.config.objId).find('ul>li');
			li[0].style.display = 'block';
			li[1].style.display = 'none';
		}else{
			dom.find('#p1_'+this.config.current+'_b').hide();
			dom.find('#p1_'+this.config.current).show();
		}
		$(obj).hide();
		dom.find('#p1_'+id+'_b').show();
		this.config.current = id;
	}
};


/**
 * 
 */
EWS.ESHOP.eshop_multiCatalog = function(config){
	this.config = config;
	this.type = 'eshop_multiCatalog';
	
	if(config.styleid == '2'){
		var obj = $('#'+config.objId).find('.iconUl');
		obj.bind('click',function(evt){
			evt.preventDefault();
			var obj = $(this);
			if(obj.parent().hasClass("hide")){//原来隐藏
				obj.parent().removeClass('hide');
				obj.parent().find('ul').show();
			}else{//原来显示
				obj.parent().addClass('hide');
				obj.parent().find('ul').hide();
			}
			
		});
	}
	
	if(config.styleid == '1'){
		var obj = $('#'+config.objId).find('li.li_title strong');
		obj.bind('click',function(evt){
			evt.preventDefault();
			var obj = $(this);
			if(obj.hasClass("hide")){//原来隐藏
				obj.removeClass('hide');
				obj.find('ul').show();
			}else{//原来显示
				obj.addClass('hide');
				obj.find('ul').hide();
			}
		});
	}
	
	
};

/**
 * 商品详细
 */
EWS.ESHOP.eshop_productDetail = function(config){
	config.ProductID = getParam('pid');
	this.config = config;
	this.type = 'eshop_productDetail';
//	return;
//	var len = a.length;
//	var selectList = [];
//	for(var i=0;i<len;i++){
//		selectList.push(a.eq(i).attr('key'));
//	}
	if(this.IsExtend == false){
		$.extend(EWS.ESHOP.eshop_productDetail.prototype,EWS.ESHOP.common.prototype);
		this.IsExtend = true;
	}
	
	this.init();
};
EWS.ESHOP.eshop_productDetail.prototype = {
	
	IsExtend : false//设置继承公共方法默认值

    ,getSwitch : function(type){
		var url = '';
		var param = '';
		var what = '';
		var part = '.shop_proDescription';
        switch(type){
        	case 'isExpand' :
        	
        	break;
        	case 'isCombination' :
        	
        	break;
        	case 'isDetail' :
        		url = 'interface/Shop_GetProudectIntro.aspx';
        		param = {CID:this.config.CID,pid:this.config.ProductID};
        		what = 'isDetail';
        	break;
        	case 'isSpec' :
        		url = 'interface/Shop_GetFormat.aspx';
        		param = {CID:this.config.CID,pid:this.config.ProductID};
        		what = 'isSpec';
        	break;
        	case 'isMessage' :
        		url = 'interface/Shop_GetComment.aspx';
        		param = {CID:this.config.CID,pid:this.config.ProductID,page:1,pagesize:10};
        		what = 'isMessage';
        	break;
        	case 'isTransaction' :
        		url = 'interface/Shop_GetOrderRecord.aspx';
        		param = {CID:this.config.CID,pid:this.config.ProductID,page:1,pagesize:10};
        		what = 'isTransaction';
        	break;
        	case 'isRelatedGood' :
        	break;
        	case 'isRelatedArticles' :
        	break;
    	};
    	return [what,url,param];
    }
    
    ,init : function(){
	    var self = this;
	    var config = this.config;
	    var dom = $('#'+config.objId);
		if(config.styleid == '1'){//第一种样式才会有点击事件
			var a = dom.find('.shop_title>a');
			var part = '.shop_proDescription';
			a.bind('click',function(evt){
				evt.preventDefault();
				var key = $(this).attr('key');
				var okey = $(this.parentNode).find('.status').attr('key');
				if(key == okey)return;
	            var info = self.getSwitch(key);
		        self.showData(info[0],part,info[1],info[2]);
		        $(this.parentNode).find('.status').removeClass();
		        this.className = 'status';
			});
			if(a.length){
				var info = self.getSwitch(a.eq(0).attr('key'));
				self.showData(info[0],part,info[1],info[2]);
			}
		 }
		 //图片缩放问题(小图片)
		 var size = this.returnWidthHeight({isBig:false}); 
		 var bigSize = this.returnWidthHeight({isBig:true});
		 var img = dom.find('.shop_smallPic img');	
		 var len = img.length;
		 for(var i = 0;i<len;i++){//小图
			 this.setSmallPicSize(img[i],size,'');
		 }
		 var bigPic = dom.find('.shop_bigPic img').click(function(){
		 	window.open(this.src);
		 });
		 this.setSmallPicSize(bigPic[0],bigSize,'');
		 //第二种样式显示所有版块
		 if(config.styleid == '2'){
		 	 if(config.isDetail == '1'){
			 	 var info = self.getSwitch('isDetail');
			 	 self.showData(info[0],part,info[1],info[2]);
		 	 }
		 	 
		 	 if(config.isSpec == '1'){
			 	 var info = self.getSwitch('isSpec');
			 	 self.showData(info[0],part,info[1],info[2]);
		 	 }
		 	 
		 	 if(config.isTransaction == '1'){
			 	 var info = self.getSwitch('isTransaction');
			 	 self.showData(info[0],part,info[1],info[2]);
		 	 }
		 	 
		 	 
		 	 if(config.isMessage == '1'){
		 	 	 if($('.shop_feeback_content').length){//后台设置可以留言才能出显
				 	 var info = self.getSwitch('isMessage');
				 	 self.showData(info[0],part,info[1],info[2]);
		 	 	 }
		 	 }

		 }
		 
		 
		 //销售组合,店长推荐图片缩放
		var img = $('.shop_dealImg_ext');
		 var len = img.length;
		 if(img.length){
		 	for(var i=0;i<len;i++){
		 		var w = img.eq(i).css('width').replace('px','');
		 		var h = img.eq(i).css('height').replace('px','');
		 		this.setSmallPicSize(img[i],[w,h],'overPic');
		 	}
		 }
		 this.bindEvent();
	}
	//显示大图
	,setBigImg : function(object){
		var dom = $('#'+this.config.objId);
		var src = $(object).find('img').attr('src');
		if(src.indexOf('http') == -1){
			src = $(object).find('img').attr('src').replace('_s','');
		}
		var bigSize = this.returnWidthHeight({isBig:true});
		var img = dom.find('.shop_bigPic img')[0];
		img.src = src;
		this.setSmallPicSize(img,bigSize,'');
		var parent = $(object).parent().parent();
		parent.find('.status').removeClass();
		$(object).parent().addClass('status');
	}
	
	,bindEvent : function(){
		//点击小图看大图
		var self = this;
		var dom = $('#'+self.config.objId);
		var a = dom.find('.shop_smallPic li>a');
		a.bind('click',function(evt){
			evt.preventDefault();
			self.setBigImg(this);
//			var src = $(this).find('img').attr('src');
//			if(src.indexOf('http') == -1){
//				src = $(this).find('img').attr('src').replace('_s','');
//			}
//			var bigSize = self.returnWidthHeight({isBig:true});
//			var img = dom.find('.shop_bigPic img')[0];
//			img.src = src;
//			self.setSmallPicSize(img,bigSize,'');
//			var parent = $(this).parent().parent();
//			parent.find('.status').removeClass();
//			$(this).parent().addClass('status');
		});
		
		dom.find('.pic_zoom').click(function(evt){
			evt.preventDefault();
			window.open(dom.find('.shop_bigPic img')[0].src);
		});
		

		//点击收藏
		dom.find('.pro_bookmarks').click(function(evt){
			evt.preventDefault();
			$.ajax({
				url:"interface/Shop_Favorites_Add.aspx",//考虑到适应所有域名访问，所以使用绝对路径
				type:'get',
				data:{cid:self.config.CID,pid:getParam('pid'),pname:getParam('pname')},
				cache:false,
				dataType:'json',
				complete:function(result){
					var data = eval('('+result.responseText+')');
					if(data.success){
						alert('收藏成功!');
					}else{
					    alert(data.info);
					}
				}
			});
		});

		
		//创建浮动层(返回顶部)
		dom.find('.shop_returnTop').remove();
		var cls = this.config.styleid == '1'?'shop_returnTop_style1':'shop_returnTop_style2';
//		alert($('body').length)
//		var obj = $('body').append('<div class="'+cls+'"><a title="返回顶部"  href="#top"> 返回顶部</a></div>');
//		var obj = $('body').find('.'+cls);
		setTimeout(function(){
			$('body').append('<div class="'+cls+'"><a title="返回顶部"  href="#top"> 返回顶部</a></div>');
		},50);
		setInterval(function(){
			var obj = $('body').find('.'+cls);
			var sol = $(document).scrollTop(); 
			obj.css('top',sol+200+'px');
		},100);
		$('<p><a name="top"></a></p>').insertBefore("#wrapper"); 
		
						
		//点击扩展属性
		if(this.config.isExpand == '1'){
			dom.find('.shop_picshow .choosepart a').bind('click',function(evt){
				evt.preventDefault();
				//先清除已选择的项
				var obj = $(this);
				var brother = obj.parent().find('.status');
				var same = '';
				if(brother.length){
					same = brother.eq(0).attr('id');
				}
			    brother.removeClass();
			    obj.addClass('status');
			    
			    if(self.config.styleid == '2'){//第二套样式
				    var title = obj.parent().parent().find('.title').html();
				    var td = dom.find('.shop_picshow .pro_property td').eq(1);
				    if(same){
				    	td.find('div[id="'+same+'"]').eq(0).attr({'id':this.id}).html(title+' '+obj.html());
				    }else{
				    	td.find('div').eq(0).before('<div class="yourChoose" id="'+this.id+'">'+title+' '+obj.html()+'</div>');
				    }
			    }else{
			    	var yourChoose = dom.find('.shop_picshow .pro_property .yourChoose');
			    	if(yourChoose.length ==0){
			    		var html = '<div class="yourChoose">您已选：<strong><span id="'+this.id+'">'+obj.html()+'</span></strong></div>';
			    		dom.find('.shop_picshow .pro_property .pro_btn').before($(html));
			    	}else{
			    		if(same){
			    			yourChoose.find('span[id='+same+']').eq(0).attr({'id':this.id}).html(obj.html());
			    		}else{
				    		yourChoose.find('strong').append(',<span id="'+this.id+'">'+obj.html()+'</span>');
			    		}
			    	}
			    }
			});
		}

		dom.find('.shop_picshow .pro_amount').bind('blur',function(){			
			var v = $.trim(this.value);
			var r1= /^[0-9]*[1-9][0-9]*$/;
			if(!r1.test(v)){
				this.value = '';
			}
		});
		
		//放入购物车
		dom.find('.shoppingcarBtn').bind('click',function(evt){
			evt.preventDefault();
//			if(self.config.addFlag)
				self.sendData(1,'interface/Shop_Cart_Add.aspx');
		}).bind('mouseover',function(){
			self.checkStock();
		});
		//点击购买
		dom.find('.buyBtn').bind('click',function(evt){
			evt.preventDefault();
//			if(self.config.addFlag)
				self.sendData(2,'interface/Shop_Cart_Add.aspx');
		}).bind('mouseover',function(){
			self.checkStock();
		});
		
		//
		$('#inputAmount').bind('mouseover',function(){
			$('#eshop_buy_error').hide();
		});
		
		//将商品放入购物车后，回调成功会显示出一个层，这个可以关闭
		$(".buyclose").bind('click',function(evt){
			evt.preventDefault();
			$(this).parent().hide();
		});
		//同上一样功能
		$("#eshop_buy_close2").bind('click',function(evt){
			evt.preventDefault();
			$("#eshop_buy_ok").hide();
		});
				
		
		//小图的上下左右按键
		dom.find('.rightIcon').bind('click',function(evt){
			evt.preventDefault();
			var lastLi = dom.find('.shop_smallPic li:visible:last');
			if(lastLi.next().length){
				var firstLi = dom.find('.shop_smallPic li:visible:first');
				self.setBigImg(firstLi.next().find('a')[0]);
				firstLi.hide();
				lastLi.next().show();
			}
		});
		
		dom.find('.leftIcon').bind('click',function(evt){
			evt.preventDefault();
			var firstLi = dom.find('.shop_smallPic li:visible:first');
			if(firstLi.prev().length){
				var lastLi = dom.find('.shop_smallPic li:visible:last');
				self.setBigImg(lastLi.prev().find('a')[0]);
				lastLi.hide();
				firstLi.prev().show();
			}
		});
		
		//组合销售点击
		dom.find('.buyPackage').bind('click',function(){
			var buyPackage = this;
			if(this.state) return;
			this.state = 'ing';
			$.ajax({
				url:"interface/Shop_CartSell_Add.aspx",
				type:'post',
				data:{cid:self.config.CID,sellid:$(buyPackage).attr('key'),v:''},
				cache:false,
				dataType:'json',
				complete:function(result){
					var data = eval("("+result.responseText+")");
					if(data.success){
						buyPackage.state = '';
						window.location.href = 'shop_cart.aspx';
					}else{
						if(typeof data.data.productcount != 'undefined'){
							if(data.data.productcount == 0){
								alert('产品库存不足！');
							}
						}
					}
				}
			});
		});
		
		
		//组件销售左右
//		dom.find('.rightIcon').bind('click',function(evt){
//			evt.preventDefault();
//			var firstLi = dom.find('.shop_combin_list li:visible:first');
//			if(firstLi.prev().length){
//				var lastLi = dom.find('.shop_smallPic li:visible:last');
//				self.setBigImg(lastLi.prev().find('a')[0]);
//				lastLi.hide();
//				firstLi.prev().show();
//			}
//		});
//		dom.find('.leftIcon').bind('click',function(){
//			evt.preventDefault();
//			var lastLi = dom.find('.shop_smallPic li:visible:last');
//			if(lastLi.next().length){
//				var firstLi = dom.find('.shop_smallPic li:visible:first');
//				self.setBigImg(firstLi.next().find('a')[0]);
//				firstLi.hide();
//				lastLi.next().show();
//			}
//		});

        //处理IE情况下点击问题（点击li没反应）
		if($.browser.msie){
			var a = $('#'+this.config.objId +' .shop_recommended li>a');
			if(a.length){
				$('.shop_combin_list li').bind('click',function(evt){
					var url = $(this).find('a')[0].href;
					window.open(url);
				});
			}
			a.bind('click',function(evt){
				evt.preventDefault();
			});
		}
		

	}
	
	//检查库存量是否够
	,checkStock : function(){
		return;
		var num = $('.shop_pro_info .pro_amount input').val();
		var n = $('.shop_pro_info .pro_number span').html().replace(/[^0-9]/ig, "");
		if(Number(n)<Number(num)){
			this.config.addFlag = false;
			alert("您只能购买不超过"+n+"个商品");
			var obj = $('#outStockTips');
//			if(obj.length){
//				alert("您只能购买不超过"+num+"个商品");
//				obj.html("您只能购买不超过"+num+"个商品").show();
//			}else{
//				$('.shop_pro_info .pro_amount').append("<span id='outStockTips'>您只能购买不超过"+num+"个商品</span>");
//			}
		}else{
			this.config.addFlag = true;
			$('#outStockTips').hide();
		}
	}
	
	//检查提交数据(填写数量,扩展参数)
	,checkInfo : function(){
		var dom = $('#'+this.config.objId);
		//检查填写数量
		var v = $.trim(dom.find('.pro_property .pro_amount input').val());
		var r1= /^[0-9]*[1-9][0-9]*$/;
		if(!r1.test(v)){
			return [1];
		}
		
		//检查扩展参数
		var pro_color = dom.find('.shop_picshow .pro_color');
		var len = pro_color.length;
		var choose = '';
		if(len>0){
			if(this.config.styleid==1){
				choose = dom.find('.shop_picshow .yourChoose span');
			}else{
				choose = dom.find('.shop_picshow .yourChoose');
			}
			if(len>choose.length){
				return [2];
			}
		}
		var result = [];
		for(var i=0;i<choose.length;i++){
			result.push(choose[i].id);
		}
		return [v,result];
	}
	
	
	//查找未选择属性
	,getAttribute : function(){
		var dom = $('#'+this.config.objId);
		var pro_color = dom.find('.shop_picshow .pro_color');
		var len = pro_color.length;
		for(var i=0;i<len;i++){
			if(pro_color.eq(i).find('a.status').length == 0){
				if(pro_color.eq(i).find('strong').find('strong'))
					return pro_color.eq(i).find('strong').html();
				if(pro_color.eq(i).find('strong').find('span'))
					return pro_color.eq(i).find('strong').html();
			}
		}
	}
    
    


	
	/**
	 * 统一处理ajax数量
	 * what : 当前业务
	 * part : 要插入内容区
	 * url  : ajax地址
	 * param : 参数
	 */
	,showData : function(what,part,url,param){//组合搭配
	    var obj = '';
		var dom = $('#'+this.config.objId);
		var self = this;
		if(this.config.styleid == '1'){
			obj = dom.find(part+'>div[key="'+what+'"]');
			dom.find(part+' .shop_border:visible').hide();
			if(obj.length){//已存在区域,显示就OK
				obj.show();
				return;
			}else{
				obj = dom.find(part);
			}
		}else{
			obj = dom;
		}
		var set = function(Data){
			if(what!='isDetail'){
				Data = eval("("+Data.responseText+")");
			}else{
				Data = Data.responseText;
			}
			var cls = '';
			switch(what){
				case 'isExpand' :
	        		cls = 'shop_border shop_description_content';
	        	break;
	        	case 'isCombination' :
	        		cls = 'shop_border shop_combination';
	        	break;
				case 'isDetail':
					cls = 'shop_border shop_description_content';
					if(self.config.styleid == '1'){
						obj.append('<div class="'+cls+'" key="'+what+'">'+Data+'</div>');
					}else{
						obj.find('.shop_description_content').html(Data);
					}
				break;
				case 'isSpec':
					cls = 'shop_border shop_Specification_content';
					self.createTable(Data);
				break;
				case 'isMessage':
					cls = 'shop_border shop_feeback_content';
					self.showMessage(Data,1);
				break;
				case 'isTransaction':
					cls = 'shop_border shop_transRecord_content';
					self.showTransaction(Data,1);
				break;
				case 'isRelatedGood' :
					cls = 'shop_border shop_recommended';				
	        	break;
	        	case 'isRelatedArticles' :
					cls = 'shop_border shop_relatedArticles';	        	
	        	break;
			}
			
//			if(Data.success == 'true'){
//				obj.append('<div class="'+cls+'" key="'+what+'">'+Data.data+'</div>');
//			}
			obj.show();
		}
		
		this.ajax(url,param,set);
		
	}
	

	
	,showMessage : function(data,page){//留言板
		var dom = $('#'+this.config.objId);
		var self = this;
    	var html = [];
	    var returnli = function(lidata){
	    	var len = lidata.length;
	    	for(var i=0;i<len;i++){
	    		var cls = i%2?'':'libg';
	    		var re = lidata[i].recontent==''?'':'<span class="msg_reply"><strong>回复：</strong>'+lidata[i].recontent+'</span>';
	    		html.push('<li class="'+cls+'">'+
					'<span class="msg_time">'+lidata[i].addtime+'</span>'+
					'<span class="msg_title"><strong>留言标题：</strong>'+lidata[i].title+'</span>'+
					'<span class="msg_con"><strong>留言内容：</strong>'+lidata[i].content+'</span>'+re+'</li>');
//						    		html.push('<li class="'+cls+'">哈哈，有雪糕吃！哈哈，有雪糕吃！哈哈，有雪糕吃！哈哈，有雪糕吃！</li>');
	    	}
	    	return html.join('');
	    }
		
	 	if(data.success){
	 		var pid = getParam('pid');
			var parent = dom.find('.shop_feeback_content .shop_msg_list');
			var html = returnli(data.data.data);
			if(parent.length){//已存在
				parent.html(html);
				var pagePlace = dom.find('.shop_feeback_content .shop_detail_page');
			}else{
				var head = '';
				//分情况(样式1的parent跟样式2的parent不一样)
				if(this.config.styleid == '1'){
					parent = dom.find('.shop_proDescription');
					parent.append('<div class="shop_border shop_feeback_content " key="isMessage"></div>');	
					parent = parent.find('.shop_feeback_content');	
				}else{
					parent = dom.find('.shop_feeback_content');
				}
				if(html!=''){
					parent.html('').append('<ul class="shop_msg_list">'+html+'</ul>'+	
//                    parent.append('哈哈，有雪糕吃！哈哈，有雪糕吃！哈哈，有雪糕吃！哈哈，有雪糕吃！'+
								'<div class="shop_detail_page"></div><div class="dottedLine"></div>');
				}else{
					parent.append('<ul class="shop_msg_list"> 暂无留言!</ul>');
				}
				if(data.data.addcommenthide == '0'){
					parent.append('<table cellspacing="0" cellpadding="0" border="0" width="100%" class="feebackComment">' +
			  				'<tbody><tr>' +
							'<th>留言标题：</th><td><input type="text" class="inp1" name="title" id="messageTitle" value='+$(".shop_picshow_title strong").html()+'></td></tr><tr>'+
							'<th>留言内容：</th><td><textarea id="messageContent" name="content"></textarea></td></tr><tr>'+
							'<th>&nbsp;</th><td>' +
							'<input name="pid" type="hidden" value="'+pid+'"/><input name="cid" type="hidden" value="'+this.config.CID+'"/><input type="button" class="feebackBtn" value="提交评论"></td></tr></tbody></table>');
				}
				var pagePlace = parent.find('.shop_detail_page');
			}
			
			parent.find('.feebackBtn').unbind().bind('click',function(){
				var messageTitle = $.trim(parent.find('#messageTitle').val());
				var messageContent = $.trim(parent.find('#messageContent').val());
				if(messageTitle == ''||messageContent == ''){
					alert('请正确填写！');
					return; 
				}
				var button = this;
				this.disabled = true;
				var param ={
					pid : pid
					,cid:self.config.CID
					,messageTitle:messageTitle
					,messageContent:messageContent
				}
		    	$.ajax({
					url:"interface/Shop_SubmitComment.aspx",//考虑到适应所有域名访问，所以使用绝对路径
					type:'get',
					data:param,
					cache:false,
					dataType:'json',
					complete:function(result){
						button.disabled = false;
						var data = eval("("+result.responseText+")");
						parent.find('#messageTitle').val('');
						parent.find('#messageContent').val('');
						self.getPageData("isMessage",1);
						if(data.success){
						}else{
							alert(data.Info);
						}
					}
				});
//				$('#massageForm')[0].submit();
			});
			if(data.data.data.length)
				this.createPage(page , Math.ceil(parseInt(data.data.count)/10),pagePlace,'isMessage');
		}else{
			return '';
		}
	}
	
	
	,showTransaction : function(data,page){//成交记录
		var dom = $('#'+this.config.objId);
	    var returnli = function(lidata){
	    	var len = lidata.length;
	    	var html = [];
	    	for(var i=0;i<len;i++){
	    		var cls = i%2?'trbg':'';
	    		html.push('<tr class="'+cls+'"><td>'+(lidata[i].member||"游客")+'</td><td class="goodsTitle">'+
						'<strong><a href="?pid='+lidata[i].productid+'&pname='+lidata[i].productname+'" title="'+lidata[i].productname+'">'+lidata[i].productname+'</a></strong>'+
						'<span class="goodsInfo">'+lidata[i].property+'</span>'+
					'</td>'+
					'<td>'+lidata[i].price+'</td>'+
					'<td>'+lidata[i].amount+'</td>'+
					'<td>'+lidata[i].createddate+'</td>'+
					'<td>成交</td></tr>');
	    	}
	    	return html.join('');
	    }
		
	 	if(data.success){
			var parent = dom.find('.shop_border[key="isTransaction"]');
			var html = returnli(data.data.data);
			var p = '';
			if(parent.length){//已存在
				parent.find('.shop_record_list').html(html);
				var pagePlace = parent.find('.shop_detail_page');
			}else{
				var head = '';
				//分情况(样式1的parent跟样式2的parent不一样)
				if(this.config.styleid == '1'){
					parent = dom.find('.shop_proDescription');
					parent.append('<div class="shop_border shop_transRecord_content" key="isTransaction"></div>');	
					parent = parent.find('.shop_transRecord_content');	
				}else{
					parent = dom.find('.shop_transRecord_content');
				}
				parent.html('<table cellspacing="0" cellpadding="0" border="0" width="100%" class="shop_record_list"><tbody><tr><th class="goodsBuyer">购买者</th>'+
					'<th class="goodsTitle">商品名称</th>'+
					'<th class="goodsPrice">购买价</th>'+
					'<th class="goodsAmount">数量</th>'+
					'<th class="goodsTime">成交时间</th>'+
					'<th class="goodsstate">状态</th></tr>'+html+'</tbody></table><div class="shop_detail_page"></div>');
			}
		   var pagePlace = parent.find('.shop_detail_page');
			if(data.data.data.length)
				this.createPage(page , Math.ceil(parseInt(data.data.count)/10) || 0,pagePlace,'isTransaction',this.config.flag);
			this.config.flag = true;
		}else{
			
		}
	}
	
	, createTable: function(Table_datas) {
		var dom = $('#'+this.config.objId);
		var self = this;
//		var parent = dom.find('.shop_border[key="isSpec"]');
	    if(self.config.styleid == '1'){
	    	var parent = dom.find('.shop_proDescription');	
	    }else{
	    	var parent = dom.find('.shop_Specification_content');	
	    }

		if(Table_datas.success){
			var createCell = function(Table_data){
				
	    	    var row = 2;
	    	    var columns = 2;
	    	    var data = [];
	    	    if (Table_data) {//修改表格
	    	        row = Table_data.row || 1;
	    	        columns = Table_data.columns || 2;
	    	        data = Table_data.data;
	    	    };
	    	    if (!Table_data || Table_data.data.length == 0) {
	    	        var len = row * columns;
	    	        for (var i = 0; i < len; i++) {
	    	            data.push('');
	    	        }
	    	    }
	    	    var td = '';
	    	    var tr = '';
	    	    var len = 0;
//	    	    var width = self.tableWidth / (columns) + 'px';
	    	    for (var i = 0; i < row; i++) {//创建行
	    	        var td = 'th';
	    	        if(row>0){
	    	        	td = 'td';
	    	        }
	    	        tr += '<tr>';
	    	        for (var j = 0; j < columns; j++) {//创建列
	    	            len = columns * i + j;
	    	            tr += '<'+td+'>' + data[len] + '</'+td+'>';
	    	        }
	    	        tr += '</tr>';
	    	    }
    	    	return tr;
			}
			
			var Data = Table_datas.data;
			if(Data.length == 0){
				if(self.config.styleid == '1'){
	        		parent.append('<div class="shop_border shop_Specification_content" key="isSpec">暂无数据</div>');
				}else{
					parent.html('暂无数据');
				}
	        }else{
				var html = [];
				for(var m=0;m<Data.length;m++){
					var h = createCell(eval('('+Data[m].content+')'));
					html.push('<table class="area" cellspacing="0" cellpadding="0" border="0" width="100%">' + h + '</table>');
				}
				
				if(this.config.styleid == '1'){
	    	    	parent.append('<div class="shop_border shop_Specification_content" key="isSpec">' + html.join('<br><br>') + '</div>');
				}else{
					parent.append(html.join('<br><br>'));
				}
	        }
    	}
	}
	
	,ajax : function(url,param,callBack){
		$.ajax({
			url:url,
			type:'get',
			data:param,
			cache:false,
			dataType:'json',
			complete:function(result){
				callBack(result);
			}
		});
	}
	
	,getPageData : function(type,page){
		var info = this.getSwitch(type);
		info[2].page = page;
		var self = this;
		$.ajax({
			url:info[1],
			type:'get',
			data:info[2],
			cache:false,
			dataType:'json',
			complete:function(result){
				var data = eval("("+result.responseText+")");
				if(type == 'isMessage')
					self.showMessage(data,page);
				else
				    self.showTransaction(data,page);
			}
		});
	}
	

	
	/**
	 * 提交数据
	 * type : 类型(1表示放入购物车,2购买)
	 */
	,sendData : function(type,url){
			var result = this.checkInfo();
			if(result.length == 1){
				if(result[0] == 2){
					var tips = this.getAttribute();
					if(tips) 
						alert('请选择'+tips);
					else
						alert('请选择商品属性.');
				}
				if(result[0] == 1){
					alert('请填写购买商品数量');
				}
				return;
			}
			var self = this;
			$.ajax({
				url:url,
				type:'get',
				data:{cid:this.config.CID,pid:getParam('pid'),v:result[1].join(','),num:result[0]},
				cache:false,
				dataType:'json',
				complete:function(result){
					var result = eval('('+result.responseText+')');
					if(result.success){
						//根据type操作
						if(type == 2){
							window.location.href="Shop_Cart.aspx";
						}
						//显示购买成功的层
						if(type==1){ 
							$("#eshop_buy_ok").show('');
//							var num = $('.shoppingData').html();
							$.ajax({
								url:"interface/Shop_CartCountNum.aspx",
								type:'get',
								data:{CID:self.config.CID},
								cache:false,
								dataType:'json',
								complete:function(result){
									var data = eval("("+result.responseText+")");
									if(data.success)
										$('.shoppingData').html(data.data);
								}
							});
						}
					}else{
						if(typeof result.data.productcount!='undefined'){
							$('#eshop_stock').eq(1).html(result.data.productcount+'件');
							var obj = $('#eshop_buy_error');
							obj.show();
							if(result.data.productcount!='0')
								obj.find('p').html("要购买的商品库存不足,请重新输入！");
							else
							    obj.find('p').html("很抱歉，此商品暂时缺货！");
						}else{
							alert('提交失败！');
						}
						
					}
				}
			});
	}
	
	
	
	
};
