/* -*- C++ -*- */
var debug_mode = false;
var ajax_request_type = 'POST';
var ajax_debug_target_id = '';
var ajax_target_id = '';
var failure_redirect_url = '';
var ajax_requests = new Array();
var ajax_uri = 'http://www.ytmnd.com/sites/comment_remote.html';

var reply_row = 0;


function postComment () {
  
}


function replyInsert (dongs, site_id, comment_table, ct) {


  var table = document.getElementById('comment_row_' + comment_table);

  var replyTable = document.getElementById('comment_row_' + reply_row);


  if (replyTable) {
    replyTable.deleteRow(1);
  }


  new_row = table.insertRow(1);
  reply_row = comment_table;


  //new_row.insertCell();

  spacer = document.createElement('td');
  spacer.style.backgroundColor = '#d4cebb';
  spacer.style.height = '120px';
  spacer.style.width = '90px';


//  <div style="height: 80px; width: 160px; vertical-align: top; font-family: Verdana; font-size 12px; padding-left: 12px; padding-top:12 px; border-bottom:1px dotted #000000; margin-bottom:3px;">Reply to this comment: <img src="http://content.ytmnd.com/assets/images/spacer.gif" width="32" height="32" style="position: relative; left: 5px; top: 60px;" id="comment_reply_status"></div>

  reply_comment = document.createElement('td');
  reply_comment.style.backgroundColor = '#b0aa99';
  reply_comment.style.height = '80px';
  reply_comment.style.width = '160px';
  reply_comment.style.color = '#ffffff';
  reply_comment.style.verticalAlign = 'top';
  reply_comment.style.fontFamily = 'Verdana';
  reply_comment.style.fontSize = '12px';
  reply_comment.style.paddingLeft = '12px';
  reply_comment.style.paddingTop = '12px';
  reply_comment.innerHTML = 'Reply to this comment: <img src="http://content.ytmnd.com/assets/images/spacer.gif" width="32" height="32" style="position: relative; left: 5px; top: 60px;" id="comment_reply_status">';

  reply_comment.style.borderBottom = '1px dotted #000000';
  reply_comment.style.marginBottom = '3px';


  comment_form = document.createElement('td');

  comment_form.setAttribute("colSpan",2);
    if (ct == 2) {
      formHTML  = '<form action="/news/comment.html" id="inline_form" method="post">';
    }
    else {
      formHTML  = '<form action="/sites/comment.html" id="inline_form" method="post">';
    }

    if (ct == 2) {
      formHTML += '<input type="hidden" name="news_id" value="' +site_id +'">';
    }
    else {
      formHTML += '<input type="hidden" name="site_id" value="' +site_id +'">';
    }

  formHTML += '<input type="hidden" id="comment_id" name="comment_id" value="'+dongs+'">';
  formHTML += '<textarea style="width: 620px;" class="textarea_field" id="inline_comment" onKeyDown="textCounter(this.form.';
  formHTML += 'inline_comment,this.form.remLen,800);" onKeyUp="textCounter(this.form.inline_comment,this.form.remLen,512);" rows="6"';
  formHTML += 'cols="36" name="inline_comment"></textarea>&nbsp;<br><span style="text-align: right; float: right; width: 100%">';
  formHTML += '<input type="image" src="http://content.ytmnd.com/assets/images/submit_button.png" class="button"';
  formHTML += 'onclick="" />&nbsp;&nbsp;';
  formHTML += '<input type="hidden" name="remLen" id="remLen"></span></form>';

  comment_form.innerHTML = formHTML;

  comment_form.style.borderBottom = '1px dotted #000000';
  comment_form.style.marginBottom = '3px';


  new_row.appendChild(spacer);
  new_row.appendChild(reply_comment);
  new_row.appendChild(comment_form);
}


function postComment ()
{


//  document.getElementById('comment_reply_status').src = "http://content.ytmnd.com/assets/images/comments_loading.gif";


//  actual_comment = document.getElementById('inline_comment').value;
//  site_id = document.getElementById('site_id').value;
//  comment_id = document.getElementById('comment_id').value;

   

 // setTimeOut("document.getElementById('inline_form').submit()", 1000);





}

function showComment(counter_id) {

  document.getElementById('abar_' + counter_id).style.display='';
  document.getElementById('hbar_' + counter_id).style.display='';
  document.getElementById('comment_date_' + counter_id).style.display='';
  document.getElementById('full_comment_' + counter_id).style.display='';
  document.getElementById('sbar_' + counter_id).style.display='none';
  return false;
}


function hideComment(counter_id) {

  document.getElementById('abar_' + counter_id).style.display='none';
  document.getElementById('hbar_' + counter_id).style.display='none';
  document.getElementById('comment_date_' + counter_id).style.display='none';
  document.getElementById('full_comment_' + counter_id).style.display='none';
  document.getElementById('sbar_' + counter_id).style.display='';
  return false;
}



function commentVoteDown (comment_id, ct)
{
  if (ct != 1) {ct = 'n';}

  comment_voter = document.getElementById('comment_vote_interface');
  comment_voter.src='/vote/comment_vote.html?comment_id='+comment_id+'&ct='+ct+'&vote=1&auth_code=' + vote_auth_hash;

  document.getElementById('down_'+comment_id).innerHTML = '<span style="color: black; font-size: 20px; vertical-align: -2px;">-</span>';

  return false;
}



function commentVoteUp (comment_id, ct)
{
  if (ct != 1) {ct = 'n';}

  comment_voter = document.getElementById('comment_vote_interface');
  comment_voter.src='/vote/comment_vote.html?comment_id='+comment_id+'&ct='+ct+'&vote=2&auth_code=' + vote_auth_hash;
  document.getElementById('up_'+comment_id).innerHTML = '<span style="color: black; font-size: 20px; vertical-align: -2px;">+</span>';

  return false;
}

