function TranslateComments()
{
    var obj;

    obj = document.getElementById("B_CommandSubmit");
    if( obj != "undefined" && obj != null )
        obj.value = "Submit";
    obj = document.getElementById("B_CommandReset");
    if( obj != "undefined" && obj != null )
        obj.value = "Clear Form";
    obj = document.getElementById("Lbl_page_comments");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "comments";
    obj = document.getElementById("Lbl_page_pages");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "pages";
    obj = document.getElementById("Lbl_list_all");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "View All Comments";
        
    obj = document.getElementById("Lbl_list_comments");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "comments";
    obj = document.getElementById("Lbl_list_pages");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "pages";

   obj = document.getElementById("Lbl_stat_listed");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "listed";
    obj = document.getElementById("Lbl_stat_comments");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "comments";
    obj = document.getElementById("Lbl_UserName");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "User Name";
    obj = document.getElementById("Lbl_pwd");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Password";
    obj = document.getElementById("Lbl_Excellent");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Excellent";
    obj = document.getElementById("Lbl_vgood");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Very Good";
    obj = document.getElementById("Lbl_good");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Good";
    obj = document.getElementById("Lbl_fair");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Fair";
    obj = document.getElementById("Lbl_poor");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Poor";
    obj = document.getElementById("Lbl_pointofview");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Point of View";
    obj = document.getElementById("Lbl_stat_Excellent");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Excellent";
    obj = document.getElementById("Lbl_stat_vgood");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Very Good";
    obj = document.getElementById("Lbl_stat_good");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Good";
    obj = document.getElementById("Lbl_stat_fair");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Fair";
    obj = document.getElementById("Lbl_stat_poor");
    if( obj != "undefined" && obj != null )
        obj.innerHTML = "Poor";
}

function GetAddCommentForm(NewsID)
{
/* disable the posting comments here instead of remove it from the template: we don't need to re-publish all the articles -- janet */
/*
   var Action="id=" + NewsID + "&CommentType=GetAddCommentForm";
   var options={ 
                  method:'get', 
                  parameters:Action, 
                  onComplete:function(transport) 
                  { 
                      var returnvalue=transport.responseText; 
                      var arrreturnvalue=returnvalue.split('$$$'); 
                     if (arrreturnvalue.length > 1)
                     { 
                      if (arrreturnvalue[0]=="ERR") 
                          document.getElementById("Div_CommentForm").innerHTML='***Failed to down load comment form!'; 
                      else 
                          document.getElementById("Div_CommentForm").innerHTML=arrreturnvalue[1]; 
                      }
                  } 
               }; 
   new  Ajax.Request("/comment.aspx?no-cache="+Math.random(),options);
*/
}


function CommandSubmit(NewsID, obj)
{
    if(obj.Content.value=="")
    {
        alert('Comment can not be empty!');
        return false;
    }
   else if( obj.Content.value.length > 200  ||  obj.Content.value.length < 2 )
   {
        alert('There should be more than 2 characters and less than 200 characters in the comment!  Currently, your comment contains ' + obj.Content.value.length + ' characters.');
        return false;
   }
    
    var r = obj.commtype; 
    var commtypevalue = '2'; 
    for(var i=0;i<r.length;i++) 
    {
        if(r[i].checked)
           commtypevalue=r[i].value;
    }
    var Action="CommentType=AddComment&UserNum="+escape(obj.UserNum.value)+"&&commtype="+escape(commtypevalue)+"&Content="+escape(obj.Content.value)+"&IsQID="+escape(obj.IsQID.value)+"&id=" + NewsID;
    var options={ 
                    method:'get', 
                    parameters:Action, 
                    onComplete:function(transport) 
                    { 
                        var returnvalue=transport.responseText; 
                        var arrreturnvalue=returnvalue.split('$$$'); 
                        if (arrreturnvalue[0]=="ERR") 
                        { 
                           alert(arrreturnvalue[1]); 
                           GetAddCommentForm(NewsID); 
                        } 
                        else 
                        { 
                           alert('Submit comment successfully!'); 
                           document.getElementById("Div_CommentList").innerHTML=arrreturnvalue[1]; 
                           GetAddCommentForm(NewsID); 
                        } 
                    } 
                 }; 
      new  Ajax.Request("/comment.aspx?no-cache="+Math.random(),options);
} 

