﻿EWS.Order = {};//定义命名空间:EWS.Order
EWS.Order.layerIndex = 100;//设置当前浮动层数

//定义类：商品发布--商品/分类列表
EWS.Order.GetCatalogProductList = function(config){
	this.type = 'GetCatalogProductList';
	this.config = config;
//	this.layerIndex = 100;//设置当前浮动层数
		
	this.initLoad = true;//标记初始读取数据:true
	
	//若有锚点信息，则设置为默认
	var anchor = EWS.Anchor.get("Order_"+this.config.id);
	if(anchor != null){
		this.config._catalogID = this.config.catalogID;//三四类风格需要用到
		this.config.catalogID = anchor.split(",")[0];
	};
	    
	if(config.picSize&&(config.picSize == 2||config.picSize == '2')){
		var size = [Number(config.picsizeW),Number(config.picsizeH)];
    }else{
		var size = this.returnWidthHeight(config.styleId);
	}
	this.config.size = size;
	
	if(anchor == null){
		var img = $('#'+this.config.id +' .pro_img');
		var len = img.length;
		for(var i=0;i<len;i++){
			this.setSmallPicSize(img[i],size,'overPic');
		}
		return;
	}
	
	var parent = $("#"+this.config.id);
	parent.html('');
	this.config.styleId = this.config.styleId?this.config.styleId:(config.itemStyle == 1?1:(config.itemStyle == 2?5:6));
	
	var lang = EWS.Language['E01003'];
//	var eshop_category = this.config.eshop_category?this.config.eshop_category:lang['E010034'];
//	var eshop_product = this.config.eshop_product?this.config.eshop_product:lang['E010035'];
	var eshop_category = lang['E010034'];
	var eshop_product = lang['E010035'];

	if(this.config.styleId == 1 || this.config.styleId == 2 ||this.config.styleId == 5 || this.config.styleId == 6 ){
		var page = this.config.styleId == 2?'ord_mop_page':'ord_page';
		$('<h3 id="'+this.config.id+'_CatalogTitle"></h3>').html(eshop_category+'：').addClass("ord_title").appendTo(parent);
		$('<ul id="'+this.config.id+'_Catalog" class="ord_sort">'+lang['E0100312']+'</ul>').appendTo(parent);
		$('<h3 id="'+this.config.id+'_ProductTitle" class="ord_title"></h3>').html(eshop_product+'：').addClass("ord_title").appendTo(parent);
		$("<div id='"+this.config.id+"_Product'>"+lang['E0100312']+"</div>").appendTo(parent);
		$("<div class='"+page+"'></div>").appendTo(parent);
	}else{
		if(this.config.styleId == 3){
			var html = '<div class="waresort_left" ><div class="waresort_top"><span>'+eshop_category+'</span></div><ul class="waresort_first" id="'+this.config.id+'_Catalog"></ul></div>'+
			           '<div class="waresort_right"><div class="waresort_title" ><span>'+eshop_product+'</span></div><div id="'+this.config.id+'_Product">'+lang['E0100312']+'</div><div class="ord_mop_page"></div></div>';
		}else{
			var html = '<div class="waresort_left" ><h3>'+eshop_category+'</h3><ul class="waresort_first" id="'+this.config.id+'_Catalog"></ul></div>'+
			           '<div class="waresort_right"><h3>'+eshop_product+'</h3><div id="'+this.config.id+'_Product">'+lang['E0100312']+'</div><div class="ord_mop_page"></div></div>';
		}
		parent.append(html);
	}
	this.getCatalog(this.config.catalogID);
};

/**
 * 获取商品分类
 * @param {Number} parentID　商品分类父级ID
 */
EWS.Order.GetCatalogProductList.prototype.getCatalog = function(parentID){	

//	var eshop_category = this.config.eshop_category?this.config.eshop_category:EWS.Language['E01003']['E010034'];
	var eshop_category = EWS.Language['E01003']['E010034'];
	
	//若parentID不存在则使用config.catalogID代替
	if(parentID==undefined){
		parentID = this.config.catalogID;
	}else{
		this.config.catalogID = parentID;
	};
	//判断样式类型（1，2为同一种类型，3与4是另一种类型）
	if(this.config.styleId == 1 || this.config.styleId == 2||this.config.styleId == 5 || this.config.styleId == 6){
		this.getCatalogByA(parentID,eshop_category);
	}else{//3与4是另一种类型
		this.getCatalogByB(parentID,eshop_category);
	}
	
};

/**
 * 获取商品分类(1同2类型)
 * @param {Number} parentID　商品分类父级ID
 */
EWS.Order.GetCatalogProductList.prototype.getCatalogByA = function(parentID,tName){
	/**
	 * 获取商品分类，响应操作
	 * @param {Object} result
	 */
	var lang = EWS.Language['E01003'];
	var _this = this;
	var _get_success = function(result){
		var title = $("#"+this.config.id+'_CatalogTitle');
		var ul = $('#'+this.config.id+'_Catalog');
		var TopCatalog = lang['E010031'];
		
		if(result.Path.length == 0){
			title.html(tName+'：<a href="javascript:Order_'+_this.config.id+'.setCatalog(\'0\',"1");">'+TopCatalog+'</a>');
			ul.html(lang['E010036']);
			var product = $('#'+this.config.id+'_Product');
			product.html(lang['E010036']);
			return;
		};
		
		var titlePath = [];

		$.each(result.Path , function(i,v){
			if(v.ID != 0){
				var name = v.Name;
			}else{
				var name = lang['E010031'];
			};
						
			titlePath.push("<a hidefocus='true' href='javascript:Order_"+_this.config.id+".setCatalog(\""+v.ID+"\",1);'>"+name+"</a>");
		});
		title.html(tName+'：'+titlePath.join("&nbsp;&nbsp;>&nbsp;&nbsp;"));
		
		ul.html("");
		$.each(result.Catalog , function(i,v){
			ul.append("<li><a hidefocus='true' key='"+v.ID+"'  href='javascript:Order_"+_this.config.id+".setCatalog(\""+v.ID+"\",\""+v.CategoryCount+"\");'>"+v.Name+"</a></li>");
		});
		if(result.Catalog.length == 0){
			ul.html(lang['E010036']);
		}
		var anchor = EWS.Anchor.get("Order_"+this.config.id);
		if(anchor == null){
			var pageNum = 1;
		}else{
			var pageNum = parseInt(anchor.split(",")[1]);
		};
		this.getProduct(pageNum);
	};
	
	$.ajax({
		url:"/EWS_Interface/Order_ListCatalog.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{CID:this.config.cid,ParentID:parentID},
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result);
		}
	});
};

/**
 * 获取商品分类(3同4类型)
 * @param {Number} parentID　商品分类父级ID
 */
EWS.Order.GetCatalogProductList.prototype.getCatalogByB = function(parentID,tName){
	/**
	 * 获取商品分类，响应操作
	 * @param {Object} result
	 */
	var _this = this;
	var _get_success = function(result){
		var ul = $('#'+this.config.id+'_Catalog');
		var len = result.length;
		if(len == 0){
			ul.html(EWS.Language['E01003']['E010031']);
			return;
		};

		$.each(result , function(i,v){
			if(v.ID != 0){
				var name = v.Name;
			}else{
				var name = EWS.Language['E01003']['E010036'];
			};
			if(_this.config.styleId == 3){
				if((i+1) == len){
					ul.append('<li class="waresort_last2" key="waresort_last2" id="c_'+v.id+'"><a hidefocus="true" href="javascript:Order_'+_this.config.id+'.setCatalogB(\''+v.id+'\');" title="'+v.name+'">'+v.name+'</a></li>');
				}else{
					ul.append('<li id="c_'+v.id+'"><a hidefocus="true" href="javascript:Order_'+_this.config.id+'.setCatalogB(\''+v.id+'\');" title="'+v.name+'">'+v.name+'</a></li>');
				}
			}else{
				ul.append('<li id="c_'+v.id+'"><a hidefocus="true" href="javascript:Order_'+_this.config.id+'.setCatalogB(\''+v.id+'\');" title="'+v.name+'">'+v.name+'</a></li>');
			};
			if(v.children.length){
				createTreeCell(v.id,v.children,((i+1) == len));
			}
		});

		
		var anchor = EWS.Anchor.get("Order_"+this.config.id);
		if(anchor == null){
			var pageNum = 1;
		}else{
			var pageNum = parseInt(anchor.split(",")[1]);
			    if((this.config.styleId == 4 ||this.config.styleId == 3)&&this.config.catalogID!='0'){
			    	$('#c_'+this.config.catalogID).find('a')[0].className = 'active'; 
			    	var obj = $('#c_'+this.config.catalogID).parent();
			    	obj.css('display','block');
			    	var pr = obj.parent().parent();
			    	if(pr[0].tagName == 'UL'&&pr[0].className!='waresort_first'){
			    		pr.css('display','block');
			    	}
			    }
		};
		
		this.getProduct(pageNum);
	};
	
	
	//创建树单元
	var createTreeCell = function(pId,data,flag){
		var len = data.length;
		var obj = $('#'+_this.config.id+'_Catalog').find('#c_'+pId);
		var ul = obj.find('ul');
		if(ul.length==0){
			ul = $('<ul style="display:none"></ul>');
		    obj.append(ul);
		} 
		for(var i=0;i<len;i++){
			var v = data[i];
			var li = '';
			if(_this.config.styleId == 3){
				if((i+1) == len){
					var cls = flag?'class="dashed4"':'';
					li = '<li id="c_'+v.id+'" '+cls+'><a hidefocus="true" href="javascript:Order_'+_this.config.id+'.setCatalogB(\''+v.id+'\');" title="'+v.name+'">'+v.name+'</a></li>';
				}else{
					li = '<li id="c_'+v.id+'"><a hidefocus="true" href="javascript:Order_'+_this.config.id+'.setCatalogB(\''+v.id+'\');" title="'+v.name+'">'+v.name+'</a></li>';
				}
			}else{
				li = '<li id="c_'+v.id+'"><a hidefocus="true" href="javascript:Order_'+_this.config.id+'.setCatalogB(\''+v.id+'\');" title="'+v.name+'">'+v.name+'</a></li>';
			};
			ul.append(li);
			if(v.children.length){
				createTreeCell(v.id,v.children);
			}
		};
	};
		
	$.ajax({
		url:"/EWS_Interface/Order_ListAllCatalog.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{CID:this.config.cid,ParentID:this.config._catalogID},
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result.tree[0].children);
		}
	});
	
};

/**
 * 设置当前产品分类
 * @param {String} parentID
 */
EWS.Order.GetCatalogProductList.prototype.setCatalog = function(parentID,number){

    if( number !='0' || number != 0){
		$('#'+this.config.id+'_Catalog').html(EWS.Language['E01003']['E0100312']);
			
		//设置锚点标记，第一位：分类ID，第二位：页码
		EWS.Anchor.set("Order_"+this.config.id,parentID+",1");
		
		this.getCatalog(parentID);
	}else{
        var obj = $('#'+this.config.id+'_Catalog');
        obj.find('.active').removeClass('active');
        $('#'+this.config.id+'_Catalog').find('a[key = '+parentID+']').addClass('active');
	    this.config.catalogID = parentID;
		this.getProduct(1);
    }
	
};

/**
 * 设置当前产品分类
 * @param {String} parentID
 */
EWS.Order.GetCatalogProductList.prototype.setCatalogB = function(parentID){
	var obj =  $('#'+this.config.id+'_Catalog');
	obj.find('.active').removeClass();
	obj.find('#c_'+parentID+'>a').addClass('active');
    var ul = obj.find('#c_'+parentID+'>ul');
    EWS.Anchor.set("Order_"+this.config.id,parentID+",1");
    if(ul.length){
	    if(this.config.styleId == 3){
	    	var parent = $('#c_'+parentID);
	    	if(ul[0].style.display == 'none'){//展开
	    		var flag = (parent.attr('key') == 'waresort_last2');
	    		if(flag){
	    			parent.removeClass();
	    		}
	    		ul.css('display','block');
	    	}else{//关闭
	    		var flag = (parent.attr('key') == 'waresort_last2');
	    		if(flag){
	    			parent.addClass('waresort_last2');
	    		}
	    		ul.css('display','none');	    		
	    	}
	    }else{
	    	if(ul[0].style.display == 'none'){//展开
	    		ul.css('display','block');
	    	}else{//关闭
	    		ul.css('display','none');	    		
	    	}
	    } 
    }
    this.config.catalogID = parentID;
	this.getProduct(1);
};

/**
 * 获取商品列表
 * @param {Number} pageNum 分页页码
 */
EWS.Order.GetCatalogProductList.prototype.getProduct = function(pageNum){
	/**
	 * 获取商品列表，响应操作
	 * @param {Object} result
	 */
	var _get_success = function(result){
		var lang = EWS.Language['E01003'];
		var parent = $('#'+this.config.id+'_Product');
		
		if(parseInt(result.pageTotal) == 0){
			parent.html(lang['E010038']);
			return;
		};
		var pageTotal = Math.ceil(parseInt(result.totalCount)/this.config.pageItem) || 0;
		
		//防止当前页码大于总页数，重新读取最后页码内容
		if(parseInt(pageTotal) < pageNum){
			this.jumpPage( pageTotal ,  pageNum , pageTotal);
			return;
		};
		
		var imgList = [];//初始化预加载图片列表
		var _this = this;
		var appId = 'Order_'+_this.config.id;
		parent.html("");
		
		var ul = [];
		var pLen = result.Product.length;
		var p = result.MoneyType;
		p = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
		var setImg = 'javascript:'+appId+'.imgLoadComplete(this)';
		$.each(result.Product , function(i,v){
			//增加预加载图片列表
			var newId = _this.config.id+"_"+i;
			var imgUrl = 'http://'+_this.config.htmlUrl+'/theme/order/img/noImg.png';
			if(v.Img){
				imgUrl = _this.getSmallPicPath(v.Img);
			}
			imgList.push({src:imgUrl,id:newId});
			if(_this.config.rowItem == 1){
				ul = [];
			}else{
				if((i+1) % _this.config.rowItem == 1){
					ul = [];
				};
			};
			if(_this.config.showProDetail&&Number(_this.config.showProDetail) == 2){//独立页显示产品信息
		 	 	 var action = 'javascript:'+appId+'.showPageDetial(\''+v.ID+'\',\''+v.Name+'\',\''+_this.config.detailMenuId+'\');';
		 	 }else{
		 	 	 var action = 'javascript:'+appId+'.showDetial(\''+v.ID+'\',\''+v.Name+'\');';
			 }
//			var action = 'javascript:'+appId+'.showDetial(\''+v.ID+'\',\''+v.Name+'\');';
			var style = "margin-right:"+_this.config.sBetween+"px";
			if((i+1) % _this.config.rowItem == 0 || (i+1) == pLen){
                style = '';
			};
			
			var ulCls = '';
			switch(_this.config.styleId){
				case 5 :
				case 6 :
				case 1 ://样式一
				    var li = '<li class="ord_part'+_this.config.styleId+'" style='+style+'>' +
								'<ul>' +
									'<li>' +
										'<a class="size" href="'+action+'">' +
											'<img onload="'+setImg+'" title="'+v.Name+'" src="'+imgUrl+'" id="'+newId+'"/>' +
										'</a>' +
									'</li>' +
									'<li>' +
										'<span>'+p+'&nbsp;'+v.UnitPrice+'</span>' +
										'<button class="buy" title="'+lang['E0100310']+'" onclick="'+appId+'.setShoppingCar(\''+v.ID+'\');'+appId+'.showShoppingCar();">'+lang['E0100310']+'</button>' +
										'<a href="'+action+'" class="detail" title="'+lang['E0100311']+'">'+lang['E0100311']+'</a>' +
									'</li>' +
									'<li>' +
										'<strong><a hidefocus="true" href="'+action+'" title='+v.Name+'>'+v.Name+'</a></strong>' +
									'</li>' +
								'</ul>' +
							'</li>';
				    break;
				case 2 ://样式二
				    var li = '<li style='+style+'><a class="size" href="'+action+'"><img onload="'+setImg+'" id="'+newId+'" title="'+v.Name+'" src="'+imgUrl+'" /></a></li>';
				    ulCls = 'ord_show2';
				    break;
				case 3 ://样式三
				    var li = '<li style='+style+'>' +
				    			 '<div class="waresort_content"><a href="'+action+'"><img onload="'+setImg+'" id="'+newId+'" title="'+v.Name+'" src="'+imgUrl+'" /></a></div>' +
				    			 '<div class="waresort_content2"><a hidefocus="true" href="'+action+'" title='+v.Name+'>'+v.Name+'</a><p>'+p+'&nbsp;'+v.UnitPrice+'</p></div>' +
				    		 '</li>';
				    break;
				case 4 ://样式四
				    var li = '<li class="waresort_r_bg" style='+style+'>' +
				    			'<ul>' +
				    				'<li class="waresort_r_a"><a href="'+action+'"><img onload="'+setImg+'" title="'+v.Name+'"  id="'+newId+'"  src="'+imgUrl+'" /></a></li>' +
				    				'<li><a hidefocus="true" href="'+action+'">'+v.Name+'</a></li>' +
				    				'<li class="waresort_r_num"><span>'+lang['E0100314']+'：'+v.Sn+'</span><a title="'+lang['E0100311']+'"  href="'+action+'">'+lang['E0100311']+'</a></li>' +
				    				'<li class="waresort_r_pre" id="ext-gen681"><span>'+lang['E010033']+'：'+p+'&nbsp;'+v.UnitPrice+'</span><a title="'+lang['E0100310']+'" href="javascript:'+appId+'.setShoppingCar(\''+v.ID+'\');'+appId+'.showShoppingCar();">'+lang['E0100310']+'</a></li>' +
				    			'</ul>' +
				    		'</li>';
				    break;
			};
			
			ul.push(li);
			
			if((i+1) % _this.config.rowItem == 0 || (i+1) == pLen){
				$('<ul class="'+ulCls+'">'+ul.join("")+'</ul>').appendTo(parent);
			};
			
		});
		
		if(pLen == 0){
			parent.append('<div class="noData">'+lang['E010038']+'</div>');
		}
		
		
		if(this.config.styleId==2||this.config.styleId==3||this.config.styleId==4){
			this.setNavigation(pageNum ,pageTotal,this.config.id,true);
		}else{
			this.setNavigation(pageNum ,pageTotal);
		}//设定分页导航
	};
	
	var _this = this;
	
	$.ajax({
		url:"/EWS_Interface/Order_ListProduct.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{CID:this.config.cid,ParentID:this.config.catalogID,PageItem:this.config.pageItem,PageNum:pageNum},
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result);
		}
	});
};

