function showaddcomment(){
  document.getElementById('addthreadedcomment').style.display='block';
  document.getElementById('hiddenparentid').value = '0';
  window.location.href = "#addcommentform";
}

function replyto(id){
  document.getElementById('addthreadedcomment').style.display='block';
  document.getElementById('hiddenparentid').value = id;
  document.getElementById('threadedinreplyto1').innerHTML = 'In Reply to:';
  document.getElementById('threadedinreplyto2').innerHTML = '<em>Comment #'+id+'</em><span id="threadedundoreply"><a href="javascript:undoreply();">(Undo)</a></span>';
  window.location.href = "#addcommentform";
}

function undoreply(){
  document.getElementById('hiddenparentid').value = '0';
  document.getElementById('threadedinreplyto1').innerHTML = '';
  document.getElementById('threadedinreplyto2').innerHTML = '';
}

function toggletwitter(){
  if (document.getElementById('twitter').checked === true){
    document.getElementById('twitter').checked=false;
  } else{
    document.getElementById('twitter').checked=true;
  }
}

function textCounter(field,cntfield,maxlimit) {
  if (field.value.length > maxlimit){
    field.value = field.value.substring(0, maxlimit);
  } else {
    cntfield.value = maxlimit - field.value.length;
  }
}

