//放入cookies中的历史浏览记录/今日查看看
function readHistoryCookies(id){
var showdiv = $('#'+id);
showdiv.html("<img src='/images/zoomloader.gif' width=32px height=32px>信息加载中...");
showdiv.show(100);
 $.getJSON("/ms/cart?method=readHistoryCookies&callback=?",function(date){
   	  var html = "";
   		html +="		<table border=\"0\" cellpadding=\"0\" >";
   		html +="		<table border=\"0\" cellpadding=\"0\" >";
   		if(date.length ==0){
   		html +="		<tr>";
		html +="		<td align=\"center\"><a href=\"/ms/plist?action=init\"> 未查看过</a>";
		html +="		</td>";
		html +="		</tr>";
   		}else{
		$.each(date,function(i,item){		
			html +="		<tr>";
			html +="		<td align=\"center\">";
			html +="		<a href=\"/ms/details?action=goods&id="+item.id+"\" target=\"_blank\" title=\""+item.goodsNo+"\" ><img  border=\"0\" src=\""+item.showpic+"\" alt=\""+item.goodsNo+"\" width=\"65\" height=\"65\" /></a>";
			html +="		</td>";
			html +="		</tr>";
			html +="		<tr><td align=\"center\"><a href=\"/ms/details?action=goods&id="+item.id+"\" target=\"_blank\" title=\""+item.goodsName+"\" class=\"cart\">"+item.goodsName+"</a>";
			html +="		</td>";
			html +="		</tr>";
		 })		
		}		
		html +="		<tr>";
		html +="		<td align=\"center\"><a href=\"/ms/plist?action=init\">更多</a>";
		html +="		</td>";
		html +="		</tr>";
		html +="		</table>";
		showdiv.html("");
		showdiv.html(html);
   })
}
//读取购物车
function readMyshopcart(id){
var showdiv = $('#'+id);
showdiv.html("<img src='/images/zoomloader.gif' width=32px height=32px>信息加载中...");
showdiv.show(100);
 $.getJSON("/ms/cart?method=readMyshopcart&callback=?",function(date){
    var html = "";
   		html +="		<table border=\"0\" cellpadding=\"0\" >";
   		if(date.length ==0){
   		html +="		<tr>";
		html +="		<td align=\"center\"><a href=\"/ms/plist?action=init\">购买</a>/<a href=\"login.jsp\">登入</a>";
		html +="		</td>";
		html +="		</tr>";
   		}
		$.each(date,function(i,item){		
			html +="		<tr>";
			html +="		<td align=\"center\">";
			html +="		<a href=\"/ms/details?action=goods&id="+item.id+"\" target=\"_blank\" title=\""+item.goodsNo+"\" ><img  border=\"0\" src=\""+item.showpic+"\" alt=\""+item.goodsNo+"\" width=\"65\" height=\"65\" /></a>";
			html +="		</td>";
			html +="		</tr>";
			html +="		<tr><td align=\"center\"><a href=\"/ms/details?action=goods&id="+item.id+"\" target=\"_blank\" title=\""+item.goodsName+"\" class=\"cart\">"+item.goodsName+"</a>";
			html +="		</td>";
			html +="		</tr>";
		 })		
				
		html +="		<tr>";
		html +="		<td align=\"center\"><a href=\"/ms/shoppingcart?method=init\">购物车</a>";
		html +="		</td>";
		html +="		</tr>";
				
		html +="		</table>";
 		showdiv.html("");
		showdiv.html(html);
 })
}
//今日热卖
function readHot(id){
var showdiv = $('#'+id);
showdiv.html("<img src='/images/zoomloader.gif' width=32px height=32px>信息加载中...");
showdiv.show(100);
 $.getJSON("/ms/cart?method=readHot&callback=?",function(date){
 		var html = "";
   		html +="		<table border=\"0\" cellpadding=\"0\" >";
   		
   		if(date.length ==0){
   		html +="		<tr>";
		html +="		<td align=\"center\"><a href=\"/ms/plist?action=init\"> 无商品</a>";
		html +="		</td>";
		html +="		</tr>";
   		}
		$.each(date,function(i,item){		
			html +="		<tr>";
			html +="		<td align=\"center\">";
			html +="		<a href=\"/ms/details?action=goods&id="+item.id+"\" target=\"_blank\" title=\""+item.goodsNo+"\" ><img  border=\"0\" src=\""+item.showpic+"\" alt=\""+item.goodsNo+"\" width=\"65\" height=\"65\" /></a>";
			html +="		</td>";
			html +="		</tr>";
			html +="		<tr><td align=\"center\"><a href=\"/ms/details?action=goods&id="+item.id+"\" target=\"_blank\" title=\""+item.goodsName+"\" class=\"cart\">"+item.goodsName+"</a>";
			html +="		</td>";
			html +="		</tr>";
		 })		
		html +="		<tr>";
		html +="		<td align=\"center\"><a href=\"/ms/plist?action=init\">更多</a>";
		html +="		</td>";
		html +="		</tr>";
				
		html +="		</table>";
		showdiv.html("");
		showdiv.html(html);
 })
}
function show_hide_cart_div(id){
var div1 = $('#div1');
var div2 = $('#div2');
var div3 = $('#div3');
var div4 = $('#div4');
var showdiv = $('#'+id);
if(div1.css("display")!="none"){
 div1.slideUp(100);
}
if(div2.css("display")!="none"){
div2.slideUp(100);
}
if(div3.css("display")!="none"){
div3.slideUp(100);
}
if(div4.css("display")!="none"){
div4.slideUp(100);
}
if(id == "div1"){
if(showdiv.css("display")=="none"){
	showdiv.show(100);
}else{
	showdiv.hide(100);
}

}
if(id == "div2"){
if(showdiv.css("display")=="none"){
	readMyshopcart(id);
}else{
	showdiv.hide(100);
}


}
if(id == "div3"){
if(showdiv.css("display")=="none"){
	readHistoryCookies(id);
}else{
	showdiv.hide(100);
}

}
if(id == "div4"){
if(showdiv.css("display")=="none"){
	readHot(id);
}else{
	showdiv.hide(100);
}

}


}