/**
 * 展示产品详细信息(独立页面展示)
 * @param {String} pid 产品ID
 * @param {String} pname 产品名称
 * @param {String} url 要跳转到的页面
 */
EWS.Order.GetCatalogProductList.prototype.showPageDetial = function(pid,pname,url){
	window.open(url+".aspx?pid="+pid+"&pname="+pname);
};


/**
 * 展示产品详细信息(当前页面展示)
 * @param {String} id 产品ID
 * @param {String} name 产品名称
 */
EWS.Order.GetCatalogProductList.prototype.showDetial = function(id,name){
	this.hideImgLayer();
	
	var appId = 'Order_'+this.config.id;
	this.config.pId = id;
	var _this = this;
	var scrollSize = EWS.GetPageScroll();
	var pageSize = EWS.GetPageSize();
	var target = $('#Product_'+this.config.id);
	var top = scrollSize.Y+20;
	var left = (pageSize.WinW - 830) / 2;	
	var isExists = false;//设置浮动层不存在标记为false
	var lang = EWS.Language['E01005'];
	

	/**
	 * 数据加载响应
	 * @param {Object} result 数据
	 */
	var _get_success = function(result){
		var arr = this.createProductDetailHtml2(this.config,result);
		var target = $('#Product_'+this.config.id);
		var target_detial = $("#Product_"+_this.config.id+" div.ord_detail");
		//若浮动层存在，则直接显示
		if(isExists){		
			target_detial.html(arr[0]);
			//预加载图片，调整图片Size
			new EWS.PreLoadImage({
				 path:""
				,arrSrc:arr[1]
				,maxWidth:55
				,maxHeight:56
				,scope:_this
				,success:_this.setDetialImage
			});
			return;
		};
		
		//使用动画出场效果
		target
		.animate({top: top+'px' , left: left+'px'}, "normal")
		.animate({width: '+830px'}, "fast" , function(){
			target_detial.html(arr[0]);
			
			//预加载图片，调整图片Size
			new EWS.PreLoadImage({
				 path:""
				,arrSrc:arr[1]
				,maxWidth:55
				,maxHeight:56
				,scope:_this
				,success:_this.setDetialImage
			});
		});
			
	};
	
	var html = 
	'<div id="Product_'+this.config.id+'" class="ord_mdl ord_box">' +
		'<div class="ord_mdl_t">' +
			'<div class="ord_mdl_t_l"></div>' +
			'<div class="ord_mdl_t_r"></div>' +
			'<div class="ord_mdl_t_c"><h2>'+lang['E0100510']+'</h2></div>' +
			'<div class="ord_mdl_t_m"><a href="javascript:'+appId+'.hideDetial();" title="'+lang['E0100511']+'">'+lang['E0100511']+'</a></div>' +
		'</div>' +
		
		'<div class="ord_mdl_c ord_g_p_hide">' +
			'<div class="ord_mdl_c_l ord_g_p_fill"></div>' +
			'<div class="ord_mdl_c_r ord_g_p_fill"></div>' +				
			'<div class="ord_mdl_c_c">' +
				'<div class="ord_detail">' +
					'<div class="ord_loading"><strong>'+name+'</strong> '+lang['E0100512']+'</div>' +
				'</div>' +
			'</div>' +
		'</div>' +
		
		'<div class="ord_mdl_b">' +
			'<div class="ord_mdl_b_l"></div>' +
			'<div class="ord_mdl_b_r"></div>' +
			'<div class="ord_mdl_b_c"></div>' +
		'</div>' +		
	'</div>';
	EWS.Order.layerIndex++;//设置当前浮动层数
	if(target.length==0){//处理：浮动层不存在
		$(html).css({
	    	 position:'absolute'
			,width:350
			,'z-index':EWS.Order.layerIndex
			,top: ( (pageSize.WinH - 100) /2) + scrollSize.Y
			,left:(pageSize.WinW - 350) / 2
		}).appendTo("body");
	}else{//处理：浮动层已经存在
		$('#Product_'+this.config.id+' div.ord_detail')
			.html('<div class="ord_loading"><strong>'+name+'</strong> '+lang['E0100512']+'</div>');
		isExists = true;//设置浮动层不存在标记为true
	};
	$.ajax({
		url:"/EWS_Interface/Order_ProductShow.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{ProductID:id},
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result);
		}
	});
};

/**
 * 展示产品详细内容图片（大图）
 * @param {} id
 */
EWS.Order.GetCatalogProductList.prototype.showDetialImage = function(id){
	var Sid = this.config.styleId;
	var size = this.returnWidthHeight('bigImg');
	var ProductImage = $("#Product_"+this.config.id+"_Img");
	var img = $("#"+id)[0];
	if ($.browser.msie) {
		var originalImg = new Image();
		originalImg.src = img.src;
		var originalWidth = originalImg.width;
		var originalHeight = originalImg.height;
	}else{
		var originalWidth = img.naturalWidth;
		var originalHeight = img.naturalHeight;
	};
	if(!size) size = [354,216];
	var scaleProduct = this.getImageScale(originalWidth,originalHeight,size[0],size[1]);
	ProductImage.attr({src:img.src});
	ProductImage.css({width:scaleProduct[0],height:scaleProduct[1],position:'relative',top:(size[1]-scaleProduct[1])/2});
};


/**
 * 展示产品图片
 */
EWS.Order.GetCatalogProductList.prototype.showProductImage = function(){
	window.open($("#Product_"+this.config.id+"_Img")[0].src);
};


/**
 * 隐藏产品详细内容
 */
EWS.Order.GetCatalogProductList.prototype.hideDetial = function(id){
	id?$("#"+id).remove():$("#Product_"+this.config.id).remove();
};


/**
 * 设定产品详细内容图片
 * img.id     图片ID
 * img.width  图片宽度
 * img.height 图片高度
 * img.src   图片来源
 * img.index 图片索引
 * @param {Object} img 图片对象
 */
EWS.Order.GetCatalogProductList.prototype.setDetialImage = function(img){
	//若当前图片是第一张产品图片	
	if(img.index==0){
		this.showDetialImage(img.id);//展示产品详细内容图片（大图）
	};
	//获得图片原始宽度与高度
	var originalImg = new Image();
	originalImg.src = img.src;
	var originalWidth = originalImg.width;
	var originalHeight = originalImg.height;
	//根据原始宽度与高度设置图片垂直居中所需要的偏移位置
	//先判断样式类型
	var size = this.returnWidthHeight(true);
	var width = size[0];
	var height = size[1];
	var scale = this.getImageScale(originalWidth,originalHeight,width,height);
	$("#"+img.id).css({position:'relative',top:(height-scale[1])/2});
};


/**
 * 设定分页导航
 * @param {Number} pageNum   当前页页码
 * @param {Number} pageTotal 总页数
 */
EWS.Order.GetCatalogProductList.prototype.setNavigation = function(pageNum , pageTotal, id , type){
	if(type){
        var parent = $("#"+id+" div.ord_mop_page");
	}else{
		var parent = id?$("#"+id+" div.ord_pages"):$("#"+this.config.id+" div.ord_page");
	}
	var pageGroup = 5;//设定分页页码组数量
	var groupNum = parseInt( (pageNum - 1) / pageGroup ) + 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:Order_"+this.config.id+".jumpPage("+nextGroupNum+","+pageNum+","+pageTotal+");";
	var nextPage = "javascript:Order_"+this.config.id+".jumpPage("+nextNum+","+pageNum+","+pageTotal+");";
	var nextText = "第 "+nextGroupNum+" 页";
	var prevPage = "javascript:Order_"+this.config.id+".jumpPage("+prevNum+","+pageNum+","+pageTotal+");";
	var prevGroup = "javascript:Order_"+this.config.id+".jumpPage("+prevGroupNum+","+pageNum+","+pageTotal+");";
	var prevText = "第 "+prevGroupNum+" 页";
	
	var html = "<a href='"+prevGroup+"' class='first' title='"+prevText+"'>"+prevText+"</a>" +
			   "<a href='"+prevPage+"' class='previous' title='上一页'>上一页</a>" +
			   "{span}" +
			   "<a href='"+nextPage+"' class='next' title='下一页'>下一页</a>" +
			   "<a href='"+nextGroup+"' class='last' title='"+nextText+"'>"+nextText+"</a>";
	
	var span = "<span>";

	for(var i=start; i <= end; i++){
		if( i <= 9 ){
			var num = "0"+i;
		}else{
			var num = i;
		};
		var href = "javascript:Order_"+this.config.id+".jumpPage("+i+","+pageNum+","+pageTotal+");";
		
		if( i == pageNum ){
			span += "<a href='"+href+"' class='status'><strong>"+num+"</strong></a>";
		}else{
			span += "<a href='"+href+"'>"+num+"</a>";
		};
	};
	span+="</span>";
	parent.html("");
	$(html.replace(/{span}/,span)).appendTo(parent);
			   
	if(this.initLoad){
		this.initLoad = false;//标记初始读取数据:false
	};
};


/**
 * 跳转到指定页码
 * @param {Number} jumpPage  跳转页码
 * @param {Number} pageNum   当前页页码
 * @param {Number} pageTotal 总页数
 */
EWS.Order.GetCatalogProductList.prototype.jumpPage = function(jumpPage , pageNum , pageTotal){
	jumpPage = jumpPage > pageTotal ? pageTotal : jumpPage;
	if(jumpPage == pageNum){
		return;
	};
	//设置锚点标记，第一位：分类ID，第二位：页码
	if(this.type){
//		EWS.Anchor.set("Order_"+this.config.id,this.config.eshop_category+","+jumpPage);
//		EWS.Anchor.set("Order_"+this.config.id,this.config.catalogID+","+jumpPage);
		if(this.type == 'orders_showCatalogProduct'){
			EWS.Anchor.set("Order_"+this.config.id,this.config.catalogID+","+jumpPage);
			this.getProductByPage(jumpPage);
		}else if(this.type == 'orders_showMoreProduct'){
			EWS.Anchor.set("Order_"+this.config.id,"0,"+jumpPage);
			this.moreProductGetData(jumpPage);
		}else if(this.type == 'GetCatalogProductList'){
			EWS.Anchor.set("Order_"+this.config.id,this.config.catalogID+","+jumpPage);
//			EWS.Anchor.set("Order_"+this.config.id,this.config.catalogID+","+jumpPage);
			this.getProduct(jumpPage);
		}else if(this.type == 'orders_productSearch'||this.type == 'orders_fullearch'){
			EWS.Anchor.set("Order_"+this.config.id,this.config.catalogID+","+jumpPage);
			this.getLists(jumpPage);
		};
	}else{
	};
};

/**
 * 绑定图片浏览效果事件
 * img.id
 * img.width
 * img.height
 * img.src
 * @param {Object} img
 */
EWS.Order.GetCatalogProductList.prototype.setImageLayer = function(img){
	var src = img.src.split('/');
	if(src[src.length-1] != 'noImg.png'){
		var _this = this;
		var target  = $('#'+img.id);
		target.mouseover(function(event){
			_this.config.imgSizeTemp = [event.pageX == null ? event.clientX : event.pageX,event.pageY == null ? event.clientY : event.pageY];
			_this.showImgLayer(this);
		});
		
		target.mouseout(function(event){
			_this.hideImgLayer(this);
		});
	};
};

/**
 * 隐藏图片浏览层
 */
EWS.Order.GetCatalogProductList.prototype.hideImgLayer = function(){
	$("#"+this.config.id+"_zoomPic").remove();
};


/**
 * 根据给出的最大高度与宽度，按当前高度与宽度的比例生成比例值
 * @param {Number} originalWidth 原始宽度
 * @param {Number} originalHeight  原始高度
 * @param {Number} maxWidth 最大宽度
 * @param {Number} maxHeight 最大高度
 * @return {Array} 返回最新比例 [宽度，高度]
 */
EWS.Order.GetCatalogProductList.prototype.getImageScale = function(originalWidth , originalHeight , maxWidth , maxHeight){
	/**
     * 计算出比例值，若含有小数点则取出小数点两位
     * @param {Number} num1 原始值
     * @param {Number} num2　参考值
     * @return {Number}
     */
    var _CalculateScale = function(num1 , num2){
    	var Temp = num2 / num1;
		
		if(Temp.length > 1){
			return num2;
		}else{
			return parseFloat(Temp.toString().substring(0,4));
		};
    };

	if(maxWidth==maxHeight){//最大高度==最大宽度
		if(originalWidth>originalHeight){
			var wScale =  _CalculateScale(originalWidth , maxWidth);//计算出最大高度的比例，取小数点两位值
			if(wScale<=1){
				newWidth = maxWidth;
				newHeight = wScale*originalHeight;
			}else{
				newHeight = originalWidth;
        		newWidth = originalHeight;
			}
		}else if(originalWidth<originalHeight){
			var hScale = _CalculateScale(originalHeight ,maxHeight);//计算出最大宽度的比例，取小数点两位值
			if(hScale<=1){
				newHeight = maxHeight;
				newWidth = hScale*originalWidth;
			}else{
				newHeight = originalHeight;
				newWidth = originalWidth;
			}
		}else{//原始长宽相等
			var wScale = _CalculateScale(originalWidth ,maxWidth);//计算出最大宽度的比例，取小数点两位值
			if(wScale<=1){
				newHeight = originalWidth * wScale;
			    newWidth = newHeight;
			}else{
				newHeight = originalWidth;
			    newWidth = newHeight;
			}
		}
	}else if(maxWidth>maxHeight){//最大宽度>最大高度
		if(originalWidth > originalHeight){
			var wScale = _CalculateScale(originalWidth , maxWidth);//计算出最大宽度的比例，取小数点两位值
			if(wScale<=1){
	        	if(originalHeight * wScale>maxHeight){
	        		newHeight = maxHeight;
	        		newWidth = _CalculateScale(originalHeight , maxHeight)*originalWidth;
	        	}else{
	        		newWidth = maxWidth;
	        		newHeight = originalHeight * wScale;
	        	}
	        }else{
	        	newWidth = originalWidth;
	        	newHeight = originalHeight;
	        }
		}else if(originalWidth == originalHeight){
			var wScale = _CalculateScale(originalWidth , maxWidth);//计算出最大宽度的比例，取小数点两位值
			if(wScale<=1){
				newHeight = maxHeight;
				newWidth = _CalculateScale(originalHeight , maxHeight)*originalWidth;
			}else{
				if(originalHeight>maxHeight){
					newWidth = _CalculateScale(originalHeight , maxHeight)*originalWidth;
		        	newHeight = _CalculateScale(originalHeight , maxHeight)*originalHeight;
				}else{
					newWidth = originalWidth;
		        	newHeight = originalHeight;
				}
			}
		}else{//原始宽度<原始高度
			var hScale = _CalculateScale(originalHeight , maxHeight);
			if(hScale<=1){
				if(hScale*originalWidth>maxWidth){
					newWidth = maxWidth;
					newHeight =  _CalculateScale(originalWidth , maxWidth)*originalHeight;
				}else{
					newWidth = hScale*originalWidth;
	        		newHeight = maxHeight;
				}
			}else{
					newWidth = originalWidth;
		        	newHeight = originalHeight;
			}
		}
	}else{//最大宽度<最大高度
		if(originalWidth >= originalHeight){
			var wScale = _CalculateScale(originalWidth , maxWidth);//计算出最大宽度的比例，取小数点两位值
			if(wScale<=1){
				newWidth = wScale*originalWidth;
	        	newHeight = wScale*originalHeight;
			}else{
				newWidth = originalWidth;
	        	newHeight = originalHeight;
			}
		}else if(originalWidth < originalHeight){
			var hScale = _CalculateScale(originalHeight , maxHeight);
			if(hScale*originalWidth>maxWidth){
				newWidth = maxWidth;
				newHeight = _CalculateScale(originalWidth , maxWidth)*originalHeight;
			}else{
				newWidth = originalWidth *hScale;
				newHeight = originalHeight*hScale;
			}
		}
	}

	return [newWidth , newHeight];
};

/**
 * 显示图片浏览层
 * img.id
 * img.width
 * img.height
 * img.src
 * @param {Object} img
 */
