var spellpage = "spell/RapidSpellCheckerPopUp.jsp";
//var spellpage = "spell/RapidSpellCheckerPopUp.aspx";

// this function is called from edit
function __onSpell()
{
  popUpCheckSpelling("rsTCIntrapidSpellWebLauncher");
}


function RSCustomInterface()
{
  this.getText = getText;
  this.setText = setText;

  function getText()
  {
    return editGetBodyHtml();
  }
  function setText(text)
  {
    editSetBodyHtml(text);
  }
}


function escQuotes(text)
{
  var rx = new RegExp("\"", "g");
  return text.replace(rx,"&#34;");
}

function escEntities(text)
{
  var rx = new RegExp("&", "g");
  return text.replace(rx,"&amp;");
}

var spellBoot="";
function popUpCheckSpelling(interfaceObjectName)
{
  var spellBoot = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head><body onLoad='document.forms[0].submit();'><font face='arial, helvetica' size=2>Spell checking document...</font><form action='" + spellpage  + "' method='post' ACCEPT-CHARSET='UTF-8'>";
  spellBoot += "<input type='hidden' name='textToCheck' value=\""+escQuotes(escEntities(eval(interfaceObjectName+'.getText()')))+"\"><input type='hidden' name='InterfaceObject' value='"+interfaceObjectName+"'><input type='hidden' name='mode' value='popup'><input type='hidden' name='UserDictionaryFile' value=''><input type='hidden' name='SuggestionsMethod' value='HASHING_SUGGESTIONS'><input type='hidden' name='SeparateHyphenWords' value='false'>";
  spellBoot += "<input type='hidden' name='IncludeUserDictionaryInSuggestions' value='false'><input type='hidden' name='FinishedListener' value=''><input type='hidden' name='callBack' value=''><input type='hidden' name='IgnoreXML' value='true'><input type='hidden' name='IgnoreCapitalizedWords' value='false'>";
  spellBoot += "<input type='hidden' name='GuiLanguage' value='ENGLISH'><input type='hidden' name='LanguageParser' value='ENGLISH'>";
  spellBoot += "<input type='hidden' name='ShowFinishedMessage' value='true'><input type='hidden' name='ShowNoErrorsMessage' value='true'><input type='hidden' name='ShowXMLTags' value='false'>";
  spellBoot += "<input type='hidden' name='DictFile' value=''><input type='hidden' name='PopUpWindowName' value=''><input type='hidden' name='CreatePopUpWindow' value='true'><input type='hidden' name='ConsiderationRange' value='80'></form></body></html>";
  var sc = window.open('', 'rspellwin', 'resizable=yes,scrollbars=auto,dependent=yes,toolbar=no,left=100,top=100,status=no,location=no,menubar=no,width=370,height=400'); sc.focus(); sc.document.open();  sc.document.write(spellBoot); sc.document.close();
}

var rsTCIntrapidSpellWebLauncher = new RSCustomInterface();



