
///--------------------------------------------------------------------------------------------------评论处理开始
var cddoc=new ActiveXObject("Microsoft.XMLDOM");
cddoc.async=true;
cddoc.onreadystatechange=LoadedComment;
function LoadedComment()
{
	var txt="";
	if(cddoc.readyState==4)
	{		
		if(cddoc.parseError.errorCode != 0) 
		{
			txt="暂无评论！";
		}else{
			var ProductID="";
			var Buy_Type="";
			var IndexPage=1;
			var PageSize=10;
			var RecordCount=0;
			var bi=cddoc.documentElement.selectNodes("BaseInfo");			
			if(bi!=null&&bi.length>0)
			{
				ProductID=bi[0].childNodes[0].text.trim();
				Buy_Type=bi[0].childNodes[1].text.trim();
				IndexPage=parseInt(bi[0].childNodes[2].text.trim());
				PageSite=parseInt(bi[0].childNodes[3].text.trim());
				RecordCount=parseInt(bi[0].childNodes[4].text.trim());
			}
			var bi=cddoc.documentElement.selectNodes("item");
			if(bi!=null&&bi.length>0)
			{				
				for(var i=0;i<bi.length;i++)
				{	
					var cr=new Comment_Row();
					cr.setValue(bi[i]);
					
					var CommentLevel="<img src='/Images/Img1/CommentLevel_"+cr.CommentLevel+".gif' broder='0'>";
					if(cr.CommentLevel=="1")
					{
						CommentLevel+="差评";
					}else if(cr.CommentLevel=="2")
					{
						CommentLevel+="中评";
					}else if(cr.CommentLevel=="3")
					{
						CommentLevel+="好评";
					}
					
					
					txt+="<table width='100%' height='40' border='0' cellpadding='0' cellspacing='2'>";
					txt+="<tr> ";
					txt+="<td width='443' height='22' valign='middle'><strong>主题：</strong><font color='#FF6600'>"+cr.Title+"</font>("+CommentLevel+")</td>";
					txt+="<td width='145' valign='middle'>作者：<font color='#FF6600'>"+cr.Editor+"</font></td>";
					txt+="<td width='154' align='right' valign='middle'><font color='#666666'>"+cr.Pubdate+"</font></td>";
					txt+="</tr>";
					txt+="<tr> ";
					txt+="<td height='21' colspan='3' valign='top'>"+cr.Description+"</td>";
					txt+="</tr>";
					if(cr.EditorreText.length>1)
					{
						txt+="<tr> ";
						txt+="<td height='21' colspan='3' valign='top'><strong>商家回复：</strong>"+cr.EditorreText+" &nbsp;("+cr.EditorReDate+")</td>";
						txt+="</tr>";
					}
					txt+="</table>";
					txt+="<table width='100%' height='1' border='0' cellpadding='0' cellspacing='0'><tr><td background='/images/Img1/line_dot2.gif'></td></tr></table>";
				}
				txt+=CommentPage(ProductID,Buy_Type,IndexPage,PageSize,RecordCount);
			}else{
				txt="暂无评论！";
			}			
			//span_Comment_Count.innerHTML=""+RecordCount;
		}
	}else{
		txt="暂无评论！";
	}	
	Comment_Text_List.innerHTML=txt;
}
function Comment_LoadPage(path)
{
	cddoc.load(path);	
}

function Comment_Row()
{
	this.Title="";
	this.Editor="";
	this.Description="";
	this.Pubdate="";
	this.CommentLevel="";
	this.EditorreText="";
	this.EditorReDate="";
	this.setValue=function(bitiem)
	{
		try
		{
			this.Title=bitiem.childNodes[0].text.trim();
			this.Editor=bitiem.childNodes[1].text.trim();
			this.Description=bitiem.childNodes[2].text.trim();
			this.Pubdate=bitiem.childNodes[3].text.trim();
			this.CommentLevel=bitiem.childNodes[4].text.trim();
			this.EditorreText=bitiem.childNodes[5].text.trim();
			this.EditorReDate=bitiem.childNodes[6].text.trim();	
		}
		catch(e){}	
	}
}



function CommentPage(ProductID,Buy_Type,IndexPage,PageSize,RecordCount)
{
	var xmlfile="/CN/Product/Product_Comment_Xml.aspx?Buy_Type="+Buy_Type+"&ProductID="+ProductID+"&PageSize="+PageSize+"&RecordCount="+RecordCount
	var PageListTxt="";	
	var PageCount=parseInt(RecordCount/PageSize);	
	if(RecordCount%PageSize>0)PageCount++;
	var pageskip=10;
	var Bpage=1;
	var Epage=1;
	if(PageCount>=pageskip&&IndexPage>6)
	{
		Bpage=IndexPage-5;
		if(PageCount>=pageskip&&Bpage>PageCount-(pageskip-1))Bpage=PageCount-(pageskip-1);
	}
	Epage=Bpage+(pageskip-1);
	if(Epage>PageCount)Epage=PageCount;
	
	if(PageCount>1)
	{		
		PageListTxt="<table border='0' cellpadding='0' style='border-collapse: collapse' width='100%' height='20'>";
		PageListTxt+="<tr>";
		PageListTxt+="<td align='right'>";
		PageListTxt+="共<b>"+RecordCount+"</b>条记录&nbsp;每页:<b>"+PageSize+"</b>条&nbsp;共<b>"+PageCount+"</b>页&nbsp;页次:<b>"+IndexPage+"</b>/<b>"+PageCount+"</b>&nbsp;&nbsp;&nbsp;&nbsp;分页:";
		if(IndexPage>1)
		{
			PageListTxt+="<a href='javascript:Comment_LoadPage(\""+xmlfile+"&Page=1\");' title=第一页><FONT face=webdings>9</FONT></a>";
			PageListTxt+="<a href='javascript:Comment_LoadPage(\""+xmlfile+"&Page="+(IndexPage-1)+"\");' title=上一页><FONT face=webdings>7</FONT></a>";
		}

		for(var i=Bpage;i<=Epage;i++)
		{
			if(i==IndexPage)
				PageListTxt+=" <b><font color='red'>"+i+"</font></b> ";	   		
			else
				PageListTxt+=" <a href='javascript:Comment_LoadPage(\""+xmlfile+"&Page="+i+"\");' title=第"+i+"页>"+i+"</a> ";
		}

		if(IndexPage<PageCount)
		{
			PageListTxt+="<a href='javascript:Comment_LoadPage(\""+xmlfile+"&Page="+(IndexPage+1)+"\");' title=下一页><FONT face=webdings>8</FONT></a>";
			PageListTxt+="<a href='javascript:Comment_LoadPage(\""+xmlfile+"&Page="+PageCount+"\");' title=最后一页><FONT face=webdings>:</FONT></a>";
		}
		
		PageListTxt+="&nbsp;</td>";		
		PageListTxt+="</tr></table>";
	}
	return PageListTxt;
}

function LoadCommandDoc(Buy_Type,ProductID)
{
	var Url="/CN/Product/Product_Comment_Xml.aspx?ProductID="+ProductID+"&Buy_Type="+Buy_Type+"";
	cddoc.load(Url);//加载评论信息
}
///--------------------------------------------------------------------------------------------------评论处理结束