EWS.Order.GetCatalogProductList.prototype.showImgLayer = function(img){
	var id = this.config.id+"_zoomPic";
	var div = $.find("#"+id);
	var maxWidth = 200;
	var maxHeight = 100;
//	var maxWidth = 531;
//	var maxHeight = 384;
	var pageSize = EWS.GetPageSize();
	var scrollSize = EWS.GetPageScroll();
	var scale = this.getImageScale(img.width , img.height , maxWidth , maxHeight);		
	var x = this.config.imgSizeTemp[0] + 50;
	var y = this.config.imgSizeTemp[1] + 50;
	var maxX = pageSize.WinW + scrollSize.X;
	var originalX = scale[0] + x;
//	x = maxX >= originalX ? x : x - scale[0] - 100;
	var maxY = pageSize.WinH + scrollSize.Y;
	var originalY = scale[1] + y;
	y = maxY >= originalY ? y : y - (originalY - maxY) - 50;
	
	x = (this.config.imgSizeTemp[0]+531)>pageSize.WinW?(this.config.imgSizeTemp[0]-((this.config.imgSizeTemp[0]+531)-pageSize.WinW)):this.config.imgSizeTemp[0];
	if(div.length==0){
		var target = $('<div id="'+id+'" class="ord_zoomPic">' +
				'<img src="http://www1.khews.com/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});
	};
//	img.src = img.src.replace('_s.','.');
    var _img = {src:img.src};
	if(this.IsInterResource(_img.src)){
		_img.src = _img.src.replace('_s.','.');
	}
	this.getOriginalPicSize(_img);
};

/**
 * 展示产品购物车
 */
EWS.Order.GetCatalogProductList.prototype.showShoppingCar = function(){
	var _this = this;	
	var isExists = false;//设置浮动层不存在标记为true
	var scrollSize = EWS.GetPageScroll();
	var pageSize = EWS.GetPageSize();
	var target = $('#ShoppingCar_'+this.config.id);
	var top = scrollSize.Y+100;
	var left = (pageSize.WinW - 830) / 2;
	var appId = 'Order_'+this.config.id;
	var ProductID = $.cookie("EWS_ShopCar_"+this.config.cid);
	var idList = [];
    var lang = EWS.Language['E01009'];
	var loadHtml =
	'<div class="ord_detail">' +
		'<div class="ord_loading"><strong>'+name+'</strong> '+lang['E0100937']+'</div>' +
	'</div>';
	
	var html = 
	'<div id="ShoppingCar_'+this.config.id+'" class="ord_mdl ord_box">'+
		'<div class="ord_mdl_t">' +
			'<div class="ord_mdl_t_l"></div>' +
			'<div class="ord_mdl_t_r"></div>' +
			'<div class="ord_mdl_t_c"><h2>'+lang['E0100938']+'</h2></div>' +
			'<div class="ord_mdl_t_m"><a href="javascript:'+appId+'.hideShoppingCar();" title="'+lang['E0100939']+'">'+lang['E0100939']+'</a></div>' +
		'</div>' +
		
		'<div class="ord_mdl_c ord_g_p_hide">' +
			'<div class="ord_mdl_c_l ord_g_p_fill"></div>' +
			'<div class="ord_mdl_c_r ord_g_p_fill"></div>' +				
			'<div class="ord_mdl_c_c">' + loadHtml + '</div>' +
		'</div>' +
		
		'<div class="ord_mdl_b">' +
			'<div class="ord_mdl_b_l"></div>' +
			'<div class="ord_mdl_b_r"></div>' +
			'<div class="ord_mdl_b_c"></div>' +
		'</div>' +
	'</div>';
	
	var _get_success = function(result){
		var dateTime = result.addtime;
		var p = result.moneytype;
		p = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
		var info_id = "EWS_ShopInfo_"+this.config.cid;
		var info = $.cookie(info_id);
		var input = {
			'OrderInfo_Name' : {
				 name:lang['E010092']
				,cls:'ord_info_input ord_info_error'
				,tag:'input'
				,type:'text'
				,value:lang['E010093']
			}
			,'OrderInfo_Tel' : {
				 name:lang['E010094']
				,cls:'ord_info_input ord_info_error'
				,tag:'input'
				,type:'text'
				,value:lang['E010095']
			}
			,'OrderInfo_Email' : {
				 name:lang['E010096']
				,cls:'ord_info_input ord_info_error'
				,tag:'input'
				,type:'text'
				,value:lang['E010097']
			}
			,'OrderInfo_Addr' : {
				 name:lang['E010098']
				,cls:'ord_info_input ord_info_error'
				,tag:'input'
				,type:'text'
				,value:lang['E010099']
			}
			,'OrderInfo_Remarks' : {
				 name:lang['E0100910']
				,cls:'ord_info_textarea'
				,tag:'textarea'
				,type:'text'
				,value:''
			}
		};
		
		if(info != null){
			var infoArr = $.evalJSON(info);
			
			$.each(infoArr , function(i,v){
				input[i].value =  v;
				input[i].cls = input[i].cls.replace(/ ord_info_error/ , "");
			});
		};
		
		var infoHTML = [];
		$.each(input , function(i,v){
			if(v.tag == 'input'){
				infoHTML.push(
				'<label for="'+i+'"><strong>'+v.name+'</strong>' +					
					'<'+v.tag+' id="'+i+'" class="'+v.cls+'" type="'+v.type+'" value="'+v.value+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" />' +
				'</label>'
				);
			}else{
				infoHTML.push(
				'<label for="'+i+'"><strong>'+v.name+'</strong>' +					
					'<'+v.tag+' id="'+i+'" class="'+v.cls+'" type="'+v.type+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);">'+v.value+'</'+v.tag+'>' +
				'</label>'
				);
			};
		});
		
		var html = 
		'<div class="ord_neworder">' +
			'<h3 class="ord_title">'+lang['E0100911']+'</h3>' +
			
			'<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
				'<tr>' +
					'<th class="order_time">'+lang['E0100912']+'</th>' +
					'<td class="order_no">'+result.addtime+'</td>' +
					'<th class="order_time">'+lang['E0100913']+'</th>' +
					'<td class="order_no">' +
						'<label for="pay">' +
							'<select id="Payment">' +
							'<option value="1">'+lang['E0100914']+'</option>' +
							'<option value="2">'+lang['E0100915']+'</option>' +
							'<option value="3">'+lang['E0100916']+'</option>' +
							'</select>' +
						'</label>' +
					'</td>' +
					'<th class="order_time"></th>' +
					'<td class="order_no"></td>' +
					'<th class="order_time"></th>' +
					'<td class="order_no"></td>' +
				'</tr>' +
			'</table>' +
			
			'<div class="order_bor">' +
				'<table id="Product_'+_this.config.id+'_Table" width="100%" border="0" cellspacing="0" cellpadding="0">{data}</table>' +				
			'</div>' +
			'{total}' +
			
			'<div class="ord_info">{info}</div>' +
//				'<label for="OrderInfo_Name"><strong>企业/个人</strong>' +
//					'<input id="OrderInfo_Name" class="ord_info_input" type="text" value="'+infoArr['OrderInfo_Name']+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" />' +
//				'</label>' +
//				'<div class="ord_dashed"></div>' +
//				'<label for="OrderInfo_Tel"><strong>联系电话</strong>' +
//					'<input id="OrderInfo_Tel" class="ord_info_input" type="text"  value="'+infoArr['OrderInfo_Tel']+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" />' +
//				'</label>' +
//				'<div class="ord_dashed"></div>' +
//				'<label for="OrderInfo_Email"><strong>电子邮箱</strong>' +
//					'<input id="OrderInfo_Email" class="ord_info_input" type="text" value="'+infoArr['OrderInfo_Email']+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" />' +
//				'</label>' +
//				'<div class="ord_dashed"></div>' +
//				'<label for="OrderInfo_Addr"><strong>联系地址</strong>' +
//					'<input id="OrderInfo_Addr" class="ord_info_input" type="text" value="'+infoArr['OrderInfo_Addr']+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" />' +
//				'</label>' +
//				'<div class="ord_dashed"></div>' +
//				'<label for="OrderInfo_Remarks"><strong>购物备注</strong>' +
//					'<textarea id="OrderInfo_Remarks" class="ord_info_textarea" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" >'+infoArr['OrderInfo_Remarks']+'</textarea>' +
//				'</label>' +
//			'</div>' +
			
			'<div class="ord_pht">' +
				'<div class="ord_video"><div id="Order_'+_this.config.id+'_Video"></div></div>' +
				'<div class="ord_noVideo" style="display:none;">' +
					'<div class="ord_tips"><strong></strong></div>' +
				'</div>' +
				'<div class="ord_checkbox">' +
					'<label for="'+_this.config.id+'_ShowCapture"><input type="checkbox" id="'+_this.config.id+'_ShowCapture" checked="checked" />'+lang['E0100940']+'</label>' +
				'</div>' +
				'<input type="hidden" id="'+_this.config.id+'_Capture" value="" />' +
				'<button class="ord_video_btn" title="'+lang['E0100917']+'" onclick="Order_'+_this.config.id+'.camCapture(this)">'+lang['E0100917']+'</button>' +
			'</div>' +
			
			'<div class="ord_line"></div>' +
			'<div class="ord_newOrd_loading" style="display:none"><img src="http://'+_this.config.htmlUrl+'/theme/order/img/indicator.gif" />'+lang['E0100937']+'</div>' +
			'<button class="ord_order_btn" title="'+lang['E0100918']+'" onclick="'+appId+'.submitShopping();">'+lang['E0100918']+'</button>' +
			
		'</div>';
		
		var line = 
		'<tr>' +
			'<td height="1" colspan="12"><div class="ord_dashed1"></div></td>' +
		'</tr>';
		
		var infoLine = '<div class="ord_dashed"></div>';
		
		//获得订单中产品数量
		var car_id = "EWS_ShopCar_"+this.config.cid;
		var car = $.cookie(car_id);
		var amount = {};
		if(car != null){//处理：已有cookie
			var valArr = $.evalJSON(car);
	
			$.each(valArr , function( i , v){
				amount[v.id] = parseInt(v.amount);
			});
		};

		var rLen = result.product.length;
		var totalPrice = 0;
		var data = [];
		if(rLen > 0){//处理：有产品数据
			for(var i=0; i<rLen; i++){
				data.push(
					'<tr id="Product_'+result.product[i].ID+'_Row" class="order_sta">' +
						'<th class="digi">'+(i+1)+'.</th>' +
						'<th>'+lang['E0100919']+'</th>' +
						'<td class="name"><a href="javascript:'+appId+'.showDetial(\''+result.product[i].ID+'\',\''+result.product[i].Name+'\');" title="'+result.product[i].Name+' '+lang['E0100941']+'">'+result.product[i].Name+'</a></td>' +
						'<th>'+lang['E0100920']+'</th>' +
						'<td class="no">'+result.product[i].Sn+'</td>' +
						'<th>'+lang['E0100921']+'</th>' +
						'<td class="price" id="'+result.product[i].ID+'_UnitPrice">'+result.product[i].UnitPrice+'</td>' +
						'<th>'+lang['E0100922']+'</th>' +
						'<td class="amount">' +
							'<label for="amount"><input value="'+amount[result.product[i].ID]+'" onkeyup="'+appId+'.changeShoppingCar(this,\''+result.product[i].ID+'\');" /></label>' +
						'</td>' +
						'<th>'+lang["E0100923"]+'</th>' +
						'<td class="total" id="'+result.product[i].ID+'_TotalPrice">'+parseFloat(result.product[i].UnitPrice) * parseInt(amount[result.product[i].ID])+'</td>' +
						'<td><a href="javascript:'+appId+'.delShoppingCar(\''+result.product[i].ID+'\');" title="'+lang['E0100924'] +result.product[i].Name+ lang['E0100942']+'" class="ord_del">'+lang['E0100924']+'</a></td>' +
					'</tr>'
				);
				
				totalPrice+=parseFloat(result.product[i].UnitPrice) * parseInt(amount[result.product[i].ID]);
			};
			
			html = html.replace(/{data}/ , data.join(line));
			html = html.replace(/{total}/, '<div class="order_sum">'+lang['E0100925']+':'+p+'<span id="Order_'+_this.config.id+'_TotalPrice">'+totalPrice+'</span></div>');
			
		}else{//处理：没有产品数据
			html = html.replace(/{data}/ , '<tr class="order_nodata">'+lang['E0100926']+'</tr>');
			html = html.replace(/{total}/, '');
		};
		
		html = html.replace(/{info}/ , infoHTML.join(infoLine) );
		
		var target = $('#ShoppingCar_'+this.config.id);
		var target_detial = $("#ShoppingCar_"+_this.config.id+" div.ord_mdl_c_c");
		
		//若浮动层存在，则直接显示
		if(isExists){
			target_detial.html(html);
			
			return;
		};
				
		target
		.animate({top: top+'px' , left: left+'px'}, "normal")
		.animate({width: '+830px'}, "fast" , function(){
			target_detial.html(html);

			var flashvars = {};
			flashvars.debug = "false";
			flashvars.eventLinstener = "Order_"+_this.config.id+".camEvent";
			var params = {};
			params.wmode = "opaque";
			params.allowscriptaccess = "always";
			params.bgcolor = "#989797";
			var attributes = {};
			attributes.id = "Order_"+_this.config.id+"_Cam";
			swfobject.embedSWF("http://"+_this.config.htmlUrl+"/theme/CameraCapture.swf", 'Order_'+_this.config.id+'_Video', "320", "240", "9.0.0", false, flashvars, params, attributes);
		});
		
	};
	
	EWS.Order.layerIndex++;//设置当前浮动层数
	
	if(target.length==0){//处理：浮动层不存在
		$(html)
		.css({
	    	 position:'absolute'
			,width:350
			,'z-index':EWS.Order.layerIndex
			,top: ( (pageSize.WinH - 100) /2) + scrollSize.Y
			,left:(pageSize.WinW - 350) / 2
		})
		.appendTo("body");
	}else{//处理：浮动层已经存在
		$('#ShoppingCar_'+this.config.id+' div.ord_mdl_c_c').html(loadHtml);
		isExists = true;//设置浮动层不存在标记为true
	};
	
	if(ProductID != null){//处理：有cookie
		var data = $.evalJSON(ProductID);
		
		$.each(data , function(i , v){
			idList.push(v.id);
		});
		
		var id_value = idList.join(",");
	}else{
		var id_value = '';
	};
	$.ajax({
		url:"/EWS_Interface/Order_ListShopCar.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{ProductID:id_value,CID:this.config.cid},
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result);
		}
	});
};

/**
 * 隐藏产品购物车
 */
EWS.Order.GetCatalogProductList.prototype.hideShoppingCar = function(){
	$('#ShoppingCar_'+this.config.id).remove();
};


/**
 * 添加产品到购物车列表中，若已经存在则修改
 * @param {String} productID 产品ID
 * @param {Number} amount 产品数量
 * @param {Boolean} override 覆盖已经存在的值
 */
EWS.Order.GetCatalogProductList.prototype.setShoppingCar = function(productID , amount , override){
	var car_id = "EWS_ShopCar_"+this.config.cid;
	var car = $.cookie(car_id);
	
	if(amount == undefined){
		amount = 1;
	};
	
	if(override == undefined){
		override = false;
	};
		
	if(car == null){//处理：未有cookie
		var data = [{'id':productID,'amount':amount}];
		var val = $.toJSON(data);
	}else{//处理：已有cookie
		var result = true;
		var valArr = $.evalJSON(car);
		
		$.each(valArr , function( i , v){
			if(v.id == productID){
				if(override){//处理：覆盖已经存在的值
					valArr[i] = {'id':productID,'amount':amount};
				};
				
				result = false;
				return false;
			};
		});
		
		if(result){
			valArr.push({'id':productID,'amount':amount});
		};
		
		var val = $.toJSON(valArr);
	};
	
	$.cookie(car_id , val);
};


/**
 * 删除产品到购物车列表中
 * @param {String} productID
 */
EWS.Order.GetCatalogProductList.prototype.delShoppingCar = function(productID){
	var car_id = "EWS_ShopCar_"+this.config.cid;
	var car = $.cookie(car_id);
	var _this = this;
	
	if(car != null){//处理：已有cookie
		var valArr = $.evalJSON(car);

		$.each(valArr , function( i , v){
			if(v.id == productID){
				valArr.splice( i , 1);
				return false;
			};
		});
		
		if(valArr.length==0){
			$.cookie(car_id , null);
		}else{
			$.cookie(car_id , $.toJSON(valArr));
		};
	}else{
		return;
	};	
	
	var target = $('#Product_'+productID+'_Row');
	target.fadeOut('normal',function(){
		var tr = target.next();
		
		if(tr.length > 0){
			if(tr[0].nodeName == "TR"){
				tr.remove();
			};
		};
		
		target.remove();
		
		//重新统计总金额
		_this.setTotalPrice();

		if(valArr.length == 0){//处理：没有订单产品数据
			$('#Product_'+_this.config.id+'_Table').append('<tr class="order_nodata"><td>'+EWS.Language['E01009']['E0100943']+'</td></tr>');			
		};
	});
};


/**
 * 修改产品到购物车列表中
 * @param {Object} input 输入文本框对象
 * @param {String} productID 产品ID
 * @param {Number} amount 产品数量
 */
