// add count for ajax response
var product_count_response = 0;

function productshow(typeid,criteriaid,lang,path,pageno,loadpage){

if (product_count_response == 0) {
    product_count_response++;
    
//pagesize 全局?量
var getpagesize=pagesize;
pagesize=12;
$.ajax({
				url:"/"+lang+"/service/service.html?ws=product",
				data:{typeCode:typeid,criteriaid:criteriaid,pageno:pageno,segment:prdsegmentid,criteria:prdsubsegmentid,pagesize:getpagesize},
				type: "get",
				dataType:"json",
                cache :false,
                success: function(data) {			
				//$("#ProductList").empty();alert("ok");
				if(getpagesize>12)
					$("#ShowAllButton").hide();
				else
					$("#ShowAllButton").show();
				var pagecount=data.pageitem.RequestHeader.pagecount;
				if(loadpage=='true')
				{	page(pageno, pagecount,pageno,'false');}
				var length=data.pageitem.ItemMaster.length;
				var flength=data.filters.filter.length;
				for(var i=0;i<flength;i++)
				{
					var fid=data.filters.filter[i].int_id;
					var clength=data.filters.filter[i].criterias.criteria.length;
					for(var j=0;j<clength;j++)
					{
						var cchoose=data.filters.filter[i].criterias.criteria[j].canchoose;
						var cid=data.filters.filter[i].criterias.criteria[j].int_id;
						if(cchoose!='true')
						{
							$("#fliter").find("ul."+fid).find("li."+cid).removeClass("active").addClass("disabled");
						}
						else
						{
							$("#fliter").find("ul."+fid).find("li."+cid).removeClass("disabled");
						}
					}
				}
				if(length==0)//noProductMsg全局?量
				{	$("#ProductList").html(noProductMsg);return;}
				
				var producthtml="<ul  class='productItemList clearfix'>";
				for(var i=0;i<length;i++)
				{
					var id=data.pageitem.ItemMaster[i].int_id;
					var name=data.pageitem.ItemMaster[i].str_name;
					var img=data.pageitem.ItemMaster[i].str_image;
					if(img=='')
					{
						img=absentimgpath;
					}
					var price=data.pageitem.ItemMaster[i].int_price;
					var isnew=data.pageitem.ItemMaster[i].str_icon;
					var desp=data.pageitem.ItemMaster[i].str_desp;
					var category=data.pageitem.ItemMaster[i].str_category;
					var productpath=path+typeid;
					producthtml+="<li>";
					if(isnew=='')
					{
						producthtml+="<a href='"+productpath+"/detail.html?productid="+id+"'><img src='"+img+"' alt='"+name+"' width='200'/></a>";
					}
					else
					{
		
						producthtml+="<ul class='itemBadges'><li><img src='"+isnew+"'/></li></ul><a href='"+productpath+"/detail.html?productid="+id+"'><img src='"+img+"' width='200' alt='"+name+"'/></a>";
					}
					producthtml+="<div class='itemDetails'><h3><a href='"+productpath+"/detail.html?productid="+id+"'>"+name+"</a></h3>"+desp+"</div>";
					producthtml+="</li>";
					var thisindex=i+1;
					if(thisindex % 4==0 && thisindex<length)
					{
						//alert("K"+i+":"+length);
						producthtml+="</ul><ul class='productItemList clearfix'>";
					}	
				}
				producthtml+="</ul>";				
				
				$("#ProductList").html(producthtml);
				

				product_count_response = 0;
               },
                error: function(data, textStatus) { alert(data.responseText); alert('AJAX ERROR: ' + textStatus); product_count_response = 0;}
                
            });
			
    }
}
