
// 点击商品分类链接到商品列表页
$(function() {

			$(".myItemType").click(function() {

				var myParentId = $(this).siblings(".itemTypePid").html();
				var myParentContent = $("#parentItemType" + myParentId).html();
				var myId = $(this).next(".itemTypeId").html();
				var myContent = $(this).html();
				myContent = myContent.replace(/&amp;/ig,"&");
				myParentContent = myParentContent.replace(/&amp;/ig,"&");
				if(myParentContent.indexOf("<img") >-1 || myParentContent.indexOf("<IMG") >-1 )
				{
					myParentContent=$(myParentContent).attr("alt");
				}
				
				
				if(myContent.indexOf("<img") >-1 || myContent.indexOf("<IMG") >-1)
				{
					myContent=$(this).attr("title");
					
				}

				
				//alert("myContent="+myContent);
				var content = myParentId + ":" + encodeURIComponent(myParentContent,"utf-8") + ";" + myId
						+ ":" + encodeURIComponent(myContent,"utf-8");
				var href = $(this).attr("href");
				
				
				$(this).attr("href", href + "&itypeNames=" + content);

			});

			$(".myItemTypeParent").click(function() {

						var myId = $(this).siblings(".itemTypeId").html();
						var myContent = $(this).html();
						//alert("before myItemTypeParent content="+myContent.replace(/&amp;/ig,"%26"));
						myContent = myContent.replace(/&amp;/ig,"&");
						if(myContent.indexOf("<img") >-1 || myContent.indexOf("<IMG") >-1)
						{
							myContent=$(this).attr("title");
							
						}
						
						var content = myId + ":" + encodeURIComponent(myContent,"utf-8");
						var href = $(this).attr("href");
						//alert("myItemTypeParent content="+content);
						$(this).attr("href", href + "&itypeNames=" + content);
						
					});
});

			// 加入到cookie
	$(".itemPhoto").click(function(){ 	
		var itemId = $(this).attr("id");
		var url = $(this).children().attr("src");
		url = url.replace("100x100","45x45");
		var sellingPrice;
		if($(this).parent("div").next().next().find("li span").size()>1)
			sellingPrice = $(this).parent("div").next().next().find("li span:eq(1)").attr("usdcurrency");
		else
			sellingPrice = $(this).parent("div").next().next().find("li span").attr("usdcurrency");
		var item = itemId+"-www.ctoshop.com-"+url+"-www.ctoshop.com-"+sellingPrice+"@www.ctoshop.com@";
		var before = $.cookie(sellerId+"item");
		if(!isExist(itemId,before)){		
			item = before+item;		
			var itemArray = item.split("@www.ctoshop.com@");
			var len = itemArray.length;
			if(len<8){
				$.cookie(sellerId+"item", item, { expires: 1,path: '/' });
			}
		}
	});
	
	function isExist(id,before){
		if(before!=null){	
			if(before.indexOf(id+"-www.ctoshop.com-")>-1){
				return true;
			}else{
				return false;
			}
		}		
	}