EWS.Order.GetCatalogProductList.prototype.changeShoppingCar = function(input , productID){
	var formatfloat = function(f,size){  
	     var tf=f*Math.pow(10,size);  
	     tf=Math.round(tf+0.000000001);  
	     tf=tf/Math.pow(10,size); return tf;  
	};  
	var amount = 1;//设置默认数量
	var unitPriceObj = $("#"+productID+'_UnitPrice');
	var unitPrice = parseFloat(unitPriceObj.html());
	var singlePriceObj = $("#"+productID+'_TotalPrice');

	//处理：数量为空则使用默认数量 
	if(input.value.length==0){
		input.value = amount;
		singlePriceObj.html(formatfloat(unitPrice * amount,2));
		this.setShoppingCar(productID , amount , true);
		return;
	};
	
	var regular = /^\d+$/;

	//处理：数量为非数字类型
	if(regular.test(input.value) == false){
		//获得订单中产品数量
		var car_id = "EWS_ShopCar_"+this.config.cid;
		var car = $.cookie(car_id);
		var valArr = $.evalJSON(car);

		$.each(valArr , function( i , v){
			if(v.id == productID){
				amount = parseInt(v.amount);
				return false;
			};
		});
		
		input.value = amount;
		singlePriceObj.html(formatfloat(unitPrice * amount,2));
		return;
	};
	
	//处理:正常输入
	amount = parseInt(input.value);	
	singlePriceObj.html(formatfloat(unitPrice * amount,2));
	
	//重新统计总金额
	this.setTotalPrice();
		
	this.setShoppingCar(productID , amount , true);
};

/**
 * 设定总金额
 */
EWS.Order.GetCatalogProductList.prototype.setTotalPrice = function(){
	var totalPrice = 0;
	var obj = $("#Product_"+this.config.id+"_Table td.total");
	
	if(obj.length > 0){
		$.each( obj ,function(i,v){
			totalPrice += parseFloat(v.innerHTML);
		});
		
		$("#Order_"+this.config.id+"_TotalPrice").html(totalPrice);
	}else{
		$("#ShoppingCar_"+this.config.id+" div.order_sum").remove();
	};
};

/**
 * 修改产品到购物车列表中
 * @param {Object} input 输入文本框对象
 */
EWS.Order.GetCatalogProductList.prototype.changeShoppingInfo = function(input){
	var lang = EWS.Language['E01009'];
	var errorInfo = {
		'OrderInfo_Name':[lang['E010093'],100],
		"OrderInfo_Tel":[lang['E010095'],100],
		"OrderInfo_Email":[lang['E010097'],100],
		"OrderInfo_Addr":[lang['E010099'],200],
		"OrderInfo_Remarks":['',500]
	};
	
	var input = $("#"+input.id)[0];
	var input_value = $.trim(input.value);
	
	if(input_value.length==0 && input.id != 'OrderInfo_Remarks'){
		input.value = errorInfo[input.id][0];
		input.className = 'ord_info_input ord_info_error';
		return;
	};
	
	if(EWS.LenB(input_value) > errorInfo[input.id][1]){
		input_value = EWS.MidB(input_value , 0 , errorInfo[input.id][1]);
	};
	
	input.value = input_value;
	
	if(input.id == 'OrderInfo_Remarks'){
		input.className = 'ord_info_textarea';//设置为正常样式
	}else{
		input.className = 'ord_info_input';//设置为正常样式
	};
	
	var info_id = "EWS_ShopInfo_"+this.config.cid;
	var info = $.cookie(info_id);
	
	if(info != null){//处理：已有cookie
		var valArr = $.evalJSON(info);
	}else{
		var valArr = {};
	};
	
	valArr[input.id] = input_value;
	$.cookie(info_id , $.toJSON(valArr));
};


/**
 * 获得焦点到订单信息文本框中
 * @param {Object} input 输入文本框对象
 */
EWS.Order.GetCatalogProductList.prototype.focusShoppingInfo = function(input){	
	if(input.id == 'OrderInfo_Remarks'){
		input.className = 'ord_info_textarea';//设置为正常样式
	}else{
		if(input.className == 'ord_info_input ord_info_error'){
			input.value = '';
			input.className = 'ord_info_input';
		};
	};
};


/**
 * 提交订单响应函数 
 */
EWS.Order.GetCatalogProductList.prototype.submitShopping = function(){
	var checkOk = true;
	var inputList = ['OrderInfo_Name',"OrderInfo_Tel","OrderInfo_Email","OrderInfo_Addr","OrderInfo_Remarks"];
	
	//处理：验证输入订单信息文本框
	$.each(inputList , function(i,v){
		var input = $("#"+v)[0];

		if(input.className == 'ord_info_input ord_info_error'){			
			checkOk = false;
			return false;
		};
	});
	
	var car_id = "EWS_ShopCar_"+this.config.cid;
	var car = $.cookie(car_id);
	
	//处理：验证是否有订单产品
	if(car == null){
		checkOk = false;
	};
	
	var IsCapture = $("#"+this.config.id+"_Capture").val();
	var ShowCaputre = $("#"+this.config.id+"_ShowCapture")[0].checked;
	
	if(IsCapture == '' && ShowCaputre ){
		alert(EWS.Language['E01009']['E0100944']);
		checkOk = false;
	};
	//处理：输入验证正确，则进行提交订单
	if(checkOk){
		if(ShowCaputre){//处理：上传视频签署，完成后再提交订单数据
			var cam = swfobject.getObjectById("Order_"+this.config.id+"_Cam");
			cam.captureCamra("cid="+this.config.cid,"http://"+this.config.fileUrl+"/Order_uploadImg.aspx");
		}else{//处理：提交订单数据
			this.submitFormData('');
		};
		
		$("#ShoppingCar_"+this.config.id+" button.ord_order_btn").attr({"disabled":"disabled"});//将提交Disabled
		
		$("#ShoppingCar_"+this.config.id+" div.ord_newOrd_loading").css({'display':'inline'});
	};
};

/**
 * 获取
 */


/**
 * 提交订单数据到服务器
 * @param {} picURL
 */
EWS.Order.GetCatalogProductList.prototype.submitFormData = function(picURL){
	var lang = EWS.Language['E01009'];
	var Payment_val = 1;
	$.each( $("#Payment").find("option") , function( i , v){
	    if(v.selected){
	    	Payment_val = v.value;
	    	return false;
	    };
	});
	
	var ProductData = [];
	var car_id = "EWS_ShopCar_"+this.config.cid;
	var car = $.cookie(car_id);
	var valArr = $.evalJSON(car);
	$.each(valArr , function(i,v){
		ProductData.push([v.id,v.amount]);
	});
		
	var data = {
		CID : this.config.cid,
		Payment : Payment_val,
		OwnerName:$.trim($("#OrderInfo_Name").val()),
		Phone:$.trim($("#OrderInfo_Tel").val()),
		Email:$.trim($("#OrderInfo_Email").val()),
		Address:$.trim($("#OrderInfo_Addr").val()),
		Memo:$("#OrderInfo_Remarks").val(),
		Pic:picURL,
		Product:ProductData
	};
	
	var _this = this;
	
	//提交数据
	$.post('/EWS_Interface/Order_ShopCarSave.aspx' , {'data': $.toJSON(data) } , function(result){//提交完成后显示订单ID				
		var scrollSize = EWS.GetPageScroll();
		var pageSize = EWS.GetPageSize();
		var target = $('#ShoppingCar_'+_this.config.id);
		var top = scrollSize.Y+100;
		var left = (pageSize.WinW - 830) / 2;
		var targetContent = $("#ShoppingCar_"+_this.config.id+" div.ord_mdl_c_c");
		
		targetContent.html('');
		left = left>300?100:left;		
//		$(target).animate({
//			'left':top,
//			'top':left,
//			'width':830
//		}, "normal");
		
		$("#ShoppingCar_"+_this.config.id+" div.ord_mdl_c_c").html(
		   '<div class="ord_detail">' +
			   '<div class="order_inputsc" style="text-align:center;padding:28px;">' +
					'<img src="http://'+_this.config.htmlUrl+'/theme/order/img/inputsc.png" style="width:38px;height:27px;margin-left:-96px;*margin-left:-66px;" />' +
					'<h3 style="margin-top:-20px;color:#74823D;font-size:17px;margin-left:30px;">'+lang['E0100945']+'</h3>' +
					'<p style="font-size:14px;font-family:宋体;">'+lang['E0100946']+':<span style="color:#f00;font-size:16px;padding-left:8px;">'+result+'</span></p>' +
					'<p style="padding-left:25px;font-size:14px;">'+lang['E0100947']+'</p>' +
				'</div>' +
			'</div>'					
		);
		
		//清空订单数据
		var car_id = "EWS_ShopCar_"+_this.config.cid;
		$.cookie(car_id,null);
	});
}; 


/**
 * 视频拍照事件响应函数
 * event.type
 * event.data
 * @param {Object} event 事件对象
 */
EWS.Order.GetCatalogProductList.prototype.camEvent = function(event){
	var lang = EWS.Language['E01009'];
	//通过 event.type 来判断该事件的类型
	switch (event.type) {
		case "camera_init" :
			// 这里做关于 摄像头成功 的处理
			break;
			
		case "camera_not_found" :
			// 这里做关于 摄像头未安装 的处理
			$("#ShoppingCar_"+this.config.id+" div.ord_noVideo").css({"display":'inline'});
			$("#ShoppingCar_"+this.config.id+" div.ord_noVideo strong").html(lang['E0100931']);
			$("#"+this.config.id+"_ShowCapture")[0].checked = false;
			break;
			
		case "camera_muted" :
			// 这里做关于 摄像头被禁用 的处理
			//$("#ShoppingCar_"+this.config.id+" div.ord_noVideo").css({"display":'inline'});
			//$("#ShoppingCar_"+this.config.id+" div.ord_noVideo strong").html('检测到视频被禁用，请重试一次');
			alert(lang['E0100932']);
			$("#"+this.config.id+"_ShowCapture")[0].checked = false;
			break;
			
		case "upload_complete" :
			// 这里做关于 上传成功 的处理
			// 通过访问 event.data 获得成功时从server得到的字符
			this.submitFormData("http://"+this.config.fileUrl+'/'+this.config.cid+'/'+event.data);
			break;
			
		case "upload_io_error" :
			// 这里做关于 上传失败 的处理
			//  通过访问 event.data 获得失败时的IO_ERROR文字描述
			alert(lang['E0100933']+'：'+event.data+','+lang['E0100934']);
			break;
	};
};



/**
 * 视频签署拍照
 * @param {Object} btn
 */
EWS.Order.GetCatalogProductList.prototype.camCapture = function(btn){
	if($("#"+this.config.id+"_ShowCapture")[0].checked == false){
		return;
	};
	
	var cam = swfobject.getObjectById("Order_"+this.config.id+"_Cam");	
	cam.pauseCamra();
	
	var _this = this;
	
	btn.innerHTML = EWS.Language['E01009']['E0100935'];
	btn.title = EWS.Language['E01009']['E0100935'];
	btn.onclick = function(){
		_this.camReset(btn);
	};
	
	//设置已经拍照标记
	$("#"+this.config.id+"_Capture").val("1");
};


/**
 * 视频签署重置
 * @param {Object} btn
 */
EWS.Order.GetCatalogProductList.prototype.camReset = function(btn){
	if($("#"+this.config.id+"_ShowCapture")[0].checked == false){
		return;
	};
	
	var cam = swfobject.getObjectById("Order_"+this.config.id+"_Cam");	
	cam.playCamra();
	
	var _this = this;
	btn.innerHTML = EWS.Language['E01009']['E0100936'];
	btn.title = EWS.Language['E01009']['E0100936'];
	btn.onclick = function(){
		_this.camCapture(btn);
	};
	
	//清空已经拍照标记
	$("#"+this.config.id+"_Capture").val("");
};

function createInheritance(parent, child) {
	var property;
	for(property in parent) {
		if(!child[property]) {
			child[property] = parent[property];
		};
	};
};




/**
 * 展示商品详细信息
 *  @param {Object} obj
 */
EWS.Order.GetProductDetail = function(obj){
	this.type = 'GetProductDetail';

	var  _this = this;
	
	this.config = obj;
	
	//图片缩放问题
	var size = this.returnWidthHeight(true); 
	var bigSize = this.returnWidthHeight('bigImg');
	var img = $('#'+obj.id).find('.ord_picshow img');	
	var len = img.length;
	for(var i = 0;i<len;i++){
		if(i == 0){
			this.setSmallPicSize(img[i],bigSize,'');
		}else{
			this.setSmallPicSize(img[i],size,'');
		}
	}
	
	return;
	
	/**
	 * 数据加载响应
	 * @param {Object} result 数据
	 */
	var _get_success = function(result){
		
		var arr = "";
		//先判断样式类型
		var size = this.returnWidthHeight(true); 
		
		var width = size[0];
		var height = size[1];
		if(!obj.styleId||obj.styleId ==1){
			arr = this.createProductDetailHtml(obj,result);
		}else if(obj.styleId == 2){
			arr = this.createProductDetailHtml2(obj,result);
		}else{
			arr = this.createProductDetailHtml3(obj,result);
		};
		
		$("#"+obj.id).html(arr[0]);
		
		//预加载图片，调整图片Size
		new EWS.PreLoadImage({
			 path:""
			,arrSrc:arr[1]
			,maxWidth:width
			,maxHeight:height
			,scope:_this
			,success:_this.setDetialImage
		});
		
	};
	
	$.ajax({
		url:"/EWS_Interface/Order_ProductShow.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{ProductID:obj.pId},
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result);
		}
	});
};

EWS.Order.GetCatalogProductList.prototype.setThisStyle = function(obj){
	if(this.type == 'GetProductDetail'){
		var cls = this.config.styleId == 2?'li_active':'li_active2';
	}else{
		var cls = 'li_active';
	}
	$(obj).parent().parent().find('.'+cls).removeClass();
	$(obj).parent().addClass(cls);
	
};


EWS.Order.GetProductDetail.prototype=EWS.Order.GetCatalogProductList.prototype;


/**
 * 商品详细独立页面
 * 
 */
/**
 * 展示商品详细信息
 *  @param {Object} obj
 */
EWS.Order.getDetailSelfPage = function(obj){
	this.type = 'getDetailSelfPage';

	var  _this = this;
	
	this.config = obj;
	
	//图片缩放问题
	var size = this.returnWidthHeight(true); 
	var bigSize = this.returnWidthHeight('bigImg');
	var img = $('#'+obj.id).find('.ord_picshow img');	
	var len = img.length;
	for(var i = 0;i<len;i++){
		if(i == 0){
			this.setSmallPicSize(img[i],bigSize,'');
		}else{
			this.setSmallPicSize(img[i],size,'');
		}
	}
};

EWS.Order.getDetailSelfPage.prototype=EWS.Order.GetCatalogProductList.prototype;

EWS.Order.GetCatalogProductList.prototype.setThisStyle = function(obj){
	if(this.type == 'GetProductDetail' || this.type =='getDetailSelfPage'){
		var cls = this.config.styleId == 2?'li_active':'li_active2';
	}else{
		var cls = 'li_active';
	}
	$(obj).parent().parent().find('.'+cls).removeClass();
	$(obj).parent().addClass(cls);
	
};

/**
 * 创建商品详细信息共享内容(样式一)
 * @param {Object} obj
 * @param {Object} result
 * @return {array} html ,imgList
 */
EWS.Order.GetCatalogProductList.prototype.createProductDetailHtml = function(obj,result){
	var lang = EWS.Language['E01005'];
	var p = result.MoneyType;
	if(p != '') 
	    p = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
    var appId = 'Order_'+obj.id;
	var imgList = [];//初始化预加载图片序列
	var pic = '';
	var PicLen = result.Pic.length;
	for(var i=0; i<6; i++){
		if(i<PicLen){//处理：增加预加载图片列表
			var newId = obj.id+'_Detial_'+i;
			imgList.push({src:result.Pic[i].Img||'http://'+this.config.htmlUrl+'/theme/order/img/noImg.png',id:newId});
			pic += '<li><a href="javascript:'+appId+'.showDetialImage(\''+newId+'\');" title="'+result.Pic[i].Name+'">' +
					'<img id="'+newId+'" ' +
						'src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png" ' +
						'alt="'+result.Pic[i].Name+'" width="80" height="80" />' +
					'</a><span>'+result.Pic[i].Name+'</span></li>';
		}else{//处理：空白列表
			pic += '<li><img  src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png"  width="84" height="84" title="'+lang['E010058']+'"/></li>';
		};
	};
	var style = "style=display:"+(result.Name?"block":"none"); 
	var html = 	'<div id=Pro_'+obj.pId+'  class="ord_picshow">'+
                    '<div class="ord_big">' +
						'<a href="javascript:'+appId+'.showProductImage();">' +
							'<img id="Product_'+obj.id+'_Img"' +
 								' src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png"' +
								' style="position:relative; top:36px;" alt="'+result.Name+'" />' +
						'</a>' +
					'</div>' +
					'<ul class="ord_small">'+pic+'</ul>'+
				'</div>'+
				'<div class="ord_dashed"></div>'+
				'<div class="ord_prd_info">'+
					'<span class="title" title="'+lang['E010051']+'"><strong>'+lang['E010051']+'：'+result.Name+'</strong></span>' +
					'<button '+style+' class="ord_buy" onclick="'+appId+'.setShoppingCar(\''+obj.pId+'\');'+appId+'.showShoppingCar();">'+lang['E010057']+'</button>' +
					'<span class="ord_price" title="'+lang['E010052']+'">'+lang['E010052']+'：<strong>'+p + result.UnitPrice+'</strong></span>' +
					'<div class="ord_dashed"></div>' +
					'<div class="ord_msg">' +
						'<div class="ord_msg_title">'+lang['E010056']+'</div>' +
						'<div>'+result.Intro+'</div>' +
					'</div>'+ 
				'</div>';
				
     return [html,imgList];
};

