﻿function pageselectCallback(page_id, jq) {
   productReview(page_id+1);
}
function productReview(PageIndex) {
            var pagesize = 5;
            var totalrecord=0;
         $.ajax({ type: "GET", url: '/Ajax/Ajax_ProductInfo.aspx?Action=2&ProductId='+productId+'&PageIndex=' + PageIndex + '&PageSize=' + pagesize + '', success: function(xml) {
             var ProductReviewList = $(xml).find('ProductReviewList');
             var totalrecord = ProductReviewList.attr('totalrecord');
             //总记录条数
             $('#spReview').text(totalrecord);
             var totalpage = ProductReviewList.attr('totalpage');
             var current = ProductReviewList.attr('pageindex');
//             $('.countReviews strong').html(totalrecord);
//             $('#reviewTop').html(' ');
//			 var ReviewHtml='';
//			 $(xml).find('CustName').each(function(){
//			   var CustName=$(this).text();
//			   ReviewHtml+="<a href=\"#\">"+CustName+"</a>";
//			 });
//			 $('#reviewTop').append(ReviewHtml); 
			 ReviewHtml='';
			 $('#pinglunContent').html(' ');
             $(xml).find('ProductReview').each(function() {
                 var ReviewId=$(this).find('ReviewId').text();
                 var ReviewBy = $(this).find('ReviewBy').text();
                 var ReviewContent = $(this).find('ReviewContent').text();
                 var ReviewDate = $(this).find('ReviewDate').text();
                 var Reply=$(this).find('Reply').text();
                 
                 /*
                 <h6>CAT_IS_SLEEPING <span>2010-04-28</span></h6>
				<p>我想要个大包，不过担心太大会不好看，因为我只有</p>
				<p class="huifu"><strong>客服回复：</strong>感谢您的关组</p>
                 */
                if(ReviewBy=="")
                    ReviewBy="匿名";
				ReviewHtml+="<h6>"+ReviewBy+"<span>"+ReviewDate+"</span></h6>";
				ReviewHtml+="<p>"+ReviewContent+"</p>";
				if(Reply!=""){
				    ReviewHtml+="<p class=\"huifu\"><strong>客服回复："+Reply+"</strong></p>";
				}
                
			 })
			 $('#pinglunContent').append(ReviewHtml);
			// $('.ReviewsList').append(ReviewHtml);
             $("#page1").pagination(totalrecord, {
                 callback: pageselectCallback,
                 prev_text: '上一页',
                 next_text: '下一页',
                 items_per_page: pagesize,
                 num_display_entries: 6,
                 current_page: PageIndex - 1,
                 num_edge_entries: 1
             });
//             scroller3 = new jsScroller(document.getElementById("scrollleft2"), 880, 270);
//             scrollbar3 = new jsScrollbar(document.getElementById("Scrollbar-Container2"), scroller3, false);
            
         }
     })
}
productReview(1);