  function createXMLHttpRequest() {
		var xmlHttp;
		try
		   {
		     // try to create XMLHttpRequest object
		     xmlHttp = new XMLHttpRequest();
		
		   }
		   catch(e)
		   {
		   var prefixes = ["MSXML2.XmlHttp","Microsoft.XmlHttp","MSXML3.XmlHttp", "MSXML.XmlHttp"];
		     // assume IE6 or older
		   	for (var i = 0; i < prefixes.length; i++) {
				try{xmlHttp = new ActiveXObject(prefixes[i]);}catch(ex){};
			}
		       
		   }
		   // return the created object or display an error message
		   if (!xmlHttp)
		     alert("Error creating the XMLHttpRequest object.");
		   else
		     return xmlHttp;
    }
	function addComment(pid){
		var subject=$F('subject');
		var memo=$F('memo');
	var islogin=$F('user');
	if(islogin=='noUser'){
		var name=$F('loginId');
		var password=$F('password');
		var vc=$F('vc');
		
		if(vc==null||vc==''){
			alert('验证码不能为空');
			$('vc').focus();
			return;
		}
	}		
		
	if(subject==null||subject==''){
			alert('评论主题不能为空！');
			$('subject').focus();
			return;
		}
		
		if(memo==null||memo==''){
			alert('评论内容不能为空！');
			$('memo').focus();
			return;
		}
		//alert('开始向服务器发起请求');
	var url='/addProductComment?loginId='+encodeURI(name,"utf-8") +'&&password='+password+'&&subject='+encodeURI(subject,"utf-8")+'&&memo='+encodeURI(memo,"utf-8")+'&&vc='+vc+'&&productId='+pid;
	var xmlHttp = createXMLHttpRequest();
	xmlHttp.open("post",url, true);
	xmlHttp.onreadystatechange = function () {	
		switch (xmlHttp.readyState) {		
		   case 4 :  
			   if (xmlHttp.status == 200){
			  // showMessage(xmlHttp.responseXML)
             var message=xmlHttp.responseXML.getElementsByTagName("error")[0].getAttribute("message");
	if(message!='vcf'){
    	alert(message);
    	window.close();
    }else{
    	alert('验证码输入错误，请重新输入');
    	$('codeimg').src='/image.jsp';
    }       
		       }
		       
		} 
	}			
	xmlHttp.send(null);
}
//读取留言信息。
function readMessage(number,pid){
if($('liuyan').title=='yes'){	
	return;
}
$('liuyan').title='yes';
	var xmlHttp = createXMLHttpRequest();
	xmlHttp.open("post",'/productComments?productId='+pid+'&&number='+number, true);
		xmlHttp.onreadystatechange = function () {	
		switch (xmlHttp.readyState) {		
           case 3 : 
				$('message').innerHTML = '加载中......';
		        break;
		   case 4 :  
			   if (xmlHttp.status == 200){
			   		$('message').innerHTML = '';
                    showComments(xmlHttp.responseXML,false,pid); 
		       }
		} 
	}			
	xmlHttp.send(null);	
}

function readMessageByPage(page,pid){
	if($('liuyan').title=='yes')$('liuyan').title='no';
	var xmlHttp=createXMLHttpRequest();
	xmlHttp.open("post",'/commentsMore?productId='+pid+'&&page='+page+'&&pageSize=6', true);
		xmlHttp.onreadystatechange = function () {	
		switch (xmlHttp.readyState) {		
           case 3 : 
           		clearAll();
				$('message').innerHTML = '加载中......';
		        break;
		   case 4 :  
			   if (xmlHttp.status == 200){
			   		$('message').innerHTML = '';
                    showComments(xmlHttp.responseXML,true,pid); 
		       }
		} 
	}			
	xmlHttp.send(null);	
}


