/*Created by jimmy ruska*/
var sameLen=0;
function wc(txt){
  if ((len=txt.length)===sameLen) return;
  else sameLen=len;
  s=true;
  wcnt=cnt=0;
  while (cnt<len){
    if ((c=txt.charAt(cnt++))===" " || c==="\n" || c==="\r"){
      if (s===false)  s=true;
    } else if (s===true){
      s=false;
      wcnt++;
    }
  }
  document.getElementById('wc').innerHTML='Char Count: '+cnt+' / Word Count: '+wcnt;
}
setInterval("wc(document.getElementById('txt').value)", 3000);

function preview(datas,location){
  $.ajax({
    type: "POST",
    url: "rp_test.php",
    scriptCharset: "utf-8",
    contentType: " application/x-www-form-urlencoded; charset=UTF-8", 
    data: "x="+document.getElementById(datas).value,
    success: function(msg){
      len=document.getElementById(datas).value.length;
      $("#"+location).attr("style","font-size: 18");
      $("#"+location).html(msg);
    }
  });
  return false;
}