/**
 * 创建商品详细信息共享内容(样式二)
 * @param {Object} obj
 * @param {Object} result
 * @return {array} html ,imgList
 */
EWS.Order.GetCatalogProductList.prototype.createProductDetailHtml2 = function(obj,result){
	var lang = EWS.Language['E01005'];
	var p = result.MoneyType;
	if(p != '') 
		p = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
	var appId = 'Order_'+obj.id;
	var imgList = [];//初始化预加载图片序列
	var pic = '';
	var PicLen = result.Pic.length;
	
	for(var i=0; i<6; i++){
		var cls = "";
		if(i<PicLen){//处理：增加预加载图片列表
		    cls = i == 0?"class = 'li_active'":"";
			var newId = obj.id+'_Detial_'+i;
			imgList.push({src:result.Pic[i].Img||'http://'+this.config.htmlUrl+'/theme/order/img/noImg.png',id:newId});
			
			pic += '<li '+cls+'>'+
					'<img id="'+newId+'" ' +
							'src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png" ' +
							'alt="'+result.Pic[i].Name+'" width="62" height="56"  onclick="'+appId+'.showDetialImage(\''+newId+'\');'+appId+'.setThisStyle(this)" title="'+result.Pic[i].Name+'" class="hasImg"/>' +
					'</li>';
		}else{//处理：空白列表
			pic += '<li '+cls+'><img src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png"  width="62" height="56" title="'+lang['E010058']+'"/></li>';
		};
	};
	var style = "style=display:"+(result.Name?"block":"none"); 
	var html = 	'<div class="ord_picshow_title"><strong>'+result.Name+'</strong></div>'+
				'<div class="ord_picshow">' +
					'<div class="ord_big2">' +
						'<a href="javascript:'+appId+'.showProductImage();">' +
							'<img id="Product_'+obj.id+'_Img"' +
 								' src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png"' +
								' style="position:relative; top:36px;" alt="'+result.Name+'" />' +
						'</a>' +
					'</div>'+			
					'<div class="ord_prd_info2">'+
						'<span title="'+lang['E010052']+'" class="ord_price">'+
							''+lang['E010052']+'：<strong>'+p + result.UnitPrice+'</strong>'+
						'</span>'+
						'<div class="ord_line2"><div class="icon"/><div class="line"/></div>'+
						'<p title="'+result.Name+'" class="title"><strong>'+result.Name+'</strong></p>'+
						'<p>'+lang['E010053']+':'+result.Sn+'</p>';
	 if(this.IsShowCategory()){
	 	html += '<p>'+lang['E010054']+':'+result.Category+'</p>';
	 }
	 if(this.IsShowTag()){
	 	html += '<p>'+lang['E010055']+':'+result.Tag+'</p>';
	 }           
	 html += '</div>'+
					'<ul class="ord_small2">'+pic+'</ul>'+
					'<button  '+style+' class="ord_add" onclick="'+appId+'.setShoppingCar(\''+obj.pId+'\');'+appId+'.showShoppingCar();" >'+lang['E010057']+'</button>'+
				'</div>'+	
	            '<div class="ord_line2"><div class="icon"/><div class="line"/></div>'+
	            '<div class="ord_msg">'+
	            	'<div class="ord_msg_title">'+lang['E010056']+'</div>'+
	            	'<div>'+result.Intro+'</div>'+ 
	           '</div>';			
     return [html,imgList];
};

/**
 * 创建商品详细信息共享内容(样式三)
 * @param {Object} obj
 * @param {Object} result
 * @return {array} html ,imgList
 */
EWS.Order.GetCatalogProductList.prototype.createProductDetailHtml3 = function(obj,result){
	var lang = EWS.Language['E01005'];
	var p = result.MoneyType;
	if(p != ''){ 
		p = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
	}
	var appId = 'Order_'+obj.id;
	var imgList = [];//初始化预加载图片序列
	var pic = '';
	var PicLen = result.Pic.length;
	
	for(var i=0; i<6; i++){
		var cls = "";
		if(i<PicLen){//处理：增加预加载图片列表
		    cls = i == 0?"class = 'li_active2'":"";
			var newId = obj.id+'_Detial_'+i;
			imgList.push({src:result.Pic[i].Img||'http://'+this.config.htmlUrl+'/theme/order/img/noImg.png',id:newId});
			
			pic += '<li '+cls+'>'+
					'<img id="'+newId+'" ' +
							'src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png" ' +
							'alt="'+result.Pic[i].Name+'" width="49" height="40" onclick="'+appId+'.showDetialImage(\''+newId+'\');'+appId+'.setThisStyle(this)"  class="hasImg"/>' +
					'</li>';
		}else{//处理：空白列表
			pic += '<li '+cls+'><img src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png"  width="49" height="40" title="'+lang['E010058']+'"/></li>';
		};
	};
	var style = "style=display:"+(result.Name?"block":"none"); 
	var html = 	'<div class="ord_picshow_title"><strong>'+result.Name+'</strong></div>'+
				'<div class="ord_picshow">' +
					'<div class="ord_big2">' +
						'<a href="javascript:'+appId+'.showProductImage();">' +
							'<img id="Product_'+obj.id+'_Img"' +
 								' src="http://'+this.config.htmlUrl+'/theme/order/img/noImg.png"' +
								' style="position:relative; top:36px;"  alt="'+result.Name+'" />' +
						'</a>' +
					'</div>'+	
	                '<ul class="ord_small3">'+pic+'</ul>'+
					'<div class="ord_prd_info2 ord_prd_info3">'+
						'<p title="'+result.Name+'" class="title"><strong>'+lang['E010051']+'：'+result.Name+'</strong></p>'+
						'<span title="'+lang['E010052']+'" class="ord_price">'+
								'<strong>'+p + result.UnitPrice+'</strong>'+
						'</span>'+
						'<div class="ord_line3"/>'+
						'<p>'+lang['E010053']+':'+result.Sn+'</p>';
	 if(this.IsShowCategory()){
	 	html += '<p>'+lang['E010054']+':'+result.Category+'</p>';
	 }
	 if(this.IsShowTag()){
	 	html += '<p>'+lang['E010055']+':'+result.Tag+'</p>';
	 }             
	 html += '</div>'+
				'<button '+style+' class="ord_add" onclick="'+appId+'.setShoppingCar(\''+obj.pId+'\');'+appId+'.showShoppingCar();" >'+lang['E010057']+'</button>'+
				'</div>' +
		        '<div class="ord_msg">'+
	            	'<div class="ord_msg_title">'+lang['E010056']+'</div>'+
	            	'<div class="ord_msg_con">'+result.Intro+'</div>'+ 
	            '</div>';			
     return [html,imgList];
};

/**
 * 检查此详细信息组件是否不需要显示分类及标签
 */
EWS.Order.GetCatalogProductList.prototype.IsShowCategory = function(){
	var result = true;
	if(EWS.Order.Category){
		if(typeof EWS.Order.Category == 'object'){
			var len = EWS.Order.Category.length;
			for(var i=0;i<len;i++){
				if(EWS.Order.Category[i] == this.config.id){
					result = false;
					break;
				}			
			}
		}else if(typeof EWS.Order.Category == 'boolean'){
			result = false;
		}
	}
	return result;
};
/**
 * 检查此详细信息组件是否不需要显示分类及标签
 */
EWS.Order.GetCatalogProductList.prototype.IsShowTag = function(){
	var result = true;
	if(EWS.Order.Tag){
		if(typeof EWS.Order.Tag == 'object'){
			var len = EWS.Order.Tag.length;
			for(var i=0;i<len;i++){
				if(EWS.Order.Tag[i] == this.config.id){
					result = false;
					break;
				}			
			}
		}else if(typeof EWS.Order.Tag == 'boolean'){
			result = false;
		}
	}
	return result;
};

/**
 * 搜索订单
 * @param {Object} obj
 */
EWS.Order.SearchOrder = function(obj){
	this.type = 'SearchOrder';
	this.config = obj;
	var ord = $("#"+this.config.id).find('input[name="order"]');
	this.inputValidate(ord,EWS.Language['E01008']['E010082']);
};

EWS.Order.SearchOrder.prototype = EWS.Order.GetCatalogProductList.prototype;

/**
 * 通过订单名称搜索订单
 * @param {String} cmpId
 */
EWS.Order.SearchOrder.prototype.searchOrderByName = function(cmpId){
	var input = $.trim($("#"+cmpId).find('input[name="order"]').val());
	if(input&&input!=EWS.Language['E01008']['E010082']){
		this.config.searchValue = input;
		this.createOrderListBody();
	};
};

/**
 * 搜索订单
 * 
 */
EWS.Order.SearchOrder.prototype.createOrderListBody = function(){
	if(this.config.searchValue == '' || this.config.searchValue ==EWS.Language['E01008']['E010082']){return;}
	var _this = this;	
	var lang1 = EWS.Language['E01008'];
	var lang = EWS.Language['E01009'];
	var isExists = false;//设置浮动层不存在标记为true
	var scrollSize = EWS.GetPageScroll();
	var pageSize = EWS.GetPageSize();
	var target = $('#ShoppingCar_'+this.config.id);
	var top = scrollSize.Y+150;
	var left = (pageSize.WinW - 830) / 2;
	var appId = 'Order_'+this.config.id;
//	var ProductID = $.cookie("EWS_ShopCar_"+this.config.cid);
	var idList = [];

    //计算价格
	var formatfloat = function(f,size){  
	     var tf=f*Math.pow(10,size);  
	     tf=Math.round(tf+0.000000001);  
	     tf=tf/Math.pow(10,size); return tf;  
	};  
	var loadHtml =
	'<div class="ord_detail">' +
		'<div class="ord_loading"><strong>'+name+'</strong> '+lang1['E010081']+'</div>' +
	'</div>';
	
	var html = 
	'<div id="ShoppingCar_'+this.config.id+'" class="ord_mdl ord_box">'+
		'<div class="ord_mdl_t">' +
			'<div class="ord_mdl_t_l"></div>' +
			'<div class="ord_mdl_t_r"></div>' +
			'<div class="ord_mdl_t_c"><h2>'+lang1['E010084']+'</h2></div>' +
			'<div class="ord_mdl_t_m"><a href="javascript:'+appId+'.hideShoppingCar();" title="'+lang1['E010085']+'">'+lang1['E010085']+'</a></div>' +
		'</div>' +
		
		'<div class="ord_mdl_c ord_g_p_hide">' +
			'<div class="ord_mdl_c_l ord_g_p_fill"></div>' +
			'<div class="ord_mdl_c_r ord_g_p_fill"></div>' +				
			'<div class="ord_mdl_c_c">' + loadHtml + '</div>' +
		'</div>' +
		
		'<div class="ord_mdl_b">' +
			'<div class="ord_mdl_b_l"></div>' +
			'<div class="ord_mdl_b_r"></div>' +
			'<div class="ord_mdl_b_c"></div>' +
		'</div>' +
	'</div>';
	
	var _get_success = function(result){
		var orderDetail = result.Order[0];
		
		var orderProductList = result.OrderDetial;
		
//		var info_id = "EWS_ShopInfo_"+this.config.cid;
//		var info = $.cookie(info_id);
		var input = {
			'OrderInfo_Member' : {
				 name:lang1['E010086']
				,cls:'ord_info_p'
				,tag:'p'
				,type:'text'
				,value:orderDetail.Account?orderDetail.Account:''
			},
			'OrderInfo_Name' : {
				 name:lang['E010092']
				,cls:'ord_info_p'
				,tag:'p'
				,type:'text'
				,value:orderDetail.OwnerName
			}
			,'OrderInfo_Tel' : {
				 name:lang['E010094']
				,cls:'ord_info_p'
				,tag:'p'
				,type:'text'
				,value:orderDetail.Phone
			}
			,'OrderInfo_Email' : {
				 name:lang['E010096']
				,cls:'ord_info_p'
				,tag:'p'
				,type:'text'
				,value:orderDetail.Email
			}
			,'OrderInfo_Addr' : {
				 name:lang['E010098']
				,cls:'ord_info_p'
				,tag:'p'
				,type:'text'
				,value:orderDetail.Address
			}
			,'OrderInfo_Remarks' : {
				 name:lang['E0100910']
				,cls:'ord_info_p'
				,tag:'p'
				,type:'text'
				,value:orderDetail.Memo.replace(/\s/g,"&nbsp;")
			}
		};

//		if(orderDetail != null){
//			var infoArr = $.evalJSON(info);
//			
//			$.each(orderDetail , function(i,v){
//				input[i].value =  v;
//				input[i].cls = input[i].cls.replace(/ ord_info_error/ , "");
//			});
//		};
		
		var infoHTML = [];
		$.each(input , function(i,v){
			if(v.tag == 'input'){
				infoHTML.push(
				'<label for="'+i+'"><strong>'+v.name+'</strong>' +					
					'<'+v.tag+' id="'+i+'" class="'+v.cls+'" type="'+v.type+'" value="'+v.value+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);" />' +
				'</label>'
				);
			}else{
				infoHTML.push(
				'<label for="'+i+'"><strong>'+v.name+'</strong>' +					
					'<'+v.tag+' id="'+i+'" class="'+v.cls+'" type="'+v.type+'" onblur="'+appId+'.changeShoppingInfo(this);" onfocus="'+appId+'.focusShoppingInfo(this);">'+v.value+'</'+v.tag+'>' +
				'</label>'
				);
			};
		});
		var Payment = orderDetail.Payment == 1?lang['E0100914']:(orderDetail.Payment == 2?lang['E0100915']:lang['E0100916']);
		var cls = orderDetail.Pic?'ord_video':'ord_noVideo';
		var html = 
		'<div class="ord_neworder">' +
//			'<h3 class="ord_title">新购物订单：</h3>' +
			
			'<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
				'<tr>' +
					'<th class="order_time">'+lang['E0100912']+'</th>' +
					'<td class="order_no">'+orderDetail.CreatedDate+'</td>' +
					'<th class="order_time">'+lang['E0100913']+'</th>' +
					'<td class="order_no" id="Payment">'+Payment +
//						'<label for="pay">' +
//							'<select id="Payment">' +
//							'<option value="1">银行转帐</option>' +
//							'<option value="2">货到付款</option>' +
//							'<option value="3">其它</option>' +
//							'</select>' +
//						'</label>' +
					'</td>' +
					'<th class="order_time"></th>' +
					'<td class="order_no"></td>' +
					'<th class="order_time"></th>' +
					'<td class="order_no"></td>' +
				'</tr>' +
			'</table>' +
			
			'<div class="order_bor">' +
				'<table id="Product_'+_this.config.id+'_Table" width="100%" border="0" cellspacing="0" cellpadding="0">{data}</table>' +				
			'</div>' +
			'{total}' +
			
			'<div class="ord_info">{info}</div>' +			
			'<div class="ord_pht">' +
				'<div class="'+cls+'"><img src="'+orderDetail.Pic+'" title="'+EWS.Language['E01008']['E0100821']+'" /></div>'+
//				'<div class="ord_video"><div id="Order_'+_this.config.id+'_Video"></div></div>' +
//				'<div class="ord_noVideo" style="display:none;">' +
//					'<div class="ord_tips"><strong></strong></div>' +
//				'</div>' +
//				'<div class="ord_checkbox">' +
//					'<label for="'+_this.config.id+'_ShowCapture"><input type="checkbox" id="'+_this.config.id+'_ShowCapture" checked="checked" />我要视频签署</label>' +
//				'</div>' +
//				'<input type="hidden" id="'+_this.config.id+'_Capture" value="" />' +
//				'<button class="ord_video_btn" title="视频签署" onclick="Order_'+_this.config.id+'.camCapture(this)">视频签署</button>' +
			'</div>' +
			
			'<div class="ord_line"></div>' +
			'<div class="ord_newOrd_loading" style="display:none"><img src="http://'+_this.config.htmlUrl+'/theme/order/img/indicator.gif" />'+lang['E010083']+'</div>' +
//			'<button class="ord_order_btn" title="提交订单" onclick="'+appId+'.submitShopping();">提交订单</button>' +
			
		'</div>';
		
		var line = 
		'<tr>' +
			'<td height="1" colspan="12"><div class="ord_dashed1"></div></td>' +
		'</tr>';
		
		var infoLine = '<div class="ord_dashed"></div>';
		
		//获得订单中产品数量
		var car_id = "EWS_ShopCar_"+this.config.cid;
		var car = $.cookie(car_id);
		var amount = {};
		if(car != null){//处理：已有cookie
			var valArr = $.evalJSON(car);
	
			$.each(valArr , function( i , v){
				amount[v.id] = parseInt(v.amount);
			});
		};

		var rLen = orderProductList.length;
		var totalPrice = 0;
		var data = [];
		if(rLen > 0){//处理：有产品数据
			for(var i=0; i<rLen; i++){
				data.push(
					'<tr id="Product_'+orderProductList[i].ProductId+'_Row" class="order_sta">' +
						'<th class="digi">1.</th>' +
						'<th>'+lang['E0100919']+'</th>' +
						'<td class="name"><a href="javascript:'+appId+'.showDetial(\''+orderProductList[i].ProductId+'\',\''+orderProductList[i].ProductName+'\');" title="'+orderProductList[i].ProductName+' 商品详细信息">'+orderProductList[i].ProductName+'</a></td>' +
						'<th>'+lang['E0100920']+'</th>' +
						'<td class="no">'+orderProductList[i].ProductSN+'</td>' +
						'<th>'+lang['E0100921']+'</th>' +
						'<td class="price" id="'+orderProductList[i].ProductId+'_UnitPrice">'+orderProductList[i].UnitPrice+'</td>' +
						'<th>'+lang['E0100922']+'</th>' +
						'<td class="amount">' +
							'<label for="amount">'+orderProductList[i].Amount+'</label>' +
						'</td>' +
						'<th>'+lang['E0100923']+'</th>' +
						'<td class="total" id="'+orderProductList[i].ProductId+'_TotalPrice">'+formatfloat(parseFloat(orderProductList[i].UnitPrice) * parseInt(orderProductList[i].Amount),2)+'</td>' +
//						'<td><a href="javascript:'+appId+'.delShoppingCar(\''+orderProductList[i].ProductId+'\');" title="删除 '+orderProductList[i].ProductName+'产品" class="ord_del">删除</a></td>' +
					'</tr>'
				);
				
				totalPrice+=formatfloat(parseFloat(orderProductList[i].UnitPrice) * parseInt(orderProductList[i].Amount),2);
			};
			
			html = html.replace(/{data}/ , data.join(line));
			html = html.replace(/{total}/, '<div class="order_sum">'+lang['E0100925']+':￥<span id="Order_'+_this.config.id+'_TotalPrice">'+totalPrice+'</span></div>');
			
		}else{//处理：没有产品数据
			html = html.replace(/{data}/ , '<tr class="order_nodata">'+lang['E0100926']+'</tr>');
			html = html.replace(/{total}/, '');
		};
		
		html = html.replace(/{info}/ , infoHTML.join(infoLine) );
		
		var target = $('#ShoppingCar_'+this.config.id);
		var target_detial = $("#ShoppingCar_"+_this.config.id+" div.ord_mdl_c_c");

		
		//若浮动层存在，则直接显示
		if(isExists){
			target_detial.html(html);
			return;
		};
				
		target
		.animate({top: top+'px' , left: left+'px'}, "normal")
		.animate({width: '+830px'}, "fast" , function(){
			target_detial.html(html);
			var flashvars = {};
			flashvars.debug = "false";
			flashvars.eventLinstener = "Order_"+_this.config.id+".camEvent";
			var params = {};
			params.wmode = "opaque";
			params.allowscriptaccess = "always";
			params.bgcolor = "#989797";
			var attributes = {};
			attributes.id = "Order_"+_this.config.id+"_Cam";
			swfobject.embedSWF("http://"+_this.config.htmlUrl+"/theme/CameraCapture.swf", 'Order_'+_this.config.id+'_Video', "320", "240", "9.0.0", false, flashvars, params, attributes);
		});

	};
	
	EWS.Order.layerIndex++;//设置当前浮动层数
	
	if(target.length==0){//处理：浮动层不存在
		$(html)
		.css({
	    	 position:'absolute'
			,width:350
			,'z-index':EWS.Order.layerIndex
			,top: ( (pageSize.WinH - 100) /2) + scrollSize.Y
			,left:(pageSize.WinW - 350) / 2
		})
		.appendTo("body");
	}else{//处理：浮动层已经存在
		$('#ShoppingCar_'+this.config.id+' div.ord_mdl_c_c').html(loadHtml);
		isExists = true;//设置浮动层不存在标记为true
	};
	
