function openCommentReply( event, ticket, repto ) {
  if( !event ) event = window.event;
  var li = getParentElementByTagName( event.target, 'LI' );
  var form = document.createElement('form');
  form.setAttribute( 'method', 'post' );
  form.setAttribute( 'action', '/ts/detail/'+ticket+'/' );
  var border = document.createElement( 'div' );
  border.setAttribute( 'class', 'reply' );
  var title = document.createElement( 'h3' );
  title.appendChild( document.createTextNode( 'Reply:' ) );
  border.appendChild( title );
  var textarea = document.createElement( 'textarea' );
  textarea.setAttribute( 'rows', '5' );
  textarea.setAttribute( 'cols', '80' );
  textarea.setAttribute( 'name', 'comment' );
  form.appendChild( textarea );
  var reptoInput = document.createElement( 'input' );
  reptoInput.setAttribute( 'type', 'hidden' );
  reptoInput.setAttribute( 'name', 'repto' );
  reptoInput.setAttribute( 'value', repto );
  form.appendChild( reptoInput );
  var submit = document.createElement( 'input' );
  submit.setAttribute( 'type', 'submit' );
  submit.setAttribute( 'value', 'Submit' );
  form.appendChild( submit );
  border.appendChild( form );
  li.appendChild( border );
  event.target.setAttribute( 'onclick', 'closeCommentReply( event, '+ticket+', '+repto+' )' );
}

function closeCommentReply( event, ticket, repto ) {
  if( !event ) event = window.event;
  var li = getParentElementByTagName( event.target, 'LI' );
  var form = getChildElementByTag( li, 'FORM' );
  var div = getParentElementByTagName( form, 'DIV' );
  li.removeChild( div );
  event.target.setAttribute( 'onclick', 'openCommentReply( event, '+ticket+', '+repto+' )' );
}
