/*
 * For Folded comments Plugin
 *
 * @author Mikko Kovanen <arbory [at] barbababa [dot] net>
 */

function foldComTxt( idx, showTxt, hideTxt )
{
  var divstyle = document.getElementById( 'foldedComTxt_'+idx ).style;
  var txt = document.getElementById( 'SorHComTxt_'+idx );
  var showhide = (divstyle.display == 'none')?'':'none';
  divstyle.display = showhide;
  if( showhide == 'none' )
  {
    txt.innerHTML = showTxt;
  }
  else
  {
    txt.innerHTML = hideTxt;
  }
}

function foldComAdd( idx, showTxt, hideTxt )
{
  var divstyle = document.getElementById( 'foldedComAdd_'+idx ).style;
  var txt = document.getElementById( 'SorHComAdd_'+idx );
  var showhide = (divstyle.display == 'none')?'':'none';
  divstyle.display = showhide;
  if( showhide == 'none' )
  {
    txt.innerHTML = showTxt;
  }
  else
  {
    txt.innerHTML = hideTxt;
  }
}

function commentLimit( txt, maxlen )
{
  if( txt.value.length > maxlen )
  {
    txt.value = txt.value.substring( 0, maxlen );
/*    txt.scrollTop = txt.scrollHeight;*/
  }
}


function validateCommentForm( f, nickAlertTxt, commentAlertTxt )
{
  if( f.nick.value == null )
  {
    alert( nickAlertTxt );
    return false;
  }
  if( f.nick.value.length == 0 )
  {
    alert( nickAlertTxt );
    return false;
  }

  if( f.txt.value == null )
  {
    alert( commentAlertTxt );
    return false;
  }

  if( f.txt.value.length == 0 )
  {
    alert( commentAlertTxt );
    return false;
  }

  if( f.varmistus.value == null )
  {
    alert( "Please enter 89 to spam check value" );
    return false;
  }
  if( f.varmistus.value.length != 2 )
  {
    alert( "Please enter 89 to spam check value" );
    return false;
  }
  if( f.varmistus.value != "89" )
  {
    alert( "Please enter 89 to spam check value" );
    return false;
  }

  return true;
}