//	if(ProductID != null){//处理：有cookie
//		var data = $.evalJSON(ProductID);
//		
//		$.each(data , function(i , v){
//			idList.push(v.id);
//		});
//		
//		var id_value = idList.join(",");
//	}else{
//		var id_value = '';
//	};
	
	$.ajax({
		url:"/EWS_Interface/Order_GetOrder.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{CID:this.config.cid,OrderID:this.config.searchValue},
		cache:false,
		dataType:'json',
		success:function(result){
			if(result.Order.length){
				_get_success.call(_this,result);
			}else{
				var obj = $('#ShoppingCar_'+_this.config.id);
				obj.css({'width':'850px','left':left});
				obj.find('.ord_loading').html(lang['E0100829']);
			};
		}
	});
	
};

/**
 * 验证输入字符
 * @param {Object} obj
 * @param {String} tips
 */
EWS.Order.GetCatalogProductList.prototype.inputValidate = function(obj,tips){
	obj.bind('click',function(){
		if(this.value == tips){
			this.className = "";
			this.value = "";
		};
	}).bind('blur',function(){
		if($.trim(this.value) == ""){
			this.className = "ord_info_error";
			this.value = tips;
		};
	}).val(tips);
};


/**
 * 查找商品,实例化
 * @param {Object} json
 */
EWS.Order.orders_productSearch = function(json){
	this.type = 'orders_productSearch';
	this.config = json;
	var pro = $("#"+this.config.id).find('input[name="product"]');
	this.inputValidate(pro,EWS.Language['E01007']['E010071']);

};

/**
 * 商品搜索继承类
 */
EWS.Order.orders_productSearch.prototype = EWS.Order.GetCatalogProductList.prototype;


/**
 * 点击查找商品
 * @param {String} cmpId
 */
EWS.Order.orders_productSearch.prototype.searchPro = function(cmpId){
	var input = $.trim($("#"+cmpId).find('input[name="product"]').val());
	if(input&&input!=EWS.Language['E01007']['E010071']){
		this.config.searchValue = input;
		this.createProductListBody(1);
	};
};



/**
 * 创建搜索商品列表主体
 * @param {Number} pageNum 页码
 * @param {String} Category 分类
 */
EWS.Order.orders_productSearch.prototype.createProductListBody = function(pageNum,Category){
	    var lang = EWS.Language['E01007'];
	    var _this = this;
		var _get_success = function(result){
			this.hideImgLayer();
			var appId = 'Order_'+this.config.id;
			var _this = this;
			var scrollSize = EWS.GetPageScroll();
			var pageSize = EWS.GetPageSize();
			var top = scrollSize.Y+20;
			var left = (pageSize.WinW - 830) / 2;	
			var isExists = false;//设置浮动层不存在标记为false  
			var id = 'ProductSearch_'+this.config.id;
			
			var html = 
				'<div id="ProductSearch_'+this.config.id+'" class="ord_mdl ord_box">' +
					'<div class="ord_mdl_t">' +
						'<div class="ord_mdl_t_l"></div>' +
						'<div class="ord_mdl_t_r"></div>' +
						'<div class="ord_mdl_t_c"><h2>'+lang['E010073']+'</h2></div>' +
						'<div class="ord_mdl_t_m"><a href="javascript:'+appId+'.hideDetial(\''+id+'\');" title="'+lang['E010074']+'">'+lang['E010074']+'</a></div>' +
					'</div>' +
					
					'<div class="ord_mdl_c ord_g_p_hide">' +
						'<div class="ord_mdl_c_l ord_g_p_fill"></div>' +
						'<div class="ord_mdl_c_r ord_g_p_fill"></div>' +				
						'<div class="ord_mdl_c_c">' +
							'<div class="ord_product padding">' +
								
	
	
							'</div>' +
						'</div>' +
					'</div>' +
					
					'<div class="ord_mdl_b">' +
						'<div class="ord_mdl_b_l"></div>' +
						'<div class="ord_mdl_b_r"></div>' +
						'<div class="ord_mdl_b_c"></div>' +
					'</div>' +		
				'</div>';
		EWS.Order.layerIndex++;
		if($("#"+id).length == 0){	
			$('body').append(html);
			$(html)
			.animate({top: top+'px' , left: left+'px'}, "normal")
			.animate({width: '+830px'}, "fast" , function(){
//				$('body').append(html);
			});
			$('#ProductSearch_'+this.config.id).attr({'style':"position:absolute;left:"+left+"px;top:"+top+"px;z-index:"+EWS.Order.layerIndex});
		};
		
		var target = $('#ProductSearch_'+this.config.id);
		var parent = target.find('.ord_product');
		parent.html("");
		this.searchProductHtml(result,parent);

		parent.prepend('<h3 class="ord_title">'+lang['E010075']+''+this.config.searchValue+' '+lang['E010076']+'<strong class="amount">'+(result.totalCount)+'</strong>'+lang['E010077']+'：</h3>');
		$("<div class='ord_mop_page'></div>").appendTo(parent);
		this.setNavigation(pageNum , Math.ceil(parseInt(result.totalCount)/6) || 0,'ProductSearch_'+this.config.id,true);//设定分页导航
	};
	var param = {CID:this.config.cid,q:this.config.searchValue,Total:true,PageNum:1,PageItem:6};
	if(Category&&Category!="0"){
		param.Category = Category;
	};

	$.ajax({
		url:"/EWS_Interface/Order_ListProduct.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:param,
		cache:false,
		dataType:'json',
		success:function(result){
			_get_success.call(_this,result);
		}
	});
};

EWS.Order.GetCatalogProductList.prototype.getLists = function(page){
	var param = {CID:this.config.cid,q:this.config.searchValue,Total:true,PageNum:page,PageItem:6};
	var lang = EWS.Language['E01007'];
	var self = this;
	$.ajax({
		url:"/EWS_Interface/Order_ListProduct.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:param,
		cache:false,
		dataType:'json',
		success:function(result){
			var target = $('#ProductSearch_'+self.config.id);
			var parent = target.find('.ord_product');
			parent.html("");
			parent.prepend('<h3 class="ord_title">'+lang['E010075']+' '+self.config.searchValue+' '+lang['E010076']+'<strong class="amount">'+(result.totalCount)+'</strong>'+lang['E010077']+'：</h3>');
			self.searchProductHtml(result,parent);
			$("<div class='ord_mop_page'></div>").appendTo(parent);
				self.setNavigation(page , Math.ceil(parseInt(result.totalCount)/2) || 0,'ProductSearch_'+self.config.id,true);//设定分页导航
		}
	});
};



/**
 * 商品列表公共部分
 * @param {Object} result
 * @param {Object} parent
 */
EWS.Order.GetCatalogProductList.prototype.searchProductHtml = function(result,parent){
	var lang = EWS.Language['E01002'];
	imgList = [];
	var ul = [];
	var pLen = result.Product.length;
	if(pLen){
    	var p = result.MoneyType;
   		var mType = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
	}
	var _this = this;
	var appId = 'Order_'+this.config.id;
	$.each(result.Product , function(i,v){
		//增加预加载图片列表
		var newId = parseInt(_this.config.id).toString(36)+"_"+i;
		imgList.push({src:v.Img?v.Img:'http://'+_this.config.htmlUrl+'/theme/order/img/noImg.png',id:newId});
		
//		if((i+1) % 3 == 1){
//			ul = [];
//		};
		var action = 'javascript:'+appId+'.showDetial(\''+v.ID+'\',\''+v.Name+'\');';
		ul.push(		
			'<li>' +
	 			'<div class="size">' +
		   			'<a href="'+action+'"><img  style="position: relative; top: 0.25px;" width="128" height="127"  title="'+v.Name+'"  src="http://'+_this.config.htmlUrl+'/theme/order/img/noImg.png" id="'+newId+'"/></a>' +
		   		'</div>' +
			    '<div class="content">' +
			  	    '<span>'+mType +v.UnitPrice+'</span>' +
			  	    '<button class="buy" title="'+lang['E010028']+'"  onclick="'+appId+'.setShoppingCar(\''+v.ID+'\');'+appId+'.showShoppingCar();">'+lang['E010028']+'</button>' +
			  	    '<a class="detail" title="'+lang['E010029']+'" href="'+action+'">'+lang['E010029']+'</a>' +
			    '</div>' +
   				'<div class="title">' +
   				  	'<strong><a href="'+action+'">'+v.Name+'</a></strong>' +
   				'</div>'+
			'</li>'
		);
//		if((i+1) % 3 == 0 || (i+1) == pLen){
//		};
	});
	$('<div class="ord_mop_eight"><ul>'+ul.join("")+'</ul></div>').appendTo(parent);
	//预加载图片，调整图片Size
	new EWS.PreLoadImage({
		 path:""
		,arrSrc:imgList
		,maxWidth:177
		,maxHeight:128
		,scope:_this
		,success:''
	});
};


/**
 * 搜索商品与订单
 * @param {Object} obj
 */
EWS.Order.orders_productOrdersSearch = function(obj){
	this.type = 'orders_productOrdersSearch';
	this.config = obj;
	
	var pro = $("#"+this.config.id).find('input[name="product"]');
	var ord = $("#"+this.config.id).find('input[name="order"]');
	this.inputValidate(pro,EWS.Language['E01010']['E010102']);
	this.inputValidate(ord,EWS.Language['E01010']['E010105']);
};

EWS.Order.orders_productOrdersSearch.prototype = EWS.Order.GetCatalogProductList.prototype;


/**
 * 通过订单名称搜索订单
 * @param {String} cmp
 */
EWS.Order.orders_productOrdersSearch.prototype.searchOrderOrproByName = function(cmp){
	if(cmp == "1" ||cmp ==1 ){//搜索商品
		var input = $.trim($("#"+this.config.id).find('input[name="product"]').val());
		if(input&&input!=EWS.Language['E01010']['E010102']){
			this.config.searchValue = input;
			this.createProductListBody();
		};
	}else{//搜索订单
		var input = $.trim($("#"+this.config.id).find('input[name="order"]').val());
		if(input&&input!=EWS.Language['E01010']['E010105']){
			this.config.searchValue = input;
			this.createOrderListBody();
		};
	};
};

/**
 * 购物车类
 * @param {Object} obj
 */
EWS.Order.orders_shoppingCar = function(obj){
	this.type = 'orders_shoppingCar';
	this.config = obj;
};

EWS.Order.orders_shoppingCar.prototype = EWS.Order.GetCatalogProductList.prototype;

/**
 * 通过订单名称搜索订单
 * @param {String} cmp
 */
EWS.Order.orders_shoppingCar.prototype.shoppingCar = function(cmp){
     this.showShoppingCar();
};





/**
 * 全功能搜索类
 * @param {Object} obj
 */
EWS.Order.orders_fullearch = function(obj){
	this.type = 'orders_fullearch';
	this.config = obj;
	var JsTree = new EWS.Order.JsTree("showNode", "hideNode",obj.htmlUrl,obj.id);
	JsTree.newtree2("/EWS_Interface/Order_ListAllCatalog.aspx?cid="+this.config.cid,JsTree,obj.id);
	this.JsTree = JsTree;

	var pro = $("#"+this.config.id).find('input[name="product"]');
	var ord = $("#"+this.config.id).find('input[name="order"]');
	this.inputValidate(pro,EWS.Language['E01006']['E010062']);
	this.inputValidate(ord,EWS.Language['E01006']['E010065']);
	
};

EWS.Order.orders_fullearch.prototype = EWS.Order.GetCatalogProductList.prototype;
EWS.Order.orders_fullearch.prototype = EWS.Order.orders_productSearch.prototype;


/**
 * 通过商品名称搜索商品
 */
EWS.Order.orders_fullearch.prototype.searchProductByName = function(){
	var input = $.trim($("#"+this.config.id).find('input[name="product"]').val());
	if(input&&input!=EWS.Language['E01006']['E010062']){
		this.config.searchValue = input;
		this.createProductListBody(1,this.JsTree.curId);
	};
};

/**
 * 通过订单名称搜索订单
 */
EWS.Order.orders_fullearch.prototype.searchOrderByName = function(){
    var input = $.trim($("#"+this.config.id).find('input[name="order"]').val());
	if(input&&input!=EWS.Language['E01006']['E010065']){
		this.config.searchValue = input;
		this.createOrderListBody();
	};
};

/**
 * 点击购物车
 */
EWS.Order.orders_fullearch.prototype.showCar = function(){
	 this.showShoppingCar();
};



/**
 * 多商品展示问题
 * @param {Object} obj
 */
EWS.Order.orders_showMoreProduct = function(obj){
	this.config = obj;
	this.type = 'orders_showMoreProduct';
	var _this = this;
	
	var appId = 'Order_'+this.config.id;
	
	var imgHW = this.returnWidthHeight();
//	    获取图片范围
	if(obj.picSize&&(obj.picSize == 2||obj.picSize == '2')){
		var imgHW = [Number(obj.picsizeW),Number(obj.picsizeH)];
	}
	if(obj.styleId !=2 && imgHW.length){
		//预加载图片，调整图片Size
	}else{
	    if(!imgHW.length){
	    	imgHW = [73,75];
	    }
	};
    this.config.size = imgHW;
	
	var anchor = EWS.Anchor.get("Order_"+this.config.id);
	if(anchor == null){
			var pageNum = 1;
		}else{
			var pageNum = parseInt(anchor.split(",")[1]);
	};
	
	if(Number(pageNum) == 1){
		var img = $('#'+this.config.id +' .pro_img');
		var len = img.length;
		for(var i=0;i<len;i++){
			this.setSmallPicSize(img[i],imgHW,'overPic');
		}
		return;
	}
	
	
	//如果不是第一页就不会往下执行
	var _this = this;
	//获取所有商品数量
	$.ajax({
		url:"/EWS_Interface/Order_getMoreProduct.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{CID:this.config.cid,proIDs:this.config.proListId},
		cache:false,
		dataType:'json',
		success:function(result){
			_this.proMoreListData = result;
			_this.moreProductGetData(pageNum);
		}
	});

};