function showComments(doc,isPage,pid){
	var comments='';
	var products=doc.getElementsByTagName("comment");
	
	for(var i=0;i<products.length;i++){
	var comment='';
		comment='<div id="productsComment"> <div id="productsComment_top"><span class="productsComment_name"><b>昵称：</b>'+products[i].getAttribute('nick')+'</span>';
		comment=comment+' <span class="productsComment_date"><b>留言时间：</b>'+products[i].getAttribute('time')+'</span>';
		comment=comment+'</div><div id="productsComment_middle"><ul><li><b>评论标题：</b></li><li class="productsComment_message">'+products[i].getAttribute('subject')+'</li></ul></div>';
		comment=comment+' <div id="productsComment_bottom"><ul><li><b>评论内容：</b></li><li style="width:683px">'+products[i].getAttribute('memo')+'</li></ul></div></div>';
		comments=comments+comment;
	}
	$('liuyan').innerHTML = comments;
	if(isPage==true){
	    var total=doc.getElementsByTagName("root")[0].getAttribute("total");
		if(parseInt(total)==0){
			return;
		}
	    var totalPage=doc.getElementsByTagName("root")[0].getAttribute("totalPage");
		var page=doc.getElementsByTagName("root")[0].getAttribute("page");
		var pageInfo='';
		var next=parseInt(page)+1;
		var pre=parseInt(page)-1;
		if(page=='1'){
			pageInfo='<span class="listPage_normal"><a href="#">上一页</a></span> ';
		}else{
			pageInfo='<span class="listPage_normal"><a onclick=readMessageByPage('+pre+',"<%=pid%>") href="#">???</a></span> ';
		}
		var i=1;
		var max=parseInt(totalPage);//最多显示3页
				if(parseInt(totalPage)>=3){
			
				if(parseInt(page)<2){
					max=3;
					}else if((totalPage-parseInt(page))<2){
						i=max-3;
					}else {
						i=parseInt(page)-1;
						max=parseInt(page)+1;
					}
			}
			for(;i<=max;i++){
				if(i==page){
				pageInfo=pageInfo+'<span  class="listPage_curpage"><a onclick=readMessageByPage('+i+',\''+pid+'\') href="#">'+i+'</a></span>';
				}else{
				pageInfo=pageInfo+'<span  class="listPage_normal"><a onclick="readMessageByPage('+i+',\''+pid+'\')" href="#">'+i+'</a></span>';			
				}
			}
			
			if(page==totalPage){
			 	pageInfo=pageInfo+'<span  class="listPage_normal"><a  onclick=readMessageByPage('+page+',\''+pid+'\')   href="#">下一页</a></span>'
			 }else{
				 pageInfo=pageInfo+'<span class="listPage_normal"><a onclick=readMessageByPage('+next+',\''+pid+'\')   href="#">下一页</a></span>'
			 }
			 pageInfo=pageInfo+'到 <select name="select" onchange="changePage("'+pid+'");" id="botPage">';
			 for(i=1;i<=totalPage;i++){
			 	if(i==page){
					pageInfo=pageInfo+'<option selected>-'+i+'-</option>'
				}else{
					pageInfo=pageInfo+'<option >-'+i+'-</option>'		
				}
			 }
			 pageInfo=pageInfo+'</select>页' ;
		$('listPage').innerHTML = pageInfo;
	}
}
function changePage(pid){
	readMessageByPage(parseInt($('botPage').selectedIndex)+1,pid);
}

//清空所有
function clearAll(){
		$('message').innerHTML = '加载中......';
		$('listPage').innerHTML=''
		$('liuyan').innerHTML=''
}




//读取配送说明
function readPeisong(){
var xmlHttp=createXMLHttpRequest();
	xmlHttp.open("post",'/warm/peisong.html', true);
		xmlHttp.onreadystatechange = function () {	
		switch (xmlHttp.readyState) {		
           case 3 : 
				$('tcontent2').innerHTML = '加载中......';
		        break;
		   case 4 :  
			   if (xmlHttp.status == 200){
			   		$('tcontent2').innerHTML = xmlHttp.responseText;
		       }
		} 
	}			
	xmlHttp.send(null);	
	//left_container
}
//读取导航菜单
function readCaidan(){
var xmlHttp=createXMLHttpRequest();
	xmlHttp.open("post",'/pmenu2.htm', true);
		xmlHttp.onreadystatechange = function () {	
		switch (xmlHttp.readyState) {		
		   case 4 :  
			   if (xmlHttp.status == 200){
			  	  var tx=xmlHttp.responseText;
			 	  $('left_menu1').innerHTML =tx;
		       }
		} 
	}			
	xmlHttp.send(null);	
}
//读取导航菜单
function readFooter(){
var xmlHttp=createXMLHttpRequest();
	xmlHttp.open("post",'/index_footer2.jsp', false);
		xmlHttp.onreadystatechange = function () {	
		switch (xmlHttp.readyState) {		
		   case 4 :  
			   if (xmlHttp.status == 200){
			   		$('product_footer').innerHTML = xmlHttp.responseText;
		       }
		} 
	}			
	xmlHttp.send(null);	
}
//增加次数
function addRead(pid){
var xmlHttp=createXMLHttpRequest();
	xmlHttp.open("post",'/modPod?types=1&pds='+pid, true);			
	xmlHttp.send(null);	
}
//产品页面，跳转到最后访问的产品页面。
function lastURL(){
	var xmlHttp=createXMLHttpRequest();
	xmlHttp.open("post",'/lastUrl.jsp?url='+location.href, true);			
	xmlHttp.send(null);	
}


lastURL();

	
