function AjaxObject(){
  var request = null;
  try{
    request = new ActiveXObject("Msxml2.XMLHTTP");
  }catch (e){
    try{
      request = new ActiveXObject("Microsoft.XMLHTTP");
    }catch (oc){
      request = null;
    }
  }
  if (!request && typeof XMLHttpRequest != "undefined"){
    try{
      request =  new XMLHttpRequest();
    }catch (fa){
      alert("抱歉，您的浏览器不支持这个功能，请选择IE 6.0或FireFox浏览器。")
      request = null;
    }
  }
  return request;
}
//发送请求和处理请求
function make_show(url,contentId){
		var contentObj = document.getElementById(contentId);
		var xmlHttp = AjaxObject();
		url+="&rand="+Math.random();
		if (document.getElementById("status")!=null && document.getElementById("status").value==1){
			var status=document.getElementById("status").value;
		}
		
		//为监听状态的事件指定一个执行函数
		xmlHttp.onreadystatechange=function(){
			if (xmlHttp.readyState==4 && xmlHttp.status==200){
				if (xmlHttp.responseText == "2" && contentId =="comment_id") {
					alert("用户名和密码错误！");
					document.getElementById("userid").focus();
				}else if(xmlHttp.responseText == "4" && contentId =="comment_id"){
					alert("该用户已经禁止发言了！");
					document.getElementById("content_id").focus();
				}else if(xmlHttp.responseText == "5" && contentId =="comment_id"){
					alert("该IP已被禁止发言！");
					document.getElementById("content_id").focus();
				}else if(xmlHttp.responseText == "6" && contentId =="comment_id"){
					alert("您发布的太过频繁了！");
					document.getElementById("content_id").focus();
				}else if(xmlHttp.responseText == "7" && contentId =="comment_id"){
					alert("请注意您的言论中含有不健康的词汇（或者含有敏感的、有歧义的词汇），禁止提交！请检查!");
					document.getElementById("content_id").focus();
				}else{				
					contentObj.innerHTML = xmlHttp.responseText;
					//alert(contentObj.innerHTML);
					if (1 == status) {
						alert("发表评论成功!");
					}
				}
			}
		};
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
 }
function inti_comment(id,merchantid,type){
 	if (!id) return false;
 	if(!type){
 		type=1;
 	}
 	url ="http://dealer.cnmo.com/ajax_comment.php?merchant_id="+merchantid+"&backurl="+location.href+"&type="+type;
 	make_show(url,id);
}
