ieDropDowns = function()  {
  startList();
}

function hidecomments(id) { 
  var id = id;
  var list = 'commentlist' + id;
  document.getElementById(list).innerHTML = ' ';
} 

function hidediv(id) { 
  var x = id;
  document.getElementById(x).style.display = 'none'; 
}

function showdiv(id) { 
  var x = id;
  document.getElementById(x).style.display = 'block'; 
} 

function delete_comment(journalid,commentid,commenter)  {
  var url = "xmlgetdeletecomments.php?param=";
  var journalid = journalid * 1;
  var commentid = commentid * 1;
  var commenter = commenter;
  var commenterlength = commenter.length;
  if (journalid > 0 && commentid > 0 && commenterlength < 25)
    {
      var divid = 'delete' + commentid;
      var jcm = journalid + "," + commentid + ",'" + commenter + "'";
      document.getElementById(divid).innerHTML = 'Confirm: <a href="javascript:delete_confirm(' + jcm + ');" class="editlink">yes, delete</a>';
    }
}




function delete_confirm(journalid,commentid,commenter)  {
  var url = "xmlgetdeletecomments.php?param=";
  var journalid = journalid;
  var commentid = commentid;
  var commenter = commenter;
  var param = journalid + '*' + commentid + '*' + commenter;
  http.open("GET", url + escape(param), true);
  http.onreadystatechange = handleHttpResponseDelete;
  http.send(null);  
}

function handleHttpResponseDelete() {
  if (http.readyState == 4) {
    var results = http.responseText.split('*');
    var divid = results[0];
    var resultlength = divid.length;
    if (resultlength > 0 && resultlength < 43)
      {
        document.getElementById(divid).innerHTML = ''; 
      }
   }
}



function approve_comment(journalid,commentid,commenter)  {
  var url = "xmlgetapprovecomments.php?param=";
  var journalid = journalid;
  var commentid = commentid;
  var commenter = commenter;
  var param = journalid + '*' + commentid + '*' + commenter;
  http.open("GET", url + escape(param), true);
  http.onreadystatechange = handleHttpResponseApprove;
  http.send(null);  
}

function handleHttpResponseApprove() {
  if (http.readyState == 4) {
    var results = http.responseText.split('*');
    var divid = results[0];
    var resultlength = divid.length;
    if (resultlength > 0 && resultlength < 43)
      {
        document.getElementById(divid).innerHTML = 'approved'; 
      }
   }
}


function addmycomment(journalid) {
  var url = "xmlgetmakecomment.php?param=";
  var journalid;
  var memberid = document.getElementById('member').value;
  var commentid = 'c' + journalid;
  var comment = document.getElementById(commentid).value;
  comment = comment.substring(0, 2000);
  var param = journalid + '*' + memberid + '*' + comment;
  http.open("GET", url + escape(param), true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);  
}

function handleHttpResponse() {
  if (http.readyState == 4) {
    var results = http.responseText.split("**%##%$*");
    var commentsuccess = results[0];
    var journalid = results[1];
    var commentsexist = results[2];
    var comments = results[3];
    var nav = results[4];
    var commentbox = 'commentbox' + journalid;
    if (commentsuccess == 1)
      {
        // clear add comment box
        var commentdiv = 'commentbox' + journalid;
        hidediv(commentdiv);
        // show add comment link div
        var linkdiv = 'commentlink' + journalid;
        showdiv(linkdiv);

        // show most recent comments
        if (commentsexist == 1)
          {
            // clear any visible comments for journal        
            hidecomments(journalid);
        
            // show most recent comments
            var list = 'commentlist' + journalid;
            document.getElementById(list).innerHTML = comments; 
            document.getElementById('topcommentnav').innerHTML = nav; 
            document.getElementById('bottomcommentnav').innerHTML = nav;         
            document.getElementById(commentbox).innerHTML = '<form name="makeacomment" action="javascript:addmycomment(' + journalid + ')" method="post">Add a comment:<br><textarea name="c' + journalid + '" id="c' + journalid + '" cols="60" rows="10"></textarea><br><input type="submit" name="submit" value="Submit"></form>';         
          }
      }
    else
      {
        // comment not posted
      }
   }
}


function showcomment(entry,commentgroup)
  {
    var url = "xmlgetshowcomments.php?param=";
    var entry;
    var commentgroup;
    var memberid = document.getElementById('member').value;
    var param = entry + '*' + memberid + '*' + commentgroup;
    http.open("GET", url + escape(param), true);
    http.onreadystatechange = handleHttpResponse2;
    http.send(null);  
}

function handleHttpResponse2() {
  if (http.readyState == 4) {
    var results = http.responseText.split("**%##%$*");
    var commentsuccess = results[0];
    var journalid = results[1];
    var commentsexist = results[2];
    var comments = results[3];
    var nav = results[4];
    if (commentsuccess == 1)
      {
        // show most recent comments
        if (commentsexist == 1)
          {
            // clear any visible comments for journal        
            hidecomments(journalid);
            // show most recent comments
            var list = 'commentlist' + journalid;
            document.getElementById(list).innerHTML = comments; 
            document.getElementById('topcommentnav').innerHTML = nav; 
            document.getElementById('bottomcommentnav').innerHTML = nav;         
          }
      }
    else
      {
        // comment not posted
      }
   }
}


function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
var http = getHTTPObject();