function CommentLoginOut()
{
    var Action='CommentType=LoginOut';
    var options={ 
                  method:'get', 
                  parameters:Action, 
                  onComplete:function(transport) 
                  { 
                      var returnvalue=transport.responseText; 
                      var arrreturnvalue=returnvalue.split('$$$'); 
                      if (arrreturnvalue[0]=="ERR") 
                          alert('Unkown error!'); 
                      else 
                          document.getElementById("Div_CommentForm").innerHTML=arrreturnvalue[1]; 
                   } 
                 }; 
      new  Ajax.Request("/comment.aspx?no-cache="+Math.random(),options);
}                

function GetCommentList(NewsID, page)
{
/* disable the posting comments here instead of remove it from the template: we don't need to re-publish all the articles -- janet */
/*
   var Action="id=" + NewsID + "&CommentType=GetCommentList&page="+page;
   var options={ 
                  method:'get', 
                  parameters:Action, 
                  onComplete:function(transport) 
                  { 
                      var returnvalue=transport.responseText; 
                      if (returnvalue.indexOf("??")>-1) 
                          document.getElementById("Div_CommentList").innerHTML=""; //'ERROR: Failed to load comments'; 
                      else
                          document.getElementById("Div_CommentList").innerHTML=returnvalue; 
                      TranslateComments();    
                  } 
               }; 
      new  Ajax.Request("/comment.aspx?no-cache="+Math.random(),options);
*/
}

function GetCommentListContent(urlsitedomain,newsid,page)
{
   var Action='id='+newsid+'&CommentType=getlist&showdiv=0&page='+page;   
   var options={ 
                  method:'get', 
                  parameters:Action, 
                  onComplete:function(transport) 
                  { 
                      var returnvalue=transport.responseText;
                      if (returnvalue.indexOf("??")>-1) 
                          document.getElementById("Div_CommentListPage").innerHTML=""; //'ERROR: Failed to load comments';
                      else 
                          document.getElementById("Div_CommentListPage").innerHTML=returnvalue; 
                       TranslateComments();    
                 } 
               }; 
      new  Ajax.Request("/comment.aspx?no-cache="+Math.random(),options);
}


function CommandSubmitContent(obj,url,newsid)
{
    if(obj.Content.value=="")
    {
        alert('Comment can not be empty!');//alert('评论内容不能为空');
        return false;
    }
   else if( obj.Content.value.length > 200  ||  obj.Content.value.length < 2 )
   {
        alert('There should be more than 2 characters and less than 200 characters in the comment!  Currently, your comment contains ' + obj.Content.value.length + ' characters.');
        return false;
   }

    var r = obj.commtype; 
    var commtypevalue = '2'; 
    for(var i=0;i<r.length;i++) 
    {
        if(r[i].checked)
           commtypevalue=r[i].value;
    }
    var Action='CommentType=AddComment&showdiv=1&UserNum='+escape(obj.UserNum.value)+'&commtype='+escape(commtypevalue)+'&Content='+escape(obj.Content.value)+'&IsQID='+escape(obj.IsQID.value)+'&id=' + newsid;

   var options={ 
                    method:'get', 
                    parameters:Action, 
                    onComplete:function(transport) 
                    { 
                        var returnvalue=transport.responseText; 
                        var arrreturnvalue=returnvalue.split('$$$'); 
                        if (arrreturnvalue[0]=="ERR") 
                        { 
                           alert(arrreturnvalue[1]); 
                           obj.Content.value='';
                        } 
                        else 
                        { 
                           alert('Your comment has submitted successfully!'); //alert('发表评论成功!'); 
                           GetCommentListContent(''+url+'',''+newsid+'','1');
                           //document.getElementById("Div_CommentListPage").innerHTML=arrreturnvalue[1]; 
                           obj.Content.value='';
                        } 
                    } 
                 }; 
     new  Ajax.Request(''+url+'/comment.aspx?no-cache='+Math.random(),options); 
     
} 
function CommentLoginOut(obj,url)
{
    var Action='CommentType=LoginOut';
    var options={ 
                  method:'get', 
                  parameters:Action, 
                  onComplete:function(transport) 
                  { 
                      var returnvalue=transport.responseText; 
                      var arrreturnvalue=returnvalue.split('$$$'); 
                      if (arrreturnvalue[0]=="ERR") 
                          alert('未知错误!'); 
                      else 
                          document.getElementById('UserNum').value='Guest';
                          document.getElementById('UserPwd').value='';
                          document.getElementById('loginOutB').innerHTML='(匿名用户请直接使用Guest用户名) ';
                   } 
                 }; 
      new  Ajax.Request(''+url+'/comment.aspx?no-cache='+Math.random(),options);
}