EWS.Order.orders_showMoreProduct.prototype = EWS.Order.GetCatalogProductList.prototype;


/**
 * 混搭组件
 * 获取数据
 */
EWS.Order.orders_showMoreProduct.prototype.moreProductGetData = function(page){
	/**
	 * 获取显示的商品，响应操作
	 * @param {Object} result
	 */
	if(this.proMoreListData){
		var len = this.proMoreListData.length;
		if(this.config.styleId !='2'&&this.config.hasPage == 'true'){
			var pageSize = Number(this.config.pageItem);
			if(len>=pageSize){//总商品大于单页数
				var startId = (page-1)*pageSize;
				if(len>startId){//总商品大于当前页数的开始
	//			    ids = idsArray.slice(startId,(startId+pageSize)).join(',');
				    var data = this.proMoreListData.slice(startId,(startId+pageSize));
				    this.getHtmlSrc(data,page);
				}else{
					return;
				}
			}else{
				this.getHtmlSrc(this.proMoreListData,page);
			}
		}else{
			this.getHtmlSrc(this.proMoreListData,page);
		}
	}else{
		var _this = this;
		//获取所有商品数量
		$.ajax({
			url:"/EWS_Interface/Order_getMoreProduct.aspx",//考虑到适应所有域名访问，所以使用绝对路径
			type:'get',
			data:{CID:this.config.cid,proIDs:this.config.proListId},
			cache:false,
			dataType:'json',
			success:function(result){
				var len = result.length;
				for(var i = 0;i<len;i++){
					if(result[i].url!=''){
						result[i].url = _this.getSmallPicPath(result[i].url);
					}else{
						result[i].url = 'http://'+_this.config.htmlUrl+'/theme/order/img/noImg.png';
					}
				}
				_this.proMoreListData = result;
				_this.moreProductGetData(page);
			}
		});
	}
};

/**
 * 混搭组件
 * 创建html
 */
EWS.Order.orders_showMoreProduct.prototype.getHtmlSrc =  function(data,page){
	var html = '';
	var imgList = [];//初始化预加载图片序列
	var obj = this.config;
	var _this = this;
	var len = data.length;
	var parent = $('#'+obj.id);
	if(len){
		var p = data[0].moneytype;
		this.config.mType = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
	}else{
//		this.moreProductGetData(page);
		parent.append('<div class="noData">'+EWS.Language['E01004']['E010043']+'</div>');
		return;
	}
	var ul = $('<ul></ul>');
	if(obj.styleId == 2){
		var rdata = this.productNode();
		parent.append('<ul>'+rdata[0]+'</ul>');
	}else{
		parent.html('');

		if(obj.hasPage == 'true'){
			if(obj.rowItem==0||obj.rowItem=='0'||obj.rowItem == ""){//没有设置每行数量
				for(var i=0;i<len;i++){
					ul.append(this.returnHtmlSrc(data[i],i,len));
				};
				parent.append(ul);
				
			}else{
				for(var i=0;i<len;i++){
					//增加预加载图片列表
					if(obj.rowItem == 1){
						ul = $('<ul></ul>');
					}else{
						if((i+1) % obj.rowItem == 1){
							ul = $('<ul></ul>');
						};
					};
					
					ul.append(this.returnHtmlSrc(data[i],i,len));
					if((i+1) % obj.rowItem == 0 || (i+1) == len){
						parent.append(ul);
					};
				};
			}
			//加翻页条
			parent.append('<div class="ord_mop_page"></div>');
			this.setNavigation(page ,Math.ceil(parseInt(obj.proListId.split(',').length)/obj.pageItem)||0,obj.id,'last');//设定分页导航
			
		}else{
			ul = $('<ul></ul>');
			if(obj.rowItem != ""&&obj.rowItem!=0){
				if(obj.pageItem<len){
					len = obj.pageItem;
				}
			}
			if(obj.rowItem==0||obj.rowItem=='0'||obj.rowItem == ""){//没有设置每行数量
				for(var i=0;i<len;i++){
					ul.append(this.returnHtmlSrc(data[i],i,len));
				};
				parent.append(ul);
			}else{//设置每行数量
				for(var i=0;i<len;i++){
					//增加预加载图片列表
					if(obj.rowItem == 1){
						ul = $('<ul></ul>');
					}else{
						if((i+1) % obj.rowItem == 1){
							ul = $('<ul></ul>');
						};
					};
					
					ul.append(this.returnHtmlSrc(data[i],i,len));
					if((i+1) % obj.rowItem == 0 || (i+1) == len){
						parent.append(ul);
					};
				};
			}
		}
	}
	
	
};

/**
 * 混搭组件
 * 返回HTML
 */
 
EWS.Order.orders_showMoreProduct.prototype.returnHtmlSrc = function(data,i,pLen){
	 var obj = this.config;
	 var style = "style=margin-right:"+obj.sBetween+"px";
	 if((i+1) % obj.rowItem == 0 || (i+1) == pLen){
        style = '';
	 };
	 var newId = obj.id+"_img_"+i;
 	 var appId = 'Order_'+obj.id;
	 if(obj.showProDetail&&Number(obj.showProDetail) == 2){//独立页显示产品信息
 	 	 var action = 'javascript:'+appId+'.showPageDetial(\''+data.id+'\',\''+data.name+'\',\''+obj.detailMenuId+'\');';
 	 }else{
 	 	 var action = 'javascript:'+appId+'.showDetial(\''+data.id+'\',\''+data.name+'\');';
	 }
 	 var setImg = 'javascript:'+appId+'.imgLoadComplete(this)';
	 switch(obj.styleId){
		 case '8':
			 return '<li '+style+'>' +
						'<div class="title"><a href="'+action+'" title="">'+data.name+'</a></div>' +
						'<div class="one_img"><a href="'+action+'"><img onload="'+setImg+'" src="'+data.url+'" title="'+data.name+'" id="'+newId+'"/></a></div>' +
						'<div class="content">' +
							'<div class="number1"><div class="number2"><strong>'+data.sn+'</strong></div></div>' +
							'<div class="price1"><div class="price2"><strong>'+obj.mType+' '+data.unitprice+'</strong></div></div>' +
						'</div>'+
					'</li>';
			 break;
		 case '1':
			 return '<li '+style+'>' +
						'<div class="content">' +
							'<div class="price"><strong>'+obj.mType +data.unitprice+'</strong></div>' +
							'<a  href="'+action+'" title=""><img  onload="'+setImg+'"  src="'+data.url+'"  title="'+data.name+'" id="'+newId+'"/></a>' +
						'</div>' +
						'<div class="title">' +
							'<a href="'+action+'" title="">'+data.name+'</a>' +
							'<span>'+data.sn+'</span>' +
							'</div>'+
					'</li>';
			 break;
		 case '3':
			 return '<li '+style+'>' +
						'<div class="content"><a  href="'+action+'" title=""><img  onload="'+setImg+'"  src="'+data.url+'" title="'+data.name+'" id="'+newId+'"/></a></div>'+
					'</li>';
			 break;
		 case '4':
			 return '<li '+style+'>' +
						'<div class="content">' +
							'<div class="title">' +
								'<a href="'+action+'" title="">'+data.name+'</a>' +
								'<div class="price"><span>'+obj.mType +data.unitprice+'</span></div>' +
								'<div class="buy"><a href="javascript:void(0)" title="'+EWS.Language['E01004']['E010047']+'" onclick="'+appId+'.setShoppingCar(\''+data.id+'\');'+appId+'.showShoppingCar();"><img src="http://'+this.config.htmlUrl+'/theme/order/img/buy.png" >'+EWS.Language['E01004']['E010047']+'</a></div>' +
							'</div>' +
							'<div class="photo"><a  href="'+action+'" title=""><img  onload="'+setImg+'"  src="'+data.url+'" title="'+data.name+'" style="position: relative; top: 0.5px;" id="'+newId+'"/></a><div>' +
						'</div>'+
					'</li>';
			 break;
		case '5':
			 return '<li '+style+'>' +
						'<div class="content">' +
							'<div class="photo">' +
								'<a  href="'+action+'" title=""><img  onload="'+setImg+'"  src="'+data.url+'" title="'+data.name+'" style="position: relative; top: 1px;" id="'+newId+'"/></a>' +
								'<a class="price"  href="'+action+'"><strong>'+obj.mType +data.unitprice+'</strong></a>' +
							'</div>' +
							'<div class="title">' +
								'<a href="'+action+'" title="">'+data.name+'</a>' +
								'<span>'+data.sn+'</span>' +
							'</div>' +
						'</div>' +
					'</li>';
			 break;
		case '6':
			 return '<li '+style+'>' +
						'<div class="content">' +
							'<div class="price"><strong>'+obj.mType +data.unitprice+'</strong>' +
								'<div class="title">' +
									'<a href="'+action+'" title="">'+data.name+'</a>' +
									'<span>'+data.sn+'</span>' +
								'</div>' +
							'</div>' +
							'<div class="photo"><a  href="'+action+'" title=""><img  onload="'+setImg+'"   src="'+data.url+'" title="'+data.name+'" style="position: relative; top: 5px;" id="'+newId+'"/></a></div>' +
						'</div>	'+
					'</li>';
			 break;
		case '7':
			 return '<li '+style+'>' +
						'<div class="price">' +
							'<div class="title">' +
								'<a href="'+action+'" title="">'+data.name+'</a>' +
								'<span>'+EWS.Language['E01004']['E010048']+'：'+data.sn+'</span><strong>'+obj.mType +data.unitprice+'</strong>' +
							'</div>' +
						'</div>'+
					'</li>';
			 break;
	};
};

EWS.Order.orders_showMoreProduct.prototype.showPic = function(id){
	window.open($('#'+id).attr('src'));
};


EWS.Order.orders_showMoreProduct.prototype.productNode = function(data,type){
    var appId = 'Order_'+this.config.id;
    
    var len = this.proMoreListData.length;
    var html = '';
    var imgList = [];
	var appId = 'Order_'+this.config.id;
	var setImg = 'javascript:'+appId+'.imgLoadComplete(this)';
    for(var i=(len-1);i>=0;i--){
    	var data = this.proMoreListData[i];
    	var dis = "display:block";
    	var disb =  "display:none";
    	if(i == (len-1)){
    		dis = "display:none";
    		disb =  "display:block";
    	}
	    var action = 'javascript:'+appId+'.showDetial(\''+data.id+'\',\''+data.name+'\');';
	    
    	html += '<li id="p1_'+data.id+'" onmouseover="'+appId+'.overShowProduct(this,\''+data.id+'\');" style="'+dis+'">'+data.name+'</li>';
    	
    	var img = data.url||'http://'+this.config.htmlUrl+'/theme/order/img/noImg.png';
		var id = this.config.id+'_morePro_'+i;
	    html += '<li id="p1_'+data.id+'_b" class="current"  style="'+disb+'">'+
			       '<div class="blending">' +
					    '<div class="blend_photo"><a href="'+action+'" ><img id=\''+id+'\' src="'+img+'" width="75" height="75"  onload="'+setImg+'" /></a></div>' +
					    '<div class="blend_name"><span title="'+data.name+'">'+data.name+'</span><p>'+ this.config.mType +'</p><strong>'+data.unitprice+'</strong>' +
					    	'<a href="javascript:void(0)" ><img src="http://'+this.config.htmlUrl+'/theme/order/img/p2_10_8_1.png" onclick="'+appId+'.setShoppingCar(\''+data.id+'\');'+appId+'.showShoppingCar();" title="'+EWS.Language["E01004"]["E010046"]+'"/></a>' +
					    	'</div>' +
				   '</div>' +
		       '</li>';
    };
    if(len){
    	this.config.current = this.proMoreListData[len-1].id;
    }
    return [html,imgList];
    
};




/**
 * 键标经过展示商品信息
 * @param {Object} data 商品数据
 * @param {Object} obj  组件属性
 * @return {array} imgList html
 */
EWS.Order.orders_showMoreProduct.prototype.overShowProduct = function(obj,id){
	if(!this.config.current){
		var li = $('#'+this.config.id).find('ul>li');
		li[0].style.display = 'block';
		li[1].style.display = 'none';
	}else{
		$('#p1_'+this.config.current+'_b').hide();
		$('#p1_'+this.config.current).show();
	}
	$(obj).hide();
	$('#p1_'+id+'_b').show();
	this.config.current = id;
};

EWS.Order.orders_showMoreProduct.prototype.setImgState = function(obj){
	var dom = $('#'+obj.id);
	if(obj.picSize&&(obj.picSize == 2||obj.picSize == '2')){
			var imgHW = [Number(obj.picsizeW),Number(obj.picsizeH)];
	 }else{
			var imgHW = [73,75];
	}
	var w = (imgHW[0]-dom.attr('width'))/2+'px';
	var h = (imgHW[0]-dom.attr('height'))/2+'px';
	var style = 'left:'+w+';top:'+h+';position:absolute;';
	dom.attr('style',style);
};

/**
 * 设定产品详细内容图片
 * img.id     图片ID
 * img.width  图片宽度
 * img.height 图片高度
 * img.src   图片来源
 * img.index 图片索引
 * @param {Object} img 图片对象
 */
EWS.Order.orders_showMoreProduct.prototype.setImage = function(img){
	//获得图片原始宽度与高度
	var originalImg = new Image();
	originalImg.src = img.src;
	var originalWidth = originalImg.width;
	var originalHeight = originalImg.height;
	
	//根据原始宽度与高度设置图片垂直居中所需要的偏移位置
	//先判断样式类型
	var width = 73;
	var height = 75;
	if(this.config.styleId){
//	    获取图片范围
	    if(this.config.picSize&&(this.config.picSize == 2||this.config.picSize == '2')){
			var size = [Number(this.config.picsizeW),Number(this.config.picsizeH)];
		}else{
			var size = this.returnWidthHeight();
		}
//		var size = this.returnWidthHeight();
		width = size[0];
		height = size[1];
	};
	var scale = this.getImageScale(originalWidth,originalHeight,width,height);
	$("#"+img.id).css({position:'relative',top:(height-scale[1])/2,width:scale[0],height:scale[1]});
};



/**
 * 商品展示
 * @param {Object} obj
 */
EWS.Order.orders_showCatalogProduct = function(obj){
	this.type = 'orders_showCatalogProduct';
	this.config = obj;
	var _this = this;
	
	var appId = 'Order_'+this.config.id;
	var chunnel = EWS.getCataLog();
	if(chunnel){
		var v = chunnel[1].split('#');
		if(decodeURI(v[0]) == this.config.chunnelName){
			this.config.catalogID = chunnel[0];
		}
	}
	
	
	var imgHW = this.returnWidthHeight();
	if(obj.picSize&&(obj.picSize == 2||obj.picSize == '2')){
			var imgHW = [Number(obj.picsizeW),Number(obj.picsizeH)];
	}
	this.config.size = imgHW;
	 
	var anchor = EWS.Anchor.get("Order_"+this.config.id);
	if(anchor == null){
			var pageNum = 1;
		}else{
			var pageNum = parseInt(anchor.split(",")[1]);
	};
	
	if(Number(pageNum) == 1&&!chunnel){
		var img = $('#'+this.config.id +' .pro_img');
		var len = img.length;
		for(var i=0;i<len;i++){
			this.setSmallPicSize(img[i],imgHW,'overPic');
		}
	}else{
		this.getProductByPage(pageNum);
	}
};

EWS.Order.orders_showCatalogProduct.prototype = EWS.Order.GetCatalogProductList.prototype;


/**
 * 根据页数获取数据
 */
EWS.Order.orders_showCatalogProduct.prototype.getProductByPage = function(page){
    $("#"+this.config.id).html(EWS.Language['E01002']['E010024']);
    var _this = this;
    $.ajax({
		url:"/EWS_Interface/Order_ListProduct.aspx",//考虑到适应所有域名访问，所以使用绝对路径
		type:'get',
		data:{CID:this.config.cid,ParentID:this.config.catalogID,PageItem:this.config.pageItem,PageNum:page},
		cache:false,
		dataType:'json',
		success:function(result){
			_this.createProductHtml(result,page);
		}
	});
};


/**
 * 获取显示的商品，响应操作
 * @param {Object} result
 */
