// JScript

function createxmlhttp()
    {
     
    var xmlhttp=null;

     if (window.ActiveXObject)
      {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
     }
     else if(window.XMLHttpRequest) 
     {
      xmlhttp=new XMLHttpRequest();
     }
     return xmlhttp;
  }
function getremarklist()
{
   getremarkshu()
   getusersession()
   var firstload=0;
if(firstload==0)
   {
   document.getElementById("commentlist").innerHTML="<font color=\"red\">正在加载评论...</font>";
  
   firstload=1;
  }
   var xmlhttp=createxmlhttp();
   if (xmlhttp)
    {
        xmlhttp.onreadystatechange=function ()
         {
		  if(xmlhttp.readyState==4)  
		  {
		   
             if(xmlhttp.status==200)  
             {
               
	            document.getElementById("commentlist").innerHTML=xmlhttp.responseText;
	            
	            
			 }	         
          }
		}  
					var tm=new Date().getTime();//鍔犲叆鏃堕棿鏍囩闃叉缂撳瓨
					var url="/ajax/Ajaxgetremarklist.aspx?id="+id+"";
	    xmlhttp.open("post",url);
	    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlhttp.send("");
    }		
}
function getremarkshu()
{

   var xmlhttp=createxmlhttp();
   if (xmlhttp)
    {
        xmlhttp.onreadystatechange=function ()
         {
		  if(xmlhttp.readyState==4)  
		  {
		   
             if(xmlhttp.status==200)  
             {
               
	            document.getElementById("remarkshu").innerHTML=xmlhttp.responseText;
	            document.getElementById("remarkshu1").innerHTML=xmlhttp.responseText;
	            
	            
			 }	         
          }
		}  
					var tm=new Date().getTime();
					var url="/ajax/Ajaxgetremarkshu.aspx?id="+id+"";
	    xmlhttp.open("post",url);
	    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlhttp.send("");
    }		
}
function getusersession()
{

   var xmlhttp=createxmlhttp();
   if (xmlhttp)
    {
        xmlhttp.onreadystatechange=function ()
         {
		  if(xmlhttp.readyState==4)  
		  {
		   
             if(xmlhttp.status==200)  
             {
               var ll=(xmlhttp.responseText);
              if(ll=="nologin")
	            {
	            document.getElementById("newslogin").innerHTML="用户名：<input name='username' class='input1' id='username' size='12' maxlength='20' />&nbsp;密码：<input name='password' type='password' class='input1' id='password' value='' size='12' maxlength='20' /> <a href='/user/reg.aspx' target='_blank'>注册会员</a>";
	            } 
	            else
	            {   
	            document.getElementById("newslogin").innerHTML="<input name='username' type='hidden' id='username' value='1' /><input name='password' type='hidden' id='password' value='1' />";
	            }        
			 }	         
          }
		}  
					var tm=new Date().getTime();
					var url="/ajax/Ajaxusersession.aspx";
	    xmlhttp.open("post",url);
	    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlhttp.send("");
    }		
}
function addremark()
{
 
   document.getElementById("addremarking").innerHTML="<font color=\"red\">正在提交...</font>";
   var content=document.getElementById("content").value;
   
   if(content=="")
   {
   document.getElementById("addremarking").innerHTML="<font color=\"red\">评论内容不能为空！</font>";
   return;
   }
   
   var support = 1;
    
   var niming=document.getElementById("niming").value;

    for(var i=0;i<document.getElementsByName("niming").length;i++)
   {
      if(document.getElementsByName("niming")[0].checked==true)
      {
          niming = "1";
          break;
      }
      else if(document.getElementsByName("niming")[1].checked==true)
      {
          niming = "0";
          break;
      }
   }
   
   if(niming=="2")
   {
   document.getElementById("addremarking").innerHTML="<font color=\"red\">请选择使用匿名还是会员！</font>";
   return;
   } 
  if(niming==0)
   {
      var username=document.getElementById("username").value;
      var password=document.getElementById("password").value;
     if(username=="")
     {
          document.getElementById("addremarking").innerHTML="<font color=\"red\">用户名不能为空！</font>";
          return;
     }
     if(password=="")
     {
          document.getElementById("addremarking").innerHTML="<font color=\"red\">密码不能为空！</font>";
          return;
     }
   }
   
   var xmlhttp=createxmlhttp();
   if (xmlhttp)
    {
        xmlhttp.onreadystatechange=function ()
         {
		  if(xmlhttp.readyState==4)  
		  {
		   
             if(xmlhttp.status==200)  
             {
               var yy=(xmlhttp.responseText);
               if(yy=="remarkfou")
	            {
	            document.getElementById("content").value="";
	            document.getElementById("addremarking").innerHTML="<font color=\"red\">不可评论！</font>";
	            }
	            if(yy=="false")
	            {
	            document.getElementById("addremarking").innerHTML="<font color=\"red\">用户名或密码错误！</font>";
	            }
	            else
	            {
	            getremarklist(id)
	            document.getElementById("content").value="";
	            document.getElementById("addremarking").innerHTML="<font color=\"red\">评论成功，需管理员审核后才可显示！</font>";
	            }
	           
	            
			 }	         
          }
		}  
					var tm=new Date().getTime();//鍔犲叆鏃堕棿鏍囩闃叉缂撳瓨
					var url="/ajax/Ajaxaddremark.aspx";
					
	    xmlhttp.open("post",url,true);
	    xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
		xmlhttp.send("id="+id+"&support="+support+"&username="+username+"&password="+password+"&niming="+niming+"&content="+content);
    }		
}