EWS.Order.GetCatalogProductList.prototype.createProductHtml = function(result,page){
	    var lang = EWS.Language['E01002']; 
	    var _this = this;
	    var p = result.MoneyType;
	    var mType = p=='0'?'￥':(p=='1'?'＄':(p=='2'?'￡':'€'));
	    var product = result.Product;
        var obj = this.config;
		var pLen = product.length;
//        if(pLen == 0) return;
		var ul = $('<ul></ul>');
		var imgList = [];
		var parent = $("#"+obj.id);
//		parent.attr('chu_key',this.config.chunnel);
		parent.html('');

		for(var i=0;i<pLen;i++){
			//增加预加载图片列表
			if(obj.styleId !=7){
				var newId = obj.id+"_img_"+i;
//				var Img = product[i].Img||'http://'+this.config.htmlUrl+'/theme/order/img/noImg.png';
//				imgList.push({src:Img,id:newId});
				var imgUrl = 'http://'+_this.config.htmlUrl+'/theme/order/img/noImg.png';
				if(product[i].Img){
					imgUrl = _this.getSmallPicPath(product[i].Img);
				}
				imgList.push({src:imgUrl,id:newId});
			};
			if(obj.rowItem == 1){
				ul = $('<ul></ul>');
			}else{
				if((i+1) % obj.rowItem == 1){
					ul = $('<ul></ul>');
				};
			};
			ul.append(returnHtml(product[i],i));
			if((i+1) % obj.rowItem == 0 || (i+1) == pLen){
				parent.append(ul);
			};
		};
		
		if(pLen == 0){
			parent.append('<div class="noData">'+lang['E010022']+'</div>');
		}
		
		if(!obj.hasPage||obj.hasPage == 'true'){
			//加翻页条
			parent.append('<div class="ord_mop_page"></div>');
		}
		
		
	//判断样式类型
	 function returnHtml(data,i){
	 	 var style = "style=margin-right:"+obj.sBetween+"px";
		 if((i+1) % obj.rowItem == 0 || (i+1) == pLen){
	        style = '';
		 };
	 	 var newId = obj.id+"_img_"+i;
	 	 var appId = 'Order_'+obj.id;
	 	 if(obj.showProDetail&&Number(obj.showProDetail) == 2){//独立页显示产品信息
	 	 	var action = 'javascript:'+appId+'.showPageDetial(\''+data.ID+'\',\''+data.Name+'\',\''+obj.detailMenuId+'\');';
	 	 }else{
	 	 	var action = 'javascript:'+appId+'.showDetial(\''+data.ID+'\',\''+data.Name+'\');';
	 	 }
	 	 var setImg = 'javascript:'+appId+'.imgLoadComplete(this)';
		 switch(obj.styleId){
			 case '1':
				 return '<li '+style+'>' +
							'<div class="title"><a href="'+action+'" title="">'+data.Name+'</a></div>' +
							'<div class="one_img"><a href="'+action+'" title=""><img  onload="'+setImg+'" title="'+data.Name+'" src="'+imgUrl+'"  style="position: relative;top: 8px;"  id="'+newId+'"/></a></div>' +
							'<div class="content">' +
								'<div class="number1"><div class="number2"><strong>'+data.Sn+'</strong></div></div>' +
								'<div class="price1"><div class="price2"><strong>'+mType+' '+data.UnitPrice+'</strong></div></div>' +
							'</div>'+
						'</li>';
				 break;
			 case '2':
				 return '<li '+style+'>' +
							'<div class="content">' +
								'<div class="price"><strong>'+mType +data.UnitPrice+'</strong></div>' +
								'<a  href="'+action+'" title=""><img  onload="'+setImg+'" title="'+data.Name+'"  src="'+imgUrl+'"  id="'+newId+'"/></a>' +
							'</div>' +
							'<div class="title">' +
								'<a href="'+action+'" title="">'+data.Name+'</a>' +
								'<span>'+data.Sn+'</span>' +
								'</div>'+
						'</li '+style+'>';
				 break;
			 case '3':
				 return '<li '+style+'>' +
							'<div class="content"><a  href="'+action+'" title=""><img  onload="'+setImg+'" title="'+data.Name+'" src="'+imgUrl+'"   id="'+newId+'"/></a></div>'+
						'</li>';
				 break;
			 case '4':
				 return '<li '+style+'>' +
							'<div class="content">' +
								'<div class="title">' +
									'<a href="'+action+'" title="">'+data.Name+'</a>' +
									'<div class="price"><span>'+mType +data.UnitPrice+'</span></div>' +
									'<div class="buy"><a href="javascript:void(0)" title="'+lang['E010025']+'" onclick="'+appId+'.setShoppingCar(\''+data.ID+'\');'+appId+'.showShoppingCar();"><img src="http://'+_this.config.htmlUrl+'/theme/order/img/buy.png" >'+lang['E010026']+'</a></div>' +
								'</div>' +
								'<div class="photo">' +
									'<a href="'+action+'" title="">' +
										'<img title="'+data.Name+'" src="'+imgUrl+'"  onload="'+setImg+'"  style="position: relative; top: 0.5px;" id="'+newId+'"/>' +
										'</a>' +
								'</div>' +
							'</div>'+
						'</li>';
				 break;
			case '5':
				 return '<li '+style+'>' +
							'<div class="content">' +
								'<div class="photo">' +
									'<a  href="'+action+'" title=""><img  onload="'+setImg+'"  src="'+imgUrl+'"  title="'+data.Name+'" style="position: relative; top: 1px;" id="'+newId+'"/></a>' +
									'<a class="price" href="'+action+'"><strong>'+mType +data.UnitPrice+'</strong></a>' +
								'</div>' +
								'<div class="title">' +
									'<a href="'+action+'" title="">'+data.Name+'</a>' +
									'<span>'+data.Sn+'</span>' +
								'</div>' +
							'</div>' +
						'</li>';
				 break;
			case '6':
				 return '<li '+style+'>' +
							'<div class="content">' +
								'<div class="price"><strong>'+mType +data.UnitPrice+'</strong>' +
								'<div class="title">' +
									'<a href="'+action+'" title="">'+data.Name+'</a>' +
									'<span>'+data.Sn+'</span>' +
								'</div>' +
							'</div>' +
							'<div class="photo"><a  href="'+action+'" title=""><img title="'+data.Name+'"  onload="'+setImg+'"  src="'+imgUrl+'"  style="position: relative; top: 5px;" id="'+newId+'"/></a></div>' +
							'</div>	'+
						'</li>';
				 break;
			case '7':
				 return '<li '+style+'>' +
							'<div class="price">' +
								'<div class="title">' +
									'<a href="'+action+'" title="">'+data.Name+'</a>' +
									'<span>'+lang['E010023']+'：'+data.Sn+'</span><strong>'+mType +data.UnitPrice+'</strong>' +
								'</div>' +
							'</div>'+
						'</li>';
				 break;
			case '8':
				 return '<li '+style+'>' +
				 			'<div class="size">' +
					   			'<a href="'+action+'"><img title="'+data.Name+'"  onload="'+setImg+'"  src="'+imgUrl+'"  style="position: relative; top: 0.25px;" title="'+data.Name+'"  id="'+newId+'"/></a>' +
					   		'</div>' +
		   				    '<div class="content">' +
		   				  	    '<span>'+mType +data.UnitPrice+'</span>' +
		   				  	    '<button class="buy" title="'+lang['E010026']+'"  onclick="'+appId+'.setShoppingCar(\''+data.ID+'\');'+appId+'.showShoppingCar();">'+lang['E010026']+'</button>' +
		   				  	    '<a class="detail" title="'+lang['E010029']+'" href="'+action+'">'+lang['E010029']+'</a>' +
		   				    '</div>' +
			   				'<div class="title">' +
			   				  	'<strong><a href="'+action+'">'+data.Name+'</a></strong>' +
			   				'</div>'+
						'</li>';
				 break;
		};
	 };

	if(!obj.hasPage||obj.hasPage == 'true'){
		this.setNavigation(page ,Math.ceil(parseInt(result.totalCount)/obj.pageItem) || 0,obj.id,'last');//设定分页导航
	}
};

/**
 * 设定产品详细内容图片
 * img.id     图片ID
 * img.width  图片宽度
 * img.height 图片高度
 * img.src   图片来源
 * img.index 图片索引
 * @param {Object} img 图片对象
 */
EWS.Order.orders_showCatalogProduct.prototype.setImage1 = function(img){

	//获得图片原始宽度与高度
	var originalImg = new Image();
	originalImg.src = img.src;
	var originalWidth = originalImg.width;
	var originalHeight = originalImg.height;
	
	//根据原始宽度与高度设置图片垂直居中所需要的偏移位置
	//先判断样式类型
	var width = 185;
	var height = 162;
	if(this.config.styleId){
		var size = this.returnWidthHeight();
		width = size[0];
		height = size[1];
	};
	var scale = this.getImageScale(originalWidth,originalHeight,width,height);
	$("#"+img.id).css({position:'relative',top:(height-scale[1])/2});
};


/**
 * 列表展示
 * @param {Object} obj
 */
EWS.Order.orders_showCatalogs = function(obj){
	this.type = 'orders_showCatalogs';
	this.config = obj;
	
	var _this = this;
	
	var appId = 'Order_'+this.config.id;
	
	
//	$.ajax({
//		url:"/EWS_Interface/Order_ListCatalog.aspx",//考虑到适应所有域名访问，所以使用绝对路径
//		type:'get',
//		data:{CID:this.config.cid,ParentID:this.config.catalogID},
//		cache:false,
//		dataType:'json',
//		success:function(result){
//			_this.createCatalogListHtml(result)
//		}
//	});
};

EWS.Order.orders_showCatalogs.prototype = EWS.Order.GetCatalogProductList.prototype;

/**
 * 商品分类列表(样式一)
 * @param {Object} data
 * @param {Object} obj
 */
EWS.Order.orders_showCatalogs.prototype.createCatalogListHtml = function(result){
	var data = result.Catalog;
	var appId = 'Order_'+this.config.id;
	var len = data.length;
	var dom = $('#'+this.config.id);
	dom.html(EWS.Language['E01001']['E010012']);
	if(this.config.cataNum == '2'){
		len = this.config.cataNumValue?(this.config.cataNumValue>len?len:this.config.cataNumValue):len;
	}
	var action = 'javascript:'+appId+'.showProductLists();';
 	var html = '';
 	switch(this.config.styleId){
 		case '1' :
 		    var cls = len==0?'li_title li_first':'li_title';
	    	if(result.Path[0].Number == ''){
		    	var nL = '';
		    }else{
		    	var nL = '( '+result.Path[0].Number+' )';
		    }
 		    html = '<ul><li class="'+cls+'"><a href="javascript:void(0)" onclick="'+appId+'.setState(this,1);"><strong>'+(this.config.catalogID == "0"?EWS.Language['E01001']['E010011']:this.config.catalogName)+nL+'</strong></a><ul>';
		    for(var i=0;i<len;i++){
				if(i==len-1)
				    html +='<li class="li_last"><a href="javascript:'+appId+'.showProductLists(\''+data[i].ID+'\')">'+data[i].Name+'( '+data[i].Number+' )</a></li>';
				else
					html +='<li><a href="javascript:'+appId+'.showProductLists(\''+data[i].ID+'\')">'+data[i].Name+'( '+data[i].Number+' )</a></li>';
			};
			html +='</ul></li></ul>';
			break;
		case '2' :				
			html = '<ul><li class="li_title"><a href="javascript:'+appId+'.showProductLists(\''+this.config.catalogID+'\')"><strong>'+(this.config.catalogID == "0"?EWS.Language['E01001']['E010011']:this.config.catalogName)+'</strong></a><a href="javascript:void(0)" onclick="'+appId+'.setState(this,2);" class="iconUl" title="'+EWS.Language['E01001']['E010013']+'">'+EWS.Language['E01001']['E010013']+'</a><ul>';
			for(var i=0;i<len;i++){
				if(i==len-1)
				    html +='<li class="li_last"><a href="javascript:'+appId+'.showProductLists(\''+data[i].ID+'\')">'+data[i].Name+'</a></li>';
				else
					html +='<li><a href="javascript:'+appId+'.showProductLists(\''+data[i].ID+'\')">'+data[i].Name+'</a></li>';
			};
			html +='</ul></li></ul>';
			break;
		case '3' :
			if(this.config.hasTitle&&this.config.hasTitle == 'true'){
				html = '<div class="ord_sortList3_title"><a href="javascript:'+appId+'.showProductLists(\''+this.config.catalogID+'\')">'+this.config.catalogName+'</a></div>';
			}
			for(var i=0;i<len;i++){
				html +='|<a href="javascript:'+appId+'.showProductLists(\''+data[i].ID+'\')">'+data[i].Name+'</a>';
			};	
			break;
		case '4' :	
			if(this.config.hasTitle&&this.config.hasTitle == 'true'){
				html = '<div class="ord_sortList4_title"><a href="javascript:'+appId+'.showProductLists(\''+this.config.catalogID+'\')">'+this.config.catalogName+'</a></div>';
			}
			for(var i=0;i<len;i++){
				html +='<a href="javascript:'+appId+'.showProductLists(\''+data[i].ID+'\')">'+data[i].Name+'</a>';
			};			
			break;
 	}
	$('#'+this.config.id).html(html);
};

EWS.Order.orders_showCatalogs.prototype.setState = function(obj,p){
	var cls = obj.parentNode.className;
	if(cls.split(' ').length>1){
		obj.parentNode.className = 'li_title';
	}else{
		obj.parentNode.className = 'li_title hide';
	};
};

EWS.Order.orders_showCatalogs.prototype.showProductLists = function(id){
	if(this.config.chunnel == '1'){//本页
		if(this.config.proComId){
			var obj = eval('Order_'+this.config.proComId);
			if(obj.config){
				obj.config.catalogID = id;
				obj.getProductByPage(1);
			}
		}
	}else{
		if(this.config.linkId){
//			if(this.config.jump == 1){//在当前窗口打开连接
//				window.location.href = this.config.linkId+'.shtml';
//			}else{//新窗口打开
				window.open(this.config.linkId+'.shtml?catName='+id+','+this.config.chunnelName);
//			}
		}
	};
};


/**
 * 商品分类列表(样式二)
 * @param {boolen} p  //true 小图 undefind 大图
 * @return {Array} 
 */
EWS.Order.GetCatalogProductList.prototype.returnWidthHeight = function(p){
	
	var width = '';
	var height = '';
	var sId = this.config.styleId;
	sId = sId?Number(sId):1;
 	switch(this.type){
 		case 'GetCatalogProductList' :
 		    if(typeof(p) == 'string'){
 		    	return [406,269];
 		    }else if(typeof(p) == 'boolean'){
 		    	return [55,56];
 		    }else{
	 		    switch(sId){
					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(sId){
			 		    	case 1 :
			 		    		return [354,216];
			 		        case 2 :
			 		        	return [406,269];
			 		        case 3 :
			 		        	return [370,269];
			 		    };
			};
 		    switch(sId){
 		    	case 1 :
 		    		return p?[89,84]:[354,216];
 		        case 2 :
 		        	return p?[55,56]:[406,269];
 		        case 3 :
 		        	return p?[49,40]:[370,269];
 		    };
 			break;
 		
 		case 'orders_showCatalogProduct' :
		    if(p == 'bigImg'){
		    	return [406,269];
		    }else if(p == true){
		    	return [55,56];
		    };
 		    switch(sId){
				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 'orders_showMoreProduct' :
		    if(p == 'bigImg'){
		    	return [406,269];
		    }else if(p == true){
		    	return [55,56];
		    };
			switch(sId){ 
				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 'SearchOrder' :
		case 'orders_productSearch':
		case 'orders_productOrdersSearch':
		case 'orders_fullearch':
		    if(p == 'bigImg'){
		    	return [406,269];
		    }else if(p == true){
		    	return [55,56];
		    };
		    break;
 	};
};

/**
 * 判断是否为本站资源
 */
EWS.Order.GetCatalogProductList.prototype.IsInterResource = function(url){
	if(url){
		if(url.indexOf('khews.local')>0||url.indexOf('khews.com')>0){
			return true;
		}
	}
	return false;
};

/**
 * 取得图片的缩略图
 * url : 图片地址
 */
EWS.Order.GetCatalogProductList.prototype.getSmallPicPath = function(url){
	return url;
	if(!this.IsInterResource(url)){
		return url;
	}else{
		var arr = url.split('/');
		var name = arr[arr.length -1];
		var _url = arr[arr.length -1].split('.');
		return url.replace(name,(_url[0]+'_s.'+_url[1]));
	}
};


/**
 * 设置缩略图大小及居中
 * img {Object} 
 * img.src : 图片地址
 * img.id  : 图片id
 */
EWS.Order.GetCatalogProductList.prototype.setSmallPicSize = function(img,size,overPic){
	var flag = this.IsInterResource(img.src);
	if(flag){
		var url = img.src;
		var arr = url.split('/');
		var name = arr[arr.length -1];
		var _url = arr[arr.length -1].split('.');
		var trueName = _url[0].replace('_s','')+'.'+_url[1];
		var lastName = url.replace(name,trueName);
		img.src = lastName;
	}
	var oimg = new Image();
	oimg.src = img.src;
	if(oimg.width){
		var scale = this.getImageScale(oimg.width,oimg.height,size[0],size[1]);
		$('#'+img.id).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);
	}
};

/**
 * 等比例显示浮动图片
 * img {Object} 
 * img.src : 图片地址
 * img.id  : 浮动层的ID
 */
EWS.Order.GetCatalogProductList.prototype.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.id+"_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);
	}
};

/**
 * 图片加载成功后等比例缩放
 * img{dom Object} 
 */
EWS.Order.GetCatalogProductList.prototype.imgLoadComplete = function(obj){
	var config = this.config;	
	var w = obj.width;
	var h = obj.height;
	if(w == 0){
		var oimg = new Image();
		oimg.src = obj.src;
		w = oimg.width;
		h = oimg.height;
	}
	var scale = this.getImageScale(w,h,config.size[0],config.size[1]);
	$(obj).css({position:'relative',top:(config.size[1]-scale[1])/2,width:scale[0],height:scale[1]});
	var img = {id:obj.id,src:obj.src,width:w,height:h};
	this.setImageLayer(img);
};



