var CookieManager={set:function(_1,_2){
var _3=new Date();
_3.setTime(_3.getTime()+(30*24*60*60*1000));
var _4="; expires="+_3.toGMTString();
document.cookie=_1+"="+escape(_2)+_4;
},get:function(_5){
var dc=document.cookie;
var _7=_5+"=";
var _8=dc.indexOf("; "+_7);
if(_8==-1){
_8=dc.indexOf(_7);
if(_8!==0){
return null;
}
}else{
_8+=2;
}
var _9=document.cookie.indexOf(";",_8);
if(_9==-1){
_9=dc.length;
}
return unescape(dc.substring(_8+_7.length,_9));
},erase:function(_a){
var _b=new Date(2000,1,1,19,30,30);
document.cookie=_a+"=; expires="+_b.toGMTString();
}};
CookieManager.setCookiePair=function(_c,_d,_e){
var _f,end;
var _11=CookieManager.get(_c);
var _12=[_d,"@",_e,"#"].join("");
function trimEntry(s){
var a=s.split(",");
return a.slice(3).join(",");
}
if(!_11){
CookieManager.set(_c,_12);
}else{
_f=_11.search(eval("/(^|#)"+_d+"@/"));
if(_f===-1){
_11+=_12;
}else{
if(_11.charAt(_f)==="#"){
_f+=1;
}
end=_11.indexOf("#",_f);
_11=_11.replace(_11.substring(_f,end+1),_12);
}
while(_11.length>600){
_11=trimEntry(_11);
}
CookieManager.set(_c,_11);
}
};
CookieManager.getCookiePair=function(_15,key){
var _17=CookieManager.get(_15);
if(!_17){
return null;
}
var _18=_17.search(eval("/(^|#)"+key+"@/"));
if(_18===-1){
return null;
}
var end=_17.indexOf("#",_18+1);
var s=_17.substring(_18,end);
return s.split("@")[1];
};

var dFirstTime=true;
function isSpecial(c){
if(c=="."||c=="/"||c=="^"||c=="~"){
return true;
}
return false;
}
function splitSpecial(s){
var m=s.match(/((([a-zA-Z]+[\.\^~\/]*)*[a-zA-Z]+)|([^a-zA-Z])+)/g);
if(!m){
return [];
}
return m;
}
function diffStr(_4,_5){
DiffData=function(_6,_7,_8){
this.word=_6;
this.type=_7;
this.pos=_8;
};
function diff(o,n){
var ns={};
var os={};
var i;
try{
for(i=0;i<n.length;++i){
if(!ns.hasOwnProperty(n[i])){
ns[n[i]]={rows:[],o:null};
}
ns[n[i]].rows.push(i);
}
for(i=0;i<o.length;++i){
if(!os.hasOwnProperty(o[i])){
os[o[i]]={rows:[],n:null};
}
os[o[i]].rows.push(i);
}
for(i in ns){
if(ns[i].rows.length==1&&os.hasOwnProperty(i)&&os[i].rows.length==1){
n[ns[i].rows[0]]={text:n[ns[i].rows[0]],row:os[i].rows[0]};
o[os[i].rows[0]]={text:o[os[i].rows[0]],row:ns[i].rows[0]};
}
}
for(i=0;i<n.length-1;++i){
if(n[i].text&&!(n[i+1].text)&&(!(o[n[i].row+1])||!(o[n[i].row+1].text))&&n[i+1]==o[n[i].row+1]){
n[i+1]={text:n[i+1],row:n[i].row+1};
o[n[i].row+1]={text:o[n[i].row+1],row:i+1};
}
}
for(i=n.length-1;i>0;--i){
if(n[i].text&&!(n[i-1].text)&&(!(o[n[i].row-1])||!(o[n[i].row-1].text))&&n[i-1]==o[n[i].row-1]){
n[i-1]={text:n[i-1],row:n[i].row-1};
o[n[i].row-1]={text:o[n[i].row-1],row:i-1};
}
}
return {o:o,n:n};
}
catch(ex){
logger.error("diff(javascript) "+ex);
}
}
function diffArray(o,n){
try{
return diff(extend(["x"," "],splitSpecial(o)),extend(["x"," "],splitSpecial(n)));
}
catch(ex){
logger.error("diffArray(javascript) "+ex);
}
}
try{
return diffArray(_4,_5);
}
catch(e){
logger.error(e);
}
}

var QuillUtil={lang:"hindi",getLangLegacy:function(){
if(window.defaultLang){
return window.defaultLang;
}
var _1;
try{
_1=window.location.pathname.match(/\/[a-z]+/g);
if(window.location.pathname.slice(-1)==="/"){
return _1[_1.length-1].substring(1);
}
return _1[_1.length-2].substring(1);
}
catch(e){
return "hindi";
}
},getLang:function(){
return QuillUtil.lang;
},setLang:function(_2){
QuillUtil.lang=_2;
},isValidEmailID:function(_3){
var _4=_3.match(/^[0-9a-zA-Z_\.-]+@([0-9a-zA-Z_-]+\.)+[a-zA-Z0-9_-]+$/);
return (_4!==null);
},isValidEmailIDGroup:function(_5){
var _6=_5.split(/[\s\+,]+/);
var _7;
for(var i=0;i<_6.length;++i){
logger.info(_6[i]);
_7=_6[i].match(/^[0-9a-zA-Z_\.-]+@([0-9a-zA-Z_-]+\.)+[a-zA-Z0-9_-]+$/);
if(_7===null){
return false;
}
}
return true;
},getRandom:function(_9){
var _a=Math.random()-0.5;
_a=_a*Math.pow(2,32);
return Math.floor(_a);
},getBrowser:function(){
var ua=window.navigator.userAgent.toLowerCase();
var _c;
var _d;
var _e;
if(ua.indexOf("opera")!=-1){
return "opera";
}else{
if(ua.indexOf("safari")!=-1){
return "safari";
}else{
if(ua.indexOf("msie 6.0")!=-1||ua.indexOf("msie 7.0")!=-1){
return "ie";
}else{
if(ua.indexOf("mozilla")!=-1){
_d=ua.indexOf("gecko/");
if(_d==-1){
return "oldmoz";
}
_e=ua.indexOf(" ",_d);
if(_e==-1){
_e=ua.length;
}
_c=parseInt(ua.substring(_d+6,_e),10);
if(_c<20051107){
return "oldmoz";
}
return "moz";
}
}
}
}
return "unknown";
},isBlank:function(_f){
if(_f.match(/^\s*$/)){
return true;
}
return false;
},isValidURL:function(_10){
if(_10.match(/^http:\/\/.*$/)){
return true;
}
return false;
},isAlpha:function(_11){
if(_11.match(/^[a-zA-Z]$/)){
return true;
}
return false;
},getServerAddr:function(){
if(document.domain){
return ("http://"+document.domain);
}else{
return quillConfig.server.location;
}
},getServerPath:function(){
var _12=window.location.pathname.match(/.*\//g);
return ["http://",window.location.host,_12].join("");
},isValidAlpha:function(_13){
if(_13.match(/[a-zA-Z]+/)){
return true;
}
return false;
},getMeta:function(){
var d=document.getElementsByTagName("meta");
var ret={};
var i;
if(!d||!d.length){
logger.error("Could not read meta tags.");
}else{
for(i=0;i<d.length;i++){
if(d[i].name){
ret[d[i].name]=d[i].content;
}
}
}
return ret;
},makeURL:function(_17,req){
var _19="";
for(var i in req){
_19+=[i,"=",encodeURIComponent(req[i])].join("");
}
if(_19){
return [_17,"?",_19].join("");
}else{
return _17;
}
},setupLogging:function(){
try{
try{
if(console.log){
logger={log:console.log,debug:console.debug,info:console.info,warn:console.warn,error:console.error};
}
}
catch(e){
if(logDebug){
logger={log:log,debug:logDebug,info:logDebug,warn:logWarning,error:logError};
}
}
}
catch(e){
logger={log:function(){
},debug:function(){
},info:function(){
},warn:function(){
},error:function(){
}};
}
},setCharEncoding:function(_1b){
if(document.defaultCharset){
document.defaultCharset=_1b;
}
if(document.charset){
document.charset=_1b;
}
}};
getNodeText=function(){
var n=SPAN();
if(typeof (n.textContent)!=="undefined"){
return function(_1d){
return _1d.textContent;
};
}else{
if(typeof (n.innerText)!=="undefined"){
return function(_1e){
return _1e.innerText;
};
}else{
return function(_1f){
return _1f.text;
};
}
}
}();
setNodeText=function(){
var n=SPAN();
if(typeof (n.textContent)!=="undefined"){
return function(_21,_22){
_21.textContent=_22;
};
}else{
if(typeof (n.innerText)!=="undefined"){
return function(_23,_24){
_23.innerText=_24;
};
}else{
return function(_25,_26){
_25.text=_26;
};
}
}
}();
function getFontSize(){
if(quillConfig.fontSizes&&quillConfig.fontSizes.hasOwnProperty(QuillUtil.getLang())){
return quillConfig.fontSizes[QuillUtil.getLang()];
}else{
return ["12px","20px"];
}
}
function addStyleSheet(doc,url){
var _29=doc.createElement("LINK");
_29.rel="stylesheet";
_29.type="text/css";
_29.href=url;
var _2a=doc.getElementsByTagName("head")[0];
if(_2a){
_2a.appendChild(_29);
}else{
logger.error("addStyleSheet: document.head not found for",doc);
}
}
function enableLogPane(){
var _2b=getElement("logpane");
logger.info=function(){
var s="";
for(var i=0;i<arguments.length;i++){
s+=arguments[i]+" ";
}
_2b.appendChild(DIV(s));
if(_2b.scrollHeight>_2b.clientHeight){
_2b.scrollTop=_2b.scrollHeight-_2b.clientHeight;
}
};
}
function getCursorPosition(_2e){
var _2f;
if(typeof (_2e.selectionStart)!=="undefined"){
_2f=_2e.selectionEnd;
}else{
if(document.selection){
_2e.focus();
var sel=document.selection.createRange();
var _31=sel.duplicate();
_31.collapse(true);
var _32=_31.moveStart("character",-1000);
return -_32;
}
}
return _2f;
}
function setCursorPosition(_33,pos){
if(typeof (_33.selectionStart)!=="undefined"){
_33.selectionStart=pos;
_33.selectionEnd=pos;
}else{
if(document.selection){
_33.focus();
var _35=_33.createTextRange();
_35.collapse(true);
_35.moveStart("character",pos);
_35.moveEnd("character",pos);
_35.select();
}
}
}
iframePos=function(){
return elementPosition("indicOutput");
};

WordMapping=function(_1,_2,_3,_4,_5){
this.engWord=_1;
this.tWordList=_2;
this.preferred=_3;
this.itrans=_4;
this.optmap=_5;
};
var WordMap=function WordMap(_6){
this.localCache=_6;
this.wordMap={};
for(var i in quillConfig.supportedLanguages){
this.wordMap[i]={};
}
};
WordMap.prototype.responseFunc=function(_8,_9,o,_b,r){
var a=[];
var _e;
var i;
var itr=true;
var _11=false;
var _12;
var _13;
try{
_e=eval("("+r.responseText+")");
_12=CookieManager.getCookiePair(_8+"_prefs",_9);
_13=quillConfig.client.maxWordOptions;
if(_e.twords[0].options.length<_13){
_13=_e.twords[0].options.length;
}
for(i=0;i<_13;i++){
if(_e.twords[0].options[i]===_e.itrans){
itr=false;
}
a.push(_e.twords[0].options[i]);
}
var _14=_e.twords[0].optmap;
if(!itr){
_e.itrans=null;
}else{
a=a.splice(0,quillConfig.client.maxWordOptions-1);
if(_e.inString.slice(1).match(/[A-Z]+/)){
a.unshift(_e.itrans);
}else{
a.push(_e.itrans);
}
}
if(a.length<1){
logger.error("goofup in responseFunc, len(a) < 1");
return;
}
if(_12!=null){
for(i=0;i<a.length;i++){
if(a[i]===_12){
_11=true;
break;
}
}
}
if(!_11){
if(_9.match(/[\.\/~\^]/)){
o.wordMap[_8][_9]=new WordMapping(_9,[_e.itrans],_e.itrans,_e.itrans,_14);
}else{
o.wordMap[_8][_9]=new WordMapping(_9,a,a[0],_e.itrans,_14);
}
}else{
o.wordMap[_8][_9]=new WordMapping(_9,a,_12,_e.itrans,_14);
}
var _15=CookieManager.getCookiePair(_8+"_userMaps",_9);
if(_15){
_15=_15.split(",");
for(i=0;i<_15.length;i++){
if(_15[i]===_12){
o.wordMap[_8][_9].preferred=_12;
break;
}
}
o.wordMap[_8][_9].userMapping=_15;
}
_b(o.getMapping(_8,_9));
}
catch(e){
logger.error(e);
return;
}
};
WordMap.prototype.secondaryResp=function(_16,_17,o,_19,r){
try{
_19(o.getMapping(_16,_17));
}
catch(e){
logger.error(e);
return;
}
};
WordMap.prototype.getMapping=function(_1b,_1c){
if(_1b=="english"){
return (new WordMapping(_1c,[_1c],_1c));
}
var m=this.wordMap[_1b][_1c];
if(m&&m.engWord){
return m;
}else{
return null;
}
};
WordMap.prototype.getWordMapping=function(_1e,_1f,_20){
if(_1e=="english"){
_20(new WordMapping(_1f,[_1f],_1f));
return;
}
var _21=this.wordMap[_1e][_1f];
if(_21&&this.wordMap[_1e].hasOwnProperty(_1f)){
if(_21.def){
_21.def.addCallback(partial(this.secondaryResp,_1e,_1f,this,_20));
}else{
_20(this.getMapping(_1e,_1f));
}
return;
}
req={rand:QuillUtil.getRandom(),lang:_1e,inString:_1f};
var d=doSimpleXMLHttpRequest(QuillUtil.getServerAddr()+quillConfig.server.processWord,req);
d.addCallbacks(partial(this.responseFunc,_1e,_1f,this,_20),function(e){
logger.error("getWordMapping failed");
});
this.wordMap[_1e][_1f]={"def":d};
};
WordMap.prototype.setPreferredMapping=function(_24,_25,_26){
if(_24=="english"){
return;
}
var wm=this.wordMap[_24][_25];
wm.preferred=_26;
CookieManager.setCookiePair(_24+"_prefs",_25,_26);
};
WordMap.prototype.getAllOptions=function(_28,_29){
if(this.wordMap[_28][_29]){
return this.wordMap[_28][_29].tWordList;
}else{
return [];
}
};
WordMap.prototype.correctionRespFunc=function(_2a,_2b,_2c,r){
var val;
var _2f;
try{
val=eval("("+r.responseText+")");
_2f=this.wordMap[_2a][_2b].optmap;
if(_2f){
for(var i in val.optmap){
if(val.optmap.hasOwnProperty(i)){
if(!_2f[i]){
_2f[i]=val.optmap[i];
}
}
}
}
_2c(val.options,val.optmap);
}
catch(e){
logger.error(e);
}
};
WordMap.prototype.getCorrections=function(_31,_32,_33,pos,_35,loc){
req={rand:QuillUtil.getRandom(),lang:_31,currWord:_32.toString(),userInput:_33,pos:pos};
var d=doSimpleXMLHttpRequest(QuillUtil.getServerAddr()+"/quillpad_backend5/"+loc,req);
d.addCallbacks(method(this,partial(this.correctionRespFunc,_31,_33,_35)),function(e){
console.error("getCorrections failed");
});
};
WordMap.prototype.setUserMapping=function(_39,_3a,_3b){
var i;
var m=this.wordMap[_39][_3a];
for(i=0;i<m.tWordList.length;i++){
if(m.tWordList[i]===_3b){
return;
}
}
if(m.userMapping){
for(var i=0;i<m.userMapping.length;i++){
if(m.userMapping[i]===_3b){
return;
}
}
m.userMapping.unshift(_3b);
}else{
m.userMapping=[_3b];
}
CookieManager.setCookiePair(_39+"_userMaps",_3a,m.userMapping.toString());
};
WordMap.prototype.setUserMappingList=function(_3e,_3f,_40){
var m=this.wordMap[_3e][_3f];
m.userMapping=_40;
CookieManager.setCookiePair(_3e+"_userMaps",_3f,_40.toString());
};

function OptionsManager(_1){
this.dOptions=getElement(_1);
this.chosenOption=null;
this.numOptions=0;
this.defaultHighlightColor="#C0DAFF";
this.defaultBgColor="#FFFFFF";
this.specialBgColor="#FFEFF0";
this.specialHighlightColor="#FFBFC2";
this.sig=null;
this.mapping=new WordMapping();
this.dropDownTable=null;
}
OptionsManager.prototype.cleanup=function(){
this.clearOptions();
if(this.dropDownTable){
this.cleanupDropDown();
}
};
OptionsManager.prototype.clearOptions=function(){
var t=TABLE(null,TBODY(null,TR(null,[])));
setElementClass(t,"optionsTable");
t.style.background="white";
if(this.dOptions.childNodes.length===0){
this.dOptions.appendChild(t);
}else{
swapDOM(this.dOptions.childNodes[0],t);
}
this.numOptions=0;
};
OptionsManager.prototype.saveUserMapping=function(){
if(this.mapping.preferred&&this.mapping.engWord){
wm.setUserMapping(QuillUtil.getLang(),this.mapping.engWord,this.mapping.preferred);
wm.setPreferredMapping(QuillUtil.getLang(),this.mapping.engWord,this.mapping.preferred);
}
};
OptionsManager.prototype.setOptions=function(_3,_4,_5,_6){
if(this.sig){
disconnect(this.sig);
this.sig=null;
}
if(!_3.engWord){
this.cleanup();
}
this.numOptions=_3.tWordList.length;
this.mapping=_3;
var _7=[];
var _8=null;
var i;
var _a;
var d;
this.userOptionIdx=null;
if(_5){
this.highlightColor=_5;
}else{
this.highlightColor=this.defaultHighlightColor;
}
if(_4){
this.bgColor=_4;
}else{
this.bgColor=this.defaultBgColor;
}
if(_3.userMapping){
this.numOptions+=1;
this.userOptionIdx=0;
for(i=0;i<_3.userMapping.length;i++){
if(_3.userMapping[i]==_3.preferred){
_8=this.numOptions;
this.userOptionIdx=i;
}
}
}
_a=100/this.numOptions+"%";
if(_6){
_7.push(TD({"style":{"width":_a},"class":"options"},_3.tWordList[0],"   ",A({"href":"correct.html","target":"_blank"},"(Why am I not getting corrections?)")));
if(!_8&&_3.tWordList[0]==_3.preferred){
_8=1;
}
}else{
for(i=0;i<_3.tWordList.length;i++){
if(!_8&&_3.tWordList[i]==_3.preferred){
_8=i+1;
}
_7.push(TD({"style":{"width":_a},"class":"options"},_3.tWordList[i]));
}
}
if(_3.userMapping){
var _c=TD({"style":{"width":_a},"class":"options"},"");
_c.style.background=this.specialBgColor;
if(this.mapping.userMapping.length>1){
_c.innerHTML=[_3.userMapping[this.userOptionIdx],"&nbsp;","&darr;"].join("");
}else{
_c.innerHTML=[_3.userMapping[this.userOptionIdx],"&nbsp;"].join("");
}
_7.push(_c);
}
var t=TABLE(null,TBODY(null,TR(null,_7)));
this.sig=connect(t,"onclick",this,this.onOptionClick);
setElementClass(t,"optionsTable");
t.style.background=this.bgColor;
if(this.dOptions.childNodes.length===0){
this.dOptions.appendChild(t);
}else{
swapDOM(this.dOptions.childNodes[0],t);
}
this.dOptions.style.borderColor=this.highlightColor;
this.chosenOption=null;
this.chooseOption(_8);
};
OptionsManager.prototype.onOptionClick=function(_e){
var td=_e.target();
var s=scrapeText(td);
var i;
for(i=0;i<this.mapping.tWordList.length;i++){
if(s===this.mapping.tWordList[i]){
this.chooseOption(i+1);
tpengine.replaceWordAtCursor(this.getChosenWord());
return;
}
}
if(this.mapping.userMapping){
this.chooseOption(this.numOptions);
tpengine.replaceWordAtCursor(this.getChosenWord());
this.showDropDown(td);
}
};
OptionsManager.prototype.chooseOption=function(pos){
logger.info("chooseOption",pos);
if(pos<1||pos>this.numOptions){
return;
}
if(pos==this.chosenOption){
return;
}
if(this.dropDownTable){
this.cleanupDropDown();
}
var tr;
try{
tr=this.dOptions.childNodes[0].childNodes[0].childNodes[0];
if(this.chosenOption){
if(this.chosenOption===this.numOptions&&this.mapping.userMapping){
tr.childNodes[this.chosenOption-1].style.backgroundColor=this.specialBgColor;
}else{
tr.childNodes[this.chosenOption-1].style.backgroundColor=this.bgColor;
}
tr.childNodes[this.chosenOption-1].style.fontWeight="";
}
if(pos===this.numOptions&&this.mapping.userMapping){
tr.childNodes[pos-1].style.backgroundColor=this.specialHighlightColor;
}else{
tr.childNodes[pos-1].style.backgroundColor=this.highlightColor;
}
tr.childNodes[pos-1].style.fontWeight="bold";
this.chosenOption=pos;
}
catch(e){
logger.error("chooseOption:",e);
}
};
OptionsManager.prototype.chooseNextOption=function(){
var tr=this.dOptions.childNodes[0].childNodes[0].childNodes[0];
if(this.chosenOption==tr.childNodes.length){
this.chooseOption(1);
}else{
this.chooseOption(this.chosenOption+1);
}
};
OptionsManager.prototype.choosePrevOption=function(){
var tr=this.dOptions.childNodes[0].childNodes[0].childNodes[0];
if(this.chosenOption==1){
this.chooseOption(tr.childNodes.length);
}else{
this.chooseOption(this.chosenOption-1);
}
};
OptionsManager.prototype.getChosenWord=function(){
try{
if(this.numOptions<=0){
return null;
}else{
if(this.mapping.userMapping&&this.chosenOption===this.numOptions){
this.mapping.preferred=this.mapping.userMapping[this.userOptionIdx];
}else{
this.mapping.preferred=this.mapping.tWordList[this.chosenOption-1];
}
return this.mapping;
}
}
catch(e){
return null;
}
};
OptionsManager.prototype.showDropDown=function(src){
logger.info("table is",this.dropDownTable);
if(this.dropDownTable){
this.cleanupDropDown();
return;
}
var _17=[];
var td;
for(var i=0;i<this.mapping.userMapping.length;i++){
if(i!==this.userOptionIdx){
td=TD(null,this.mapping.userMapping[i]);
setElementClass(td,"dropDownTD");
_17.push(TR(null,td));
}
}
var t=TABLE(null,TBODY(null,_17));
var pos=elementPosition(src);
var dim=elementDimensions(src);
var _1d=document.getElementsByTagName("body")[0];
pos.y+=dim.h+5;
setElementPosition(t,pos);
t.style.width=dim.w+"px";
t.style.height="auto";
t.style.position="absolute";
t.style.background=this.specialBgColor;
t.style.display="block";
this.dropDownTable=t;
this.sigDropDown=connect(t,"onclick",this,this.clickDropDown);
this.sigMouseOver=connect(t,"onmouseover",this,this.onMouseOver);
this.sigMouseOut=connect(t,"onmousfout",this,this.onMouseOut);
_1d.appendChild(t);
};
OptionsManager.prototype.onMouseOver=function(evt){
var td=evt.target();
if(td.nodeName.toLowerCase()!=="td"){
return;
}
td.style.background=this.specialHighlightColor;
};
OptionsManager.prototype.onMouseOut=function(evt){
var td=evt.target();
if(td.nodeName.toLowerCase()!=="td"){
return;
}
td.style.background=this.specialBgColor;
};
OptionsManager.prototype.cleanupDropDown=function(){
removeElement(this.dropDownTable);
this.dropDownTable=null;
disconnect(this.sigDropDown);
if(this.sigMouseOver){
disconnect(this.sigMouseOver);
disconnect(this.sigMouseOut);
}
};
OptionsManager.prototype.clickDropDown=function(evt){
var t=scrapeText(evt.target());
var tr;
var a=[t,this.mapping.userMapping[this.userOptionIdx]];
for(var i=1;i<this.mapping.userMapping.length;i++){
if(this.mapping.userMapping[i]===t){
this.mapping.preferred=t;
tr=this.dOptions.childNodes[0].childNodes[0].childNodes[0];
tr.childNodes[this.numOptions-1].innerHTML=[t,"&nbsp;","&darr;"].join("");
}else{
a.push(this.mapping.userMapping[i]);
}
}
tpengine.replaceWordAtCursor(this.mapping);
this.cleanupDropDown();
this.mapping.userMapping=a;
wm.setUserMappingList(QuillUtil.getLang(),this.mapping.engWord,a);
};

var TextEngine=function(_1){
var _2=getElement(_1);
this.doc=_2.contentDocument?_2.contentDocument:_2.contentWindow.document;
this.win=_2.contentWindow;
this.doc.designMode="on";
if(this.doc.body){
this.displayArea=this.doc.body;
}else{
this.doc.write("<head></head><body></body>");
this.doc.close();
this.displayArea=this.doc.body;
}
addStyleSheet(this.doc,QuillUtil.getServerPath()+"css/ifr.css");
this.setFontSizes();
ifrDoc=this.doc;
this.tooltip=new ToolTip("wordTip","wordTD","optTD","editorInput",this);
this.menu=new OptMenu();
connect(this.doc,"onkeypress",this,this.onKeyPress);
connect(this.doc,"onkeydown",this,this.onKeyDown);
connect(this.doc,"onkeyup",this,this.onKeyUp);
connect(this.doc,"onclick",this,this.showOptions);
if(QuillUtil.getBrowser()==="moz"){
connect(this.doc,"onblur",this,this.onBlur);
this.xlitText=this.xlitTextFF;
}else{
connect(this.win,"onblur",this,this.onBlur);
connect(this.displayArea,"onpaste",this,this.onPaste);
connect(this.displayArea,"oncut",this,this.onCut);
}
this.callback=method(this,this.callbackFunc);
};
TextEngine.prototype.setFontSizes=function(){
var _3=getFontSize();
this.doc.body.style.fontSize=_3[0];
this.doc.body.style.lineHeight=_3[1];
var _4=getElement("indicDic");
if(_4){
_4.style.fontSize=_3[0];
_4.style.lineHeight=_3[1];
}
var _5=getElement("cOptions");
if(_5){
_5.style.fontSize=_3[0];
}
var _6=getElement("langUnicode");
if(_6){
_6.style.fontSize=_3[0];
}
var ki=getElement("keyInput");
if(ki){
ki.style.lineHeight=_3[1];
}
};
TextEngine.prototype.onPaste=function(_8){
var _9=window.clipboardData.getData("Text");
var _a=this.getSelection();
var _b=this;
this.xlitText(_9,function(_c){
if(_a.atAnchorStart){
if(_a.anchorNode){
_b.setCursorBeforeWidget(_a.anchorNode);
}
_b.doc.selection.createRange().pasteHTML(_c);
}else{
if(_a.anchorNode){
_b.setCursorAfterWidget(_a.anchorNode);
}
_b.doc.selection.createRange().pasteHTML(_c);
}
});
_8.stop();
};
TextEngine.prototype.setText=function(_d){
var _e=this;
this.xlitText(_d,function(_f){
logger.info("got callback",_f);
_e.displayArea.innerHTML=_f;
});
};
TextEngine.prototype.xlitTextFF=function(_10,_11){
var _12=splitSpecial(_10);
var _13=_12.length;
function process(_14){
var s="<span>";
var i,_17;
for(i=0;i<_14.length;i++){
switch(_14.charAt(i)){
case " ":
_17=0;
while(i<_14.length&&_14.charAt(i)===" "){
_17+=1;
s+="&nbsp;";
i++;
}
if(_17>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
case "\n":
s=[s,"</span><br><span>"].join("");
break;
default:
s=[s,_14.charAt(i)].join("");
}
}
return s+"</span>";
}
function callbk(idx,m){
_13-=1;
_12[idx]=["<span word=\"",m.engWord,"\" lang=\"",QuillUtil.getLang(),"\">",m.preferred,"</span>"].join("");
if(_13<=0){
_11(_12.join("")+"<br _moz_editor_bogus_node=\"TRUE\" _moz_dirty=\"\"/>");
}
}
for(var i=0;i<_12.length;i++){
if(_12[i].match(/[a-zA-Z]/)){
wm.getWordMapping(QuillUtil.getLang(),_12[i],partial(callbk,i));
}else{
_12[i]=process(_12[i]);
_13-=1;
if(_13<=0){
_11(_12.join(""));
}
}
}
};
TextEngine.prototype.xlitText=function(_1b,_1c){
var _1d=splitSpecial(_1b);
var _1e=_1d.length;
function process(_1f){
var s="<span>";
var i,_22;
for(i=0;i<_1f.length;i++){
switch(_1f.charAt(i)){
case " ":
_22=0;
while(i<_1f.length&&_1f.charAt(i)===" "){
_22+=1;
s+="&nbsp;";
i++;
}
if(_22>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
case "\n":
s=[s,"</span><br><span>"].join("");
break;
default:
s=[s,_1f.charAt(i)].join("");
}
}
s+="</span>";
return s;
}
function callbk(idx,m){
_1e-=1;
_1d[idx]=["<span word=\"",m.engWord,"\" lang=\"",QuillUtil.getLang(),"\">",m.preferred,"</span>"].join("");
if(_1e<=0){
_1c(_1d.join(""));
}
}
for(var i=0;i<_1d.length;i++){
if(_1d[i].match(/[a-zA-Z]/)){
wm.getWordMapping(QuillUtil.getLang(),_1d[i],partial(callbk,i));
}else{
_1d[i]=process(_1d[i]);
_1e-=1;
if(_1e<=0){
_1c(_1d.join(""));
}
}
}
};
TextEngine.prototype.onCut=function(evt){
window.clipboardData.setData("Text",this.getTextSelection());
this.deleteSelection(this.getSelection(),evt);
};
TextEngine.prototype.onBlur=function(evt){
};
TextEngine.prototype.hideMenu=function(){
if(this.menu.enabled()){
this.menu.cleanup();
}
};
TextEngine.prototype.getSelection=function(){
var _28;
var _29;
var _2a;
var _2b;
var _2c=this;
var sel;
var ret={};
if(this.win.getSelection){
sel=this.win.getSelection();
if(sel.anchorNode.nodeName==="BODY"){
if(sel.anchorOffset===0){
ret.anchorNode=this.displayArea.childNodes[0];
}else{
ret.anchorNode=this.displayArea.childNodes[sel.anchorOffset-1];
}
ret.atAnchorEnd=true;
}else{
if(sel.anchorNode.parentNode&&sel.anchorNode.parentNode.nodeName!=="BODY"){
ret.anchorNode=sel.anchorNode.parentNode;
if(sel.anchorOffset===sel.anchorNode.nodeValue.length){
ret.atAnchorEnd=true;
}
}else{
ret.anchorNode=sel.anchorNode;
if(sel.anchorOffset===sel.anchorNode.nodeValue.length){
ret.atAnchorEnd=true;
}
}
if(sel.anchorOffset===0){
ret.atAnchorStart=true;
}
}
ret.anchorOffset=sel.anchorOffset;
ret.focusNode=sel.focusNode;
ret.focusOffset=sel.focusOffset;
ret.isCollapsed=sel.isCollapsed;
logger.info(ret);
return ret;
}else{
_28=this.doc.selection.createRange().duplicate();
_28.collapse(true);
_29=this.doc.selection.createRange().duplicate();
_29.collapse(false);
_28.pasteHTML("<span id=\"fuquaSpan1\"></span>");
_2a=this.doc.getElementById("fuquaSpan1");
ret.anchorNode=_2a.parentNode;
try{
if(_2a.previousSibling&&_2a.previousSibling.nodeName==="#text"){
ret.anchorOffset=_2a.previousSibling.nodeValue.length;
}
}
catch(e){
if(e.message==="Invalid Argument."){
ret.anchorOffset=0;
}
}
if(!_2a.nextSibling||_2a.parentNode.nodeName==="BODY"){
ret.atAnchorEnd=true;
}
if(!_2a.previousSibling){
ret.atAnchorStart=true;
}
if(_28.compareEndPoints("StartToStart",_29)===0){
ret.isCollapsed=true;
withDocument(this.doc,function(){
removeElement(_2a);
});
return ret;
}else{
ret.isCollapsed=false;
}
_29.pasteHTML("<span id=\"fuquaSpan2\"></span>");
_2b=this.doc.getElementById("fuquaSpan2");
ret.focusNode=_2b.parentNode;
if(_2b.previousSibling&&_2b.previousSibling.nodeName==="#text"){
ret.focusOffset=_2b.previousSibling.nodeValue.length;
}
if(!_2b.previousSibling||_2b.parentNode.nodeName==="BODY"){
ret.atFocusStart=true;
}
withDocument(this.doc,function(){
removeElement(_2a);
});
withDocument(this.doc,function(){
removeElement(_2b);
});
return ret;
}
};
TextEngine.prototype.addNewline=function(_2f){
var n=withDocument(this.doc,BR);
this.add(n,_2f);
return n;
};
TextEngine.prototype.setCursor=function(_31,_32){
var _33;
var sel;
if(this.win.getSelection){
_33=this.doc.createRange();
_33.selectNode(_32);
_33.collapse(_31);
sel=this.win.getSelection();
sel.removeAllRanges();
sel.addRange(_33);
}else{
if(this.doc.selection){
logger.info("where",_31,_32);
_33=this.displayArea.createTextRange();
_33.moveToElementText(_32);
_33.collapse(_31);
_33.select();
}
}
};
TextEngine.prototype.setCursorBeforeWidget=partial(TextEngine.prototype.setCursor,true);
TextEngine.prototype.setCursorAfterWidget=partial(TextEngine.prototype.setCursor,false);
TextEngine.prototype.getTextSelection=function(){
if(this.win.getSelection){
return this.win.getSelection().toString();
}else{
return this.doc.selection.createRange().text;
}
};
TextEngine.prototype.getWidgetAtCursor=function(){
var n;
var sel;
var _37;
var _38;
var _39;
if(this.win.getSelection){
sel=this.win.getSelection();
n=sel.anchorNode;
if(n.nodeName.toUpperCase()==="BODY"){
_38=sel.anchorOffset;
if(_38>0){
_38-=1;
}
n=this.displayArea.childNodes[_38];
}else{
if(n.parentNode&&n.parentNode.nodeName.toUpperCase()==="BODY"){
return n;
}
return n.parentNode;
}
return n;
}else{
_37=this.doc.selection.createRange().duplicate();
_37.collapse(true);
_37.pasteHTML("<span id=\"fuquaSpan\"></span>");
_39=this.doc.getElementById("fuquaSpan");
if(_39.parentNode&&_39.parentNode.nodeName!=="BODY"){
n=_39.parentNode;
}else{
n=_39.previousSibling;
}
withDocument(this.doc,function(){
removeElement(_39);
});
return n;
}
return null;
};
TextEngine.prototype.showOptions=function(evt){
var tgt=evt.target();
var _3c;
var mgr;
logger.info("got ShowOptions");
if(this.menu.enabled()){
this.menu.cleanup();
}
this.tooltip.hide();
if(!tgt||tgt===this.displayArea){
return;
}
_3c=this.getWidgetContent(tgt);
if(_3c[0]!=="word"){
return;
}
if(evt.modifier().ctrl||evt.modifier().alt){
evt.stop();
this.tooltip.editWord(tgt,_3c[1]);
}else{
this.menu.update(tgt,wm.getMapping(_3c[2],_3c[1]));
}
};
TextEngine.prototype.getWidgetContent=function(_3e){
var c=getNodeAttribute(_3e,"word");
if(c){
return ["word",c,getNodeAttribute(_3e,"lang")];
}
return ["",""];
};
TextEngine.prototype.addText=function(_40,_41,_42,_43){
var sp=withDocument(this.doc,function(){
var s=SPAN(_42);
setElementClass(s,"spanDispArea");
setNodeAttribute(s,"word",_41);
setNodeAttribute(s,"length",_41.length);
setNodeAttribute(s,"lang",_43);
return s;
});
var _46=quillConfig.fonts[_43];
if(_46){
sp.style.fontFamily=_46+",'Arial Unicode MS',Arial, Verdana, Helvetica,sans-serif";
}else{
sp.style.fontFamily="Arial, Verdana, Helvetica,sans-serif";
}
this.add(sp,_40);
return sp;
};
TextEngine.prototype.nuke=function(sel){
function removeRecurse(_48,_49){
if(!_48){
return;
}
if(_48==_49){
withDocument(this.doc,partial(removeElement,_48));
}else{
removeRecurse(_48.nextSibling,_49);
withDocument(this.doc,partial(removeElement,_48));
}
}
removeRecurse(sel.anchorNode,sel.focusNode);
};
TextEngine.prototype.replaceText=function(n,_4b,_4c){
if(n){
setNodeText(n,_4c);
}else{
logger.warn("Tried to replace non-existent widget at",n,_4b,_4c);
}
};
TextEngine.prototype.add=function(_4d,_4e){
this.displayArea.insertBefore(_4d,_4e);
};
TextEngine.prototype.addTextNode=function(_4f,_50){
var n=this.doc.createTextNode(_4f);
this.add(n,_50);
return n;
};
TextEngine.prototype.addSpan=function(_52,_53){
var t=withDocument(this.doc,partial(SPAN,_52));
if(_52===" "){
t.innerHTML="&nbsp;";
}
this.add(t,_53);
return t;
};
TextEngine.prototype.remove=function(_55){
if(!_55){
logger.warn("Tried to remove non-existent widget",_55);
}else{
removeElement(_55);
}
};
TextEngine.prototype.getText=function(){
var i;
var txt="";
var ret="";
for(i=0;i<this.displayArea.childNodes.length;i++){
txt=this.displayArea.childNodes[i].innerText;
if(txt){
ret+=txt;
}else{
txt=this.displayArea.childNodes[i].textContent;
if(txt){
ret+=txt;
}else{
if(this.displayArea.childNodes[i].nodeName==="BR"){
ret+="\n";
}else{
txt=getNodeText(this.displayArea.childNodes[i]);
txt=txt?txt:this.displayArea.childNodes[i].data;
ret+=txt;
}
}
}
}
return ret;
};
TextEngine.prototype.getHTML=function(){
return this.displayArea.innerHTML;
};
TextEngine.prototype.getEnglishText=function(){
var i;
var _5a;
var ret="";
for(i=0;i<this.displayArea.childNodes.length;i++){
_5a=getNodeAttribute(this.displayArea.childNodes[i],"word");
if(_5a){
ret+=_5a;
}else{
if(this.displayArea.childNodes[i].nodeName==="BR"){
ret+="\n";
}else{
ret+=getNodeText(this.displayArea.childNodes[i]);
}
}
}
return ret;
};
TextEngine.prototype.doneEditing=function(_5c,_5d,_5e){
this.win.focus();
if(_5d){
this.remove(_5c);
}else{
if(_5e){
this.setCursorBeforeWidget(_5c);
}else{
this.setCursorAfterWidget(_5c);
}
}
};
TextEngine.prototype.forceFocus=function(){
this.win.focus();
};
TextEngine.prototype.onKeyUp=function(evt){
var s=evt.key().string;
var _61;
var c;
var mgr;
var sel;
switch(s){
case "KEY_ARROW_UP":
case "KEY_ARROW_DOWN":
case "KEY_PAGE_UP":
case "KEY_PAGE_DOWN":
case "KEY_HOME":
case "KEY_END":
this.hideMenu();
_61=this.getWidgetAtCursor();
c=this.getWidgetContent(_61);
if(c[0]==="word"){
mgr=new OptMgr(wm.getMapping(c[2],c[1]),getNodeText(_61));
this.tooltip.update(_61,c[1]);
this.tooltip.updateOpts(mgr.chosenOption,mgr.numOptions);
}else{
this.tooltip.hide();
}
break;
}
};
TextEngine.prototype.onKeyDown=function(evt){
var s=evt.key().string;
var _67;
var n;
var c;
var _6a;
var _6b;
var mgr,opt;
var sel;
switch(s){
case "KEY_ENTER":
this.tooltip.hide();
if(QuillUtil.getBrowser()==="moz"){
return;
}
_67=this.getWidgetAtCursor();
if(_67){
n=this.addNewline(_67.nextSibling);
}else{
n=this.addNewline(null);
}
var t=withDocument(this.doc,partial(SPAN,""));
t.innerHTML="&nbsp;";
this.add(t,n.nextSibling);
this.setCursorAfterWidget(t);
t.parentNode.removeChild(t);
this.setCursorAfterWidget(n);
evt.stop();
break;
case "KEY_BACKSPACE":
sel=this.getSelection();
_67=sel.anchorNode;
if(!sel.isCollapsed){
this.deleteSelection(sel,evt);
return;
}
c=this.getWidgetContent(_67);
if(sel.atAnchorStart){
if(QuillUtil.getBrowser()==="moz"){
this.setCursorBeforeWidget(sel.anchorNode);
}else{
if(c[0]==="word"){
this.setCursorBeforeWidget(sel.anchorNode);
}
}
return;
}
_6a=c[1].slice(0,-1);
if(c[0]==="word"){
evt.stop();
if(_6a<=0){
_6b=_67.prevSibling;
this.remove(_67);
this.tooltip.hide();
if(_6b){
this.setCursorAfterWidget(_6b);
}
}else{
setNodeAttribute(_67,"word",_6a);
this.tooltip.update(_67,_6a);
wm.getWordMapping(c[2],_6a,partial(this.callback,_67));
this.setCursorAfterWidget(_67);
}
}
break;
case "KEY_ESCAPE":
evt.stop();
break;
case "KEY_ARROW_RIGHT":
sel=this.getSelection();
if(sel.atAnchorEnd&&sel.anchorNode.nextSibling){
c=this.getWidgetContent(sel.anchorNode.nextSibling);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode.nextSibling,c[1]);
this.tooltip.setCursorAtStart();
evt.stop();
}
}else{
if(sel.atAnchorStart){
c=this.getWidgetContent(sel.anchorNode);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode,c[1]);
this.tooltip.setCursorAtStart();
evt.stop();
}
}
}
break;
case "KEY_ARROW_LEFT":
sel=this.getSelection();
if(sel.atAnchorEnd){
c=this.getWidgetContent(sel.anchorNode);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode,c[1]);
evt.stop();
}
}else{
if(sel.atAnchorStart&&sel.anchorNode.previousSibling){
c=this.getWidgetContent(sel.anchorNode.previousSibling);
if(c[0]==="word"){
this.tooltip.editWord(sel.anchorNode.previousSibling,c[1]);
evt.stop();
}
}
}
break;
case "KEY_DELETE":
sel=this.getSelection();
if(sel.isCollapsed){
this.deleteChar(sel,evt);
}else{
this.deleteSelection(sel,evt);
}
break;
case "KEY_TAB":
this.hideMenu();
_67=this.getWidgetAtCursor();
c=this.getWidgetContent(_67);
if(c[0]==="word"){
evt.stop();
mgr=new OptMgr(wm.getMapping(c[2],c[1]));
if(evt.modifier().shift){
opt=mgr.choosePrevious();
}else{
opt=mgr.chooseNext();
}
this.tooltip.updateOpts(opt[0],mgr.numOptions);
setNodeText(_67,opt[1]);
this.setCursorAfterWidget(_67);
}
break;
case "KEY_L":
if(evt.modifier().ctrl&&evt.modifier().shift){
if(QuillUtil.getLang()==="english"){
QuillUtil.setLang(QuillUtil.getLangLegacy());
toggleButtons();
}else{
QuillUtil.setLang("english");
toggleButtons();
}
evt.stop();
}
break;
}
};
TextEngine.prototype.deleteSelection=function(sel,evt){
if(sel.anchorNode.previousSibling){
this.setCursorAfterWidget(sel.anchorNode.previousSibling);
}
if(sel.focusNode.nextSibling){
this.setCursorBeforeWidget(sel.focusNode.nextSibling);
}
this.nuke(sel);
this.tooltip.hide();
evt.stop();
};
TextEngine.prototype.deleteChar=function(sel,evt){
var c;
if(sel.anchorNode.nodeName==="BODY"){
return;
}
logger.info(sel.anchorAtEnd);
var _75=this;
function modWord(_76,_77,_78,_79){
var _7a=_75;
if(_77.length<=1){
_75.remove(_76);
_75.tooltip.hide();
}else{
_77=_77.substring(1);
setNodeAttribute(_76,"word",_77);
logger.info("node is",_76);
_75.tooltip.update(_76,_77);
wm.getWordMapping(_78,_77,function(m){
_7a.callback(_76,m);
if(_79){
_7a.setCursorBeforeWidget(_76);
}
});
}
}
if(sel.atAnchorEnd){
c=this.getWidgetContent(sel.anchorNode.nextSibling);
logger.info("yo1",c);
if(c[0]==="word"){
evt.stop();
modWord(sel.anchorNode.nextSibling,c[1],c[2]);
}
}else{
if(sel.atAnchorStart){
c=this.getWidgetContent(sel.anchorNode);
if(c[0]==="word"){
evt.stop();
modWord(sel.anchorNode,c[1],c[2],true);
}
}else{
c=this.getWidgetContent(sel.anchorNode);
logger.info("yo2",c);
if(c[0]==="word"){
evt.stop();
}
}
}
};
TextEngine.prototype.callbackFunc=function(_7c,m){
var mgr=new OptMgr(m);
if(getNodeAttribute(_7c,"word")===m.engWord){
try{
this.replaceText(_7c,m.engWord,m.preferred);
}
catch(e){
logger.warn("Exception in callbackFunc",m,_7c,e);
}
}
if(this.tooltip.getWord()===m.engWord){
this.tooltip.updateOpts(mgr.chosenOption,mgr.numOptions);
}
};
TextEngine.prototype.onKeyPress=function(evt){
var s=evt.key().string;
var _81,_82;
var c;
var _84;
var t;
var mod=evt.modifier();
var sel=this.getSelection();
if(mod.alt||mod.ctrl){
return;
}
this.hideMenu();
if(s.match(/[a-zA-Z]/)){
_81=this.getWidgetAtCursor();
if(_81){
c=this.getWidgetContent(_81);
if(c[0]==="word"){
_84=c[1]+s;
setNodeAttribute(_81,"word",_84);
this.tooltip.update(_81,_84);
wm.getWordMapping(c[2],_84,partial(this.callback,_81));
this.setCursorAfterWidget(_81);
}else{
if(QuillUtil.getBrowser()==="moz"&&_81.nodeName==="BR"&&!_81.nextSibling){
_82=this.addText(_81,s," ",QuillUtil.getLang());
_82.innerHTML="&nbsp;";
}else{
_82=this.addText(_81.nextSibling,s," ",QuillUtil.getLang());
if(QuillUtil.getBrowser()==="moz"){
_82.innerHTML="&nbsp;";
}
}
this.setCursorAfterWidget(_82);
this.tooltip.update(_82,s);
wm.getWordMapping(QuillUtil.getLang(),s,partial(this.callback,_82));
}
}else{
_82=this.addText(null,s," ",QuillUtil.getLang());
this.setCursorAfterWidget(_82);
this.tooltip.update(_82,s);
wm.getWordMapping(QuillUtil.getLang(),s,partial(this.callback,_82));
}
evt.stop();
}else{
if(s.length!=0){
this.tooltip.hide();
_81=this.getWidgetAtCursor();
if(!_81){
t=this.addSpan(s,null);
evt.stop();
this.setCursorAfterWidget(t);
return;
}
c=this.getWidgetContent(_81);
if(c[0]==="word"){
if(sel.atAnchorStart){
if(sel.anchorNode.previousSibling){
c=this.getWidgetContent(sel.anchorNode.previousSibling);
if(c[0]==="word"){
t=this.addSpan(s,sel.anchorNode);
this.setCursorAfterWidget(t);
evt.stop();
}else{
if(QuillUtil.getBrowser()==="moz"){
this.setCursorAfterWidget(sel.anchorNode.previousSibling);
}else{
t=this.addSpan(s,sel.anchorNode);
this.setCursorAfterWidget(t);
evt.stop();
}
}
}else{
if(QuillUtil.getBrowser()==="moz"){
this.setCursorBeforeWidget(sel.anchorNode);
}else{
t=this.addSpan(s,sel.anchorNode);
this.setCursorAfterWidget(t);
evt.stop();
}
}
return;
}
if(QuillUtil.getBrowser()==="moz"){
this.setCursorAfterWidget(_81);
}else{
if(QuillUtil.getBrowser()==="ie"){
t=this.addSpan(s,_81.nextSibling);
this.setCursorAfterWidget(t);
evt.stop();
}
}
}
}
}
};
TextEngine.prototype.clearTextArea=function(){
var _88=this.displayArea.firstChild;
while(_88){
var _89=_88.nextSibling;
removeElement(_88);
_88=_89;
}
this.displayArea.focus();
};
TextEngine.prototype.setFocus=function(){
if(this.displayArea.lastChild){
this.setCursorAfterWidget(this.displayArea.lastChild);
}else{
this.displayArea.focus();
}
};
TextEngine.prototype.getSaveData=function(){
var i;
return serializeJSON(map(function(_8b){
var _8c=getNodeAttribute(_8b,"word");
if(_8c){
return ["word",_8c,getNodeText(_8b),getNodeAttribute(_8b,"lang")];
}else{
if(_8b.nodeName==="BR"){
return ["newline"];
}else{
if(_8b.nodeName==="#text"){
return (_8b.textContent?["text",_8b.textContent]:["text",_8b.data]);
}else{
if(_8b.nodeName==="SPAN"){
return ["text",getNodeText(_8b)];
}
}
}
}
},this.displayArea.childNodes));
};
TextEngine.prototype.load=function(_8d){
var arr=eval("("+_8d+")");
var i;
logger.info("load",arr);
function process(_90){
var s="";
var i,_93;
for(i=0;i<_90.length;i++){
switch(_90.charAt(i)){
case " ":
_93=0;
while(i<_90.length&&_90.charAt(i)===" "){
_93+=1;
s+="&nbsp;";
i++;
}
if(_93>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
default:
s=[s,_90.charAt(i)].join("");
}
}
return s;
}
var s;
for(i=0;i<arr.length;i++){
switch(arr[i][0]){
case "word":
wm.getWordMapping(arr[i][3],arr[i][1],function(){
});
this.addText(null,arr[i][1],arr[i][2],arr[i][3]);
break;
case "text":
s=withDocument(this.doc,SPAN);
setNodeText(s,arr[i][1]);
appendChildNodes(this.displayArea,s);
break;
case "newline":
this.addNewline(null);
break;
default:
logger.warn("Got unknown data in load",arr[i]);
}
}
};

function TwoPaneEngine(_1,_2,_3){
this.displayArea=getElement(_1);
this.inputArea=getElement(_2);
this.displayMgr=new ODisplayManager(this.displayArea);
this.optionsMgr=new OptionsManager(_3);
this.delay=400;
this.cursorDelay=200;
this.prevWordAtCursor="";
this.aDemo=getElement("aDemo");
this.spanSearchMsg=getElement("spanSearchMsg");
this.mode="edit";
this.prevCursorPos=null;
this.contentChangeTimer=null;
this.oldVal="";
this.contentChangeTimer=setInterval(method(this,"contentChecker"),this.delay);
this.sig=connect(this.inputArea,"onkeydown",this,this.inputOnKeyDown);
connect(this.inputArea,"onfocus",this,this.activateTimer);
connect(this.inputArea,"onblur",this,this.deactivateTimer);
connect(window,"onresize",this,this.onWindowResize);
this.posMap={};
}
TwoPaneEngine.prototype.onWindowResize=function(){
var _4=elementPosition("keyInput");
var _5=getViewportDimensions();
var _6=QuillUtil.getBrowser();
var _7=53;
if(_6=="moz"){
logger.info(window.scrollMaxY);
if(window.scrollMaxY<=0){
_7=_7-16;
}
logger.info("sub",_7);
var temp=_5.w-_4.x-_7;
this.inputArea.style.width=(_5.w-_4.x-_7)+"px";
}else{
if(_6=="ie"){
var temp=_5.w-_4.x-37;
if(temp>0){
this.inputArea.style.width=temp+"px";
}
}
}
var temp=elementDimensions("compose").w;
this.inputArea.style.width=temp-30+"px";
};
TwoPaneEngine.prototype.inputOnKeyDown=function(_8){
var n;
var _a;
var w;
var _c;
if(_8.key().string=="KEY_TAB"){
if(_8.modifier().shift){
this.optionsMgr.choosePrevOption();
}else{
this.optionsMgr.chooseNextOption();
}
w=this.optionsMgr.getChosenWord();
this.replaceWordAtCursor(w);
_8.stop();
}else{
if(_8.key().string=="KEY_Q"&&_8.modifier().alt){
this.makeCorrections();
_8.stop();
}else{
if(_8.modifier().alt){
n=parseInt(_8.key().string.substring(4,5));
if(n>=1&&n<=9){
this.optionsMgr.chooseOption(n);
this.replaceWordAtCursor(this.optionsMgr.getChosenWord());
_8.stop();
}
}else{
if(_8.key().string=="KEY_SPACEBAR"||_8.key().string=="KEY_ENTER"){
if(this.mode==="correction"){
this.mode="edit";
_a=this.getCursorPosition();
while(_a<this.inputArea.value.length){
if(this.inputArea.value.charAt(_a).match(/\s/)){
break;
}
_a+=1;
}
this.setCursorPosition(_a);
this.altCursorPos=null;
this.forceUpdate=true;
_8.stop();
this.optionsMgr.saveUserMapping();
}
}else{
if(_8.key().string=="KEY_ESCAPE"){
w=this.optionsMgr.getChosenWord();
_c=wm.getMapping(QuillUtil.getLang(),w.engWord);
this.optionsMgr.setOptions(_c);
this.replaceWordAtCursor(_c);
this.mode="edit";
_8.stop();
}
}
}
}
}
};
TwoPaneEngine.prototype.makeCorrections=function(){
this.mode="correction";
var _d=this;
var _e=this.getCursorPosition();
var w=this.displayMgr.getWordAtCursorPos(_e);
logger.info("w",w);
if(!w){
return;
}
var pos=this.displayMgr.getIndex(_e);
var _11=QuillUtil.getLang();
var opt=wm.getMapping(_11,w[0]);
if(!opt){
return;
}
if(opt.preferred!==w[1]){
opt.preferred=w[1];
}
function callback(_13,_14){
var _15=false;
if(_13.length<=1){
_15=true;
}
_d.optionsMgr.setOptions(new WordMapping(opt.engWord,_13,opt.preferred,opt.itrans,_14),"#FFEFF0","#FFBFC2",_15);
}
var _16=opt.optmap[opt.preferred];
if(_16){
wm.getCorrections(QuillUtil.getLang(),_16,opt.engWord,pos-1,callback,"getCorrections");
}else{
wm.getCorrections(QuillUtil.getLang(),opt.preferred,opt.engWord,pos-1,callback,"getCorrectionsStr");
}
this.altCursorPos=_e;
};
TwoPaneEngine.prototype.activateTimer=function(evt){
if(this.contentChangeTimer==null){
this.contentChangeTimer=setInterval(method(this,"contentChecker"),this.delay);
}
};
TwoPaneEngine.prototype.deactivateTimer=function(evt){
clearInterval(this.contentChangeTimer);
this.contentChangeTimer=null;
};
TwoPaneEngine.prototype.replaceWordAtCursor=function(w){
if(!w){
return;
}
var _1a=this.getCursorPosition();
var _1b=this.displayMgr.getWidgetPosAtCursorPos(_1a);
this.displayMgr.replaceText(_1b,w.engWord,w.preferred);
logger.info(QuillUtil.getLang(),w.engWord,w.preferred,this.mode);
if(this.mode==="edit"){
wm.setPreferredMapping(QuillUtil.getLang(),w.engWord,w.preferred);
}
};
TwoPaneEngine.prototype.getCursorPosition=function(){
var _1c;
if(typeof (this.inputArea.selectionStart)!=="undefined"){
_1c=this.inputArea.selectionEnd;
}else{
if(document.selection){
this.inputArea.focus();
var sel=document.selection.createRange();
var _1e=sel.duplicate();
_1e.moveToElementText(this.inputArea);
_1e.setEndPoint("EndToEnd",sel);
_1c=_1e.text.length;
}
}
return _1c;
};
TwoPaneEngine.prototype.setCursorPosition=function(pos){
if(typeof (this.inputArea.selectionStart)!=="undefined"){
this.inputArea.selectionStart=pos;
this.inputArea.selectionEnd=pos;
}else{
if(document.selection){
this.inputArea.focus();
var _20=this.inputArea.createTextRange();
_20.collapse(true);
_20.moveStart("character",pos);
_20.moveEnd("character",pos);
_20.select();
}
}
};
TwoPaneEngine.prototype.resetSelection=function(){
if(this.inputArea.selectionStart!=undefined){
this.inputArea.selectionEnd=this.inputArea.selectionStart;
}else{
if(document.selection){
var _21=this.getCursorPosition();
this.inputArea.focus();
var _22=this.inputArea.createTextRange();
_22.collapse(true);
_22.moveEnd("character",_21);
_22.moveStart("character",_21);
_22.select();
}
}
};
TwoPaneEngine.prototype.cursorUpdater=function(){
var _23;
_23=this.getCursorPosition();
this.displayMgr.setCursorPosition(_23);
var w=this.displayMgr.getWordAtCursorPos(_23);
if(w&&w[0]){
if(w[1]===this.prevWordAtCursor){
return;
}
if(w[0]===this.prevEngWord&&this.mode==="correction"){
return;
}
this.prevWordAtCursor=w[1];
this.prevEngWord=w[0];
var opt=wm.getMapping(QuillUtil.getLang(),w[0]);
logger.info(opt);
if(!opt){
return;
this.prevCursorPos=null;
}
this.prevCursorPos=_23;
opt.preferred=w[1];
if(this.mode==="correction"){
this.optionsMgr.saveUserMapping();
}
this.mode="edit";
this.optionsMgr.setOptions(opt);
}else{
if(this.mode==="correction"){
this.optionsMgr.saveUserMapping();
}
this.mode="edit";
this.optionsMgr.setOptions(new WordMapping("","",[]));
this.prevWordAtCursor=null;
this.prevEngWord=null;
this.prevCursorPos=null;
}
};
TwoPaneEngine.prototype.contentChecker=function(){
this.displayMgr.setScrollPos(this.inputArea.scrollTop);
difflist=diffStr(this.oldVal,this.inputArea.value);
this.oldVal=this.inputArea.value;
var _26=this;
var _27=function(_28,pos,_2a,_2b,m){
if(_2a<_26.posMap[pos]){
logger.info("Oops... got old message for",_2b);
return;
}
_26.displayMgr.replaceText(pos,_2b,m.preferred);
};
for(var i=difflist.o.length-1;i>=1;i--){
var d=difflist.o[i];
if(d.text==null&&d!=""){
this.forceUpdate=true;
this.displayMgr.remove(i-2);
}
}
for(var i=1;i<difflist.n.length;i++){
var d=difflist.n[i];
if(d.text!=null){
continue;
}
this.forceUpdate=true;
if(!QuillUtil.isValidAlpha(d)){
this.displayMgr.addNonChar(i-2,d);
}else{
this.displayMgr.addText(i-2,d,"");
if(this.posMap[i-2]){
this.posMap[i-2]+=1;
}else{
this.posMap[i-2]=1;
}
wm.getWordMapping(QuillUtil.getLang(),d,partial(_27,1,i-2,this.posMap[i-2],d));
}
}
this.cursorUpdater();
};

function ODisplayManager(_1){
this.displayArea=_1;
this.prevHighlightedWidgetPos=0;
}
ODisplayManager.prototype.setScrollPos=function(_2){
this.displayArea.scrollTop=_2+3;
};
ODisplayManager.prototype.addText=function(_3,_4,_5){
var s=SPAN(_5);
setElementClass(s,"spanDispArea");
setNodeAttribute(s,"word",_4);
setNodeAttribute(s,"length",_4.length);
var _7=quillConfig.fonts[QuillUtil.getLang()];
if(_7){
s.style.fontFamily=_7+",'Arial Unicode MS',Arial, Verdana, Helvetica,sans-serif";
}else{
s.style.fontFamily="Arial, Verdana, Helvetica,sans-serif";
}
this.add(_3,s);
};
ODisplayManager.prototype.replaceText=function(_8,_9,_a){
var n=this.displayArea.childNodes[_8];
setNodeAttribute(n,"content",_a);
if(n){
if(n.textContent!=undefined){
n.textContent=_a;
}else{
if(n.innerText!=undefined){
n.innerText=_a;
}else{
n.text=_a;
}
}
}else{
logger.warn("Tried to replace non-existent widget at",_8);
}
};
ODisplayManager.prototype.setCursorPosition=function(_c,_d){
if(!_c){
return;
}
if(this.displayArea.childNodes[this.prevHighlightedWidgetPos]){
this.displayArea.childNodes[this.prevHighlightedWidgetPos].style.backgroundColor="white";
}
var i=this.getWidgetPosAtCursorPos(_c);
if(this.displayArea.childNodes[i]){
this.displayArea.childNodes[i].style.backgroundColor="yellow";
this.prevHighlightedWidgetPos=i;
}
};
ODisplayManager.prototype.getWordAtCursorPos=function(_f){
var i=this.getWidgetPosAtCursorPos(_f);
var w=null;
if(this.displayArea.childNodes[i]){
w=[getNodeAttribute(this.displayArea.childNodes[i],"word"),getNodeAttribute(this.displayArea.childNodes[i],"content")];
}
return w;
};
ODisplayManager.prototype.getWidgetPosAtCursorPos=function(_12){
var pos=0;
var i=0;
while(pos<_12){
pos+=parseInt(getNodeAttribute(this.displayArea.childNodes[i],"length"),10);
i++;
}
if(i==0){
return 0;
}
return i-1;
};
ODisplayManager.prototype.getIndex=function(_15){
var pos=0;
var i=0;
while(pos<_15){
pos+=parseInt(getNodeAttribute(this.displayArea.childNodes[i],"length"),10);
i++;
}
return _15-(pos-parseInt(getNodeAttribute(this.displayArea.childNodes[i-1],"length"),10));
};
ODisplayManager.prototype.add=function(pos,_19){
var n=this.displayArea.childNodes[pos];
var len=getNodeAttribute(_19,"length");
if(n){
try{
this.displayArea.insertBefore(_19,n);
}
catch(e){
logger.error(e);
}
}else{
this.displayArea.appendChild(_19);
}
};
ODisplayManager.prototype.addNonChar=function(pos,_1d){
var s=SPAN();
setNodeAttribute(s,"length",_1d.length);
setNodeAttribute(s,"content",_1d);
function myReplace(_1f){
var ret="";
for(var i=0;i<_1f.length;i++){
switch(_1f.charAt(i)){
case " ":
ret+="&nbsp;";
break;
case "\n":
ret+="<br/>";
break;
case "<":
ret+="&lt;";
break;
case ">":
ret+="&gt;";
break;
default:
ret+=_1f.charAt(i);
}
}
return ret;
}
var _22=myReplace(_1d)+"<wbr/>";
s.innerHTML=_22;
this.add(pos,s);
};
ODisplayManager.prototype.remove=function(pos){
if(!this.displayArea.childNodes[pos]){
logger.warn("Tried to remove non-existent widget",pos);
}else{
removeElement(this.displayArea.childNodes[pos]);
}
};
ODisplayManager.prototype.getText=function(){
var txt="";
map(function(n){
txt+=getNodeAttribute(n,"content");
},this.displayArea.childNodes);
return txt;
};

var EmailPanel=function(_1,_2,to,_4,_5,_6,_7,_8,_9,_a,_b,_c,_d,_e){
this.iName=getElement(_1);
this.iEmail=getElement(_2);
this.iToEmail=getElement(to);
this.iSubject=getElement(_4);
this.bSend=getElement(_5);
this.buttonSend=getElement(_6);
this.sName=getElement(_7);
this.sEmail=getElement(_8);
this.sToEmail=getElement(_9);
this.sSubject=getElement(_a);
this.sMessage=getElement(_b);
this.sSendSuccess=getElement(_c);
this.sSendFail=getElement(_d);
this.sSending=getElement(_e);
connect(this.buttonSend,"onclick",this,this.emailSend);
};
EmailPanel.prototype.isBlankMsg=function(){
var _f=(mode==="singlepanel")?t:tpengine.displayMgr;
if(QuillUtil.isBlank(_f.getText())){
if(this.sMessage.style.display=="none"){
this.sMessage.style.display="block";
}
}else{
this.sMessage.style.display="none";
}
};
EmailPanel.prototype.grabFocus=function(){
this.iName.focus();
};
EmailPanel.prototype.validate=function(){
if(QuillUtil.isBlank(this.iName.value)){
this.sName.style.display="block";
return false;
}else{
this.sName.style.display="none";
}
if(!QuillUtil.isValidEmailID(this.iEmail.value)){
this.sEmail.style.display="block";
return false;
}else{
this.sEmail.style.display="none";
}
if(!QuillUtil.isValidEmailIDGroup(this.iToEmail.value)){
this.sToEmail.style.display="block";
return false;
}else{
this.sToEmail.style.display="none";
}
var obj=(mode==="singlepanel")?t:tpengine.displayMgr;
if(QuillUtil.isBlank(obj.getText())){
this.sMessage.style.display="block";
return false;
}else{
this.sMessage.style.display="none";
}
if(QuillUtil.isBlank(this.iSubject.value)){
if(confirm("Subject is empty. "+"Do you still want to send the message?")){
return true;
}
return false;
}
return true;
};
EmailPanel.prototype.emailSend=function(evt){
evt.stop();
if(!this.validate()){
return;
}
email={email_from:this.iName.value,email_replyto:this.iEmail.value,email_to:this.iToEmail.value,email_subject:this.iSubject.value,sessionid:QuillUtil.getRandom()+"_"+QuillUtil.getBrowser(),version:quillConfig.server.version,rand:QuillUtil.getRandom(),lang:QuillUtil.getLang()};
if(mode==="twopanel"){
email.email_message=tpengine.displayMgr.getText();
}else{
email.email_message=t.getText();
}
var req=getXMLHttpRequest();
req.open("POST",QuillUtil.getServerAddr()+"/quillpad_backend5/sendEmail",true);
req.setRequestHeader("Content-type","application/x-www-form-urlencoded");
d=sendXMLHttpRequest(req,queryString(email));
d.addCallback(partial(function(o,r){
o.sSending.style.display="none";
o.sSendSuccess.style.display="block";
o.sSendFail.style.display="none";
},this));
d.addErrback(partial(function(o,r){
o.sSending.style.display="none";
o.sSendSuccess.style.display="none";
o.sSendFail.style.display="block";
},this));
this.sSendSuccess.style.display="none";
this.sSendFail.style.display="none";
this.sSending.style.display="block";
};

function featuresCallback(r){
var _2;
var a;
var _4;
var _5;
var _6=getElement("featuresTD");
var _7=getElement("sTable");
var i;
var _9;
function trim(s){
return s.replace(/^\s+|\s+$/g,"");
}
try{
_5=r.responseXML.getElementsByTagName("message");
for(i=0;i<_5.length;i++){
_2=_5[i].firstChild.nodeValue;
_4=_5[i].getAttribute("url");
_9=_5[i].getAttribute("starred");
a=DIV(null,A({"target":"_blank","href":_4},trim(_2)));
if(_9==="true"){
appendChildNodes(a,IMG({src:"images/star.png",style:{paddingLeft:"5px"}}));
}
setElementClass(a,"promo");
appendChildNodes(_6,a);
}
}
catch(e){
logger.error("Exception in callback",e.name,e.message,e.lineNumber);
}
}
function PromoManager(){
this.msgMap={};
var i;
this.msgMap["singlepanel"]={"counter":0,"msgs":[]};
this.msgMap["twopanel"]={"counter":0,"msgs":[]};
//setInterval(method(this,this.promoUpdater),10000);
//var d=doSimpleXMLHttpRequest("promo.xml");
//d.addCallback(method(this,this.promoCallback));
}
PromoManager.prototype.setPromo=function(_d){
setNodeText(getElement("promoAnchor"),_d.text);
};
PromoManager.prototype.promoUpdater=function(){
var _e=mode;
var _f=this.msgMap[_e].counter;
this.setPromo(this.msgMap[_e].msgs[_f]);
this.msgMap[_e].counter++;
if(this.msgMap[_e].counter>=this.msgMap[_e].msgs.length){
this.msgMap[_e].counter=0;
}
};
PromoManager.prototype.addToMsgMap=function(_10,_11,_12){
var i;
_10=_10.toLowerCase();
if(_10=="all"){
this.msgMap["singlepanel"].msgs.push({"href":_11,"text":_12});
this.msgMap["twopanel"].msgs.push({"href":_11,"text":_12});
}else{
this.msgMap[_10].msgs.push({"href":_11,"text":_12});
}
};
PromoManager.prototype.promoCallback=function(r){
var _15;
var a;
var url;
var _18;
var _19;
var _1a;
var _1b;
var i,j;
try{
_18=r.responseXML.getElementsByTagName("message");
for(i=0;i<_18.length;i++){
url=_18[i].getAttribute("url");
_1a=_18[i].getElementsByTagName("text");
_15=_1a[0].firstChild.nodeValue;
_1b=_18[i].getElementsByTagName("lang");
for(j=0;j<_1b.length;j++){
this.addToMsgMap(_1b[j].firstChild.nodeValue,url,_15);
}
}
}
catch(e){
logger.error("Exception in callback",e);
}
this.promoUpdater();
};
function loadPromo(){
//var d=doSimpleXMLHttpRequest("features.xml");
//d.addCallback(featuresCallback);
//pm=new PromoManager();
}

function showRenderWarning(_1,_2,_3){
if(QuillUtil.getBrowser()==="ie"){
return;
}
var cc = CookieManager.get("closedCount");
if(!cc){
    cc=2;
}
cc=parseInt(cc);
if(!cc){
return;
}
function closeErrPanel(_4){
CookieManager.set("closedCount",cc-1);
this.style.display="none";
}
getElement(_1).style.display="table";
connect(getElement(_2),"onclick",getElement(_1),closeErrPanel);
}
function managePanels(){
var _5=getElement("tEmail");
var _6=true;
connect(getElement("imgEmail"),"onclick",function(_7){
_7.stop();
if(_6){
_5.style.display="block";
_6=false;
ep.grabFocus();
}else{
_5.style.display="none";
_6=true;
t.forceFocus();
}
});
connect(getElement("bClose"),"onclick",function(_8){
_8.stop();
_5.style.display="none";
_6=true;
t.forceFocus();
});
}
function fillLang(){
var s=getElement("langUnicode");
var _a=QuillUtil.getLangLegacy();
var _b=getElement("spanSearchMsg");
var i;
var _d=[];
QuillUtil.setLang(_a);
for(i in quillConfig.supportedLanguages){
if(i!=="english"){
_d.push(i);
}
}
var _e=partial(createDOM,"SUP");
function makeTD(l){
var _10;
if(quillConfig.fontSizes&&quillConfig.fontSizes.hasOwnProperty(l)){
_10=quillConfig.fontSizes[l][0];
}else{
_10="12px";
}
if(quillConfig.supportedLanguages[l][3]){
return ""
}else{
return ""
}
}
var _12=quillConfig.supportedLanguages[_a];
setNodeText(s,_12[0]);
setNodeText(getElement("engSpanMsg"),_12[1]);
setNodeText(getElement("indSpanMsg"),_12[2]);
if(quillConfig.supportedLanguages[_a][3]){
setNodeText(getElement("newSup"),quillConfig.supportedLanguages[_a][3]);
getElement("newSup").style.display="inline";
}
}

function toggleButtons() {
var temp=QuillUtil.getLangLegacy();
if(indicMode){
getElement("langSelected").src="images/langButtons/English-off.png";
setNodeText(getElement("selectedLanguage"),"English");
getElement("langSelected").title="Click to switch to "+temp.charAt(0).toUpperCase()+temp.slice(1);
indicMode = 0;
} else {
getElement("langSelected").src="images/langButtons/"+temp.charAt(0).toUpperCase()+temp.slice(1)+"-off.png";
setNodeText(getElement("selectedLanguage"),temp.charAt(0).toUpperCase()+temp.slice(1));
getElement("langSelected").title="Click to switch to English";
indicMode = 1;
}
if(mode==="singlepanel"){
t.setFocus();
}
}

function rotateLogos() {
var logos = [
["bol.png", "http://bol.rediff.com/"], 
["onmobile.gif", "http://www.onmobile.com/"], 
["iland.png", "http://www.rediffiland.com/"], 
["josh18.png", "http://josh18.com/"], 
["rediffmail.png", "http://www.rediff.com/index.html"], 
["bigadda.jpg", "http://www.bigadda.com/indexhome.php"], 
["social.png", ""]
];
var idx = 0;
var img = getElement("imgClients");
var link = getElement("aClients");
if(!img || !link) {
return;
}
setInterval(function () {
if(idx >= logos.length) {
idx = 0;
}
setNodeAttribute(img, "src", "images/clients/" + logos[idx][0]);
setNodeAttribute(link, "href", logos[idx][1]);
idx += 1;
}, 5000);
}

connect(window,"onload",function(){
QuillUtil.setupLogging();
mode="singlepanel";
var _13;
var _14=false;
var _15="";
var key="1949";
indicMode=1;
QuillUtil.setCharEncoding("UTF-8");
var _17=QuillUtil.getMeta();
_13=_17["queryURL"];
if(_17["loadQueryInIFrame"]){
_14=true;
}
if(quillConfig.server.domain){
document.domain=quillConfig.server.domain;
}
rotateLogos();
alignLangList = function(){
if(QuillUtil.getBrowser()=="ie"){
for(lang in quillConfig.padding){
getElement("td"+lang).style.paddingTop=quillConfig.padding[lang][0];
}
}else if(QuillUtil.getBrowser()=="moz"){
for(lang in quillConfig.padding){
getElement("td"+lang).style.paddingTop=quillConfig.padding[lang][1];
}
}
}
alignLangList();
var langInd=QuillUtil.getLangLegacy();
QuillUtil.setLang(QuillUtil.getLangLegacy());
try{
setNodeAttribute(getElement("aLearn"),"href",["help/",QuillUtil.getLang(),"_help.html"].join(""));
}
catch(e){
}
showRenderWarning("renderWarning","closeWarn","errPng");
loadPromo();
wm=new WordMap();
t=new TextEngine("indicOutput");
t2=new STextEngine("searchKeyInput","bGo","aClose",_13,_14,_15,key);
tpengine=new TwoPaneEngine("indicDiv","keyInput","cOptions");
tpengine.deactivateTimer();
ep=new EmailPanel("eName","eEmail","eToEmail","eSubject","imgSend","bSend","eSpanName","eSpanEmail","eSpanToEmail","eSpanSubject","eSpanMessage","eSpanSendSuccess","eSpanSendFail","eSpanSending");
connect(getElement("bPrint"),"onclick",function(evt){
evt.stop();
var _19=getElement("printText");
if(mode==="twopanel"){
_19.value=[tpengine.displayMgr.getText()," "].join("");
}else{
_19.value=[t.getText()," "].join("");
}
var _1a=getElement("printForm");
_1a.submit();
});
var _1b=getElement("encDiv");
var _1c=getElement("mainArea");
var _1d=getElement("imgSwitch");
function switchInterfaces(evt){
evt.stop();
if(mode==="singlepanel"){
setNodeAttribute(_1d,"src","images/btnsingle.png");
setNodeAttribute(_1d,"title","");
setNodeText(getElement("aSwitchInterface"),"");
mode="twopanel";
_1b.style.display="none";
_1c.style.display="block";
tpengine.onWindowResize();
tpengine.inputArea.value=t.getEnglishText();
tpengine.activateTimer();
}else{
setNodeAttribute(_1d,"src","images/btntwopanel.png");
setNodeAttribute(_1d,"title","");
setNodeText(getElement("aSwitchInterface"),"");
tpengine.deactivateTimer();
if(QuillUtil.getBrowser()==="ie"){
t.setText(tpengine.inputArea.value);
}
mode="singlepanel";
_1b.style.display="block";
_1c.style.display="none";
}
}

connect(getElement("langSelected"),"onmousedown",function(){
    var temp=QuillUtil.getLangLegacy();
    if(indicMode){
        getElement("langSelected").src="images/langButtons/English-on.png";
    } else {
        getElement("langSelected").src="images/langButtons/"+temp.charAt(0).toUpperCase()+temp.slice(1)+"-on.png";
    }
});
/*
connect(getElement("langSelected"),"onmouseup",function(){
    var temp=QuillUtil.getLangLegacy();
    if(indicMode){
        getElement("langSelected").src="images/langButtons/"+temp.charAt(0).toUpperCase()+temp.slice(1)+"-off.png";
    } else {
        getElement("langSelected").src="images/langButtons/English-off.png";
    }
});
*/
connect(getElement("langSelected"),"onclick",function(){
if(indicMode){
QuillUtil.setLang("english");
}else{
QuillUtil.setLang(QuillUtil.getLangLegacy());
}
toggleButtons();
});

connect(_1d,"onclick",switchInterfaces);
connect(getElement("aSwitchInterface"),"onclick",switchInterfaces);
if(QuillUtil.getBrowser()==="ie"){
t.setText(quillConfig.initMsgs[QuillUtil.getLang()]);
}
managePanels();
});

var OptMgr=function(_1,_2,_3){
var i;
this.mapping=_1;
this.options=[];
var _5;
try{
_5=_2?_2:_1.preferred;
this.lang=_3?_3:QuillUtil.getLang();
extend(this.options,_1.tWordList);
extend(this.options,_1.userMapping);
}
catch(e){
_5=null;
this.lang=_3?_3:QuillUtil.getLang();
}
this.numOptions=this.options.length;
for(i=0;i<this.options.length;i++){
if(this.options[i]===_5){
this.chosenOption=i+1;
break;
}
}
};
OptMgr.prototype.chooseOptionWord=function(_6){
var i;
for(i=0;i<this.options.length;i++){
if(this.options[i]===_6){
this.chooseOption(i+1);
break;
}
}
};
OptMgr.prototype.chooseOption=function(_8){
if(_8<1||_8>this.numOptions){
return;
}
if(_8===this.chosenOption){
return [_8,this.options[_8-1]];
}
this.chosenOption=_8;
this.mapping.preferred=this.options[_8-1];
wm.setPreferredMapping(this.lang,this.mapping.engWord,this.options[_8-1]);
return [_8,this.options[_8-1]];
};
OptMgr.prototype.chooseNext=function(){
if(this.chosenOption>=this.numOptions){
return this.chooseOption(1);
}else{
return this.chooseOption(this.chosenOption+1);
}
};
OptMgr.prototype.choosePrevious=function(){
if(this.chosenOption<=1){
return this.chooseOption(this.numOptions);
}else{
return this.chooseOption(this.chosenOption-1);
}
};

var OptMenu=function(){
this.visible=false;
this.table=null;
this.fontSize=getFontSize()[0];
};
OptMenu.prototype={enabled:function(){
return this.visible;
},update:function(_1,_2){
this.node=_1;
this.mgr=new OptMgr(_2,null,getNodeAttribute(_1,"lang"));
var _3=this;
function makeTR(_4){
var td;
if(_4===_3.mgr.mapping.preferred){
td=TD({style:{background:"#C0DAFF"}},_4);
}else{
td=TD({style:{background:"#FFF"}},_4);
td.onmouseover=function(){
td.style.background="#C0DAFF";
};
td.onmouseout=function(){
td.style.background="#FFF";
};
}
setElementClass(td,"linkCursor");
return TR(null,td);
}
function makeTRUserMapped(_6){
var td;
if(_6===_3.mgr.mapping.preferred){
td=TD({style:{background:"#FFBFC2"}},_6);
}else{
td=TD({style:{background:"#FFFEF0"}},_6);
td.onmouseover=function(){
td.style.background="#FFBFC2";
};
td.onmouseout=function(){
td.style.background="#FFFEF0";
};
}
setElementClass(td,"linkCursor");
return TR(null,td);
}
if(!this.mgr.mapping){
return;
}
var _8=map(makeTR,this.mgr.mapping.tWordList);
if(this.mgr.mapping.userMapping){
extend(_8,map(makeTRUserMapped,this.mgr.mapping.userMapping));
}
this.table=TABLE({cellspacing:"1",cellpadding:"2","class":"optsTable"},TBODY(null,_8));
this.table.style.border="1px #C0DAFF solid";
this.table.style.background="white";
this.table.style.padding="1px";
this.table.style.fontSize=this.fontSize;
this.table.style.lineHeight=this.fontSize;
this.sig=connect(this.table,"onclick",this,this.onTblClick);
var _9=withDocument(ifrDoc,partial(elementPosition,_1));
var _a=iframePos();
_9.x+=_a.x;
_9.y+=_a.y+22-ifrDoc.body.scrollTop;
this.table.style.position="absolute";
setElementPosition(this.table,_9);
document.body.appendChild(this.table);
this.visible=true;
},onTblClick:function(_b){
var _c=_b.target();
if(_c!==this.table&&_c.nodeName==="TD"){
setNodeText(this.node,scrapeText(_c));
this.mgr.chooseOptionWord(getNodeText(_c));
this.cleanup();
}
_b.stop();
},cleanup:function(){
disconnect(this.sig);
removeElement(this.table);
this.table=null;
this.visible=false;
}};

function ToolTip(_1,_2,_3,_4,_5){
this.tdiv=getElement(_1);
this.textengine=_5;
if(QuillUtil.getBrowser()==="moz"){
this.tdiv.style.position="fixed";
this.updatePos=function(_6){
var _7=withDocument(this.textengine.doc,partial(elementPosition,_6));
var _8=iframePos();
_7.x+=_8.x;
_7.y+=_8.y+24-this.textengine.doc.body.scrollTop;
this.pos=_7;
_7.x-=window.pageXOffset;
_7.y-=window.pageYOffset;
setElementPosition(this.tdiv,_7);
};
window.onscroll=method(this,function(){
var _9=this.pos;
if(!_9){
return;
}
setElementPosition(this.tdiv,{x:_9.x-window.pageXOffset,y:_9.y-window.pageYOffset});
});
}else{
this.tdiv.style.position="absolute";
}
this.wordSpan=getElement(_2);
this.optSpan=getElement(_3);
this.editorInput=getElement(_4);
if(QuillUtil.getBrowser()==="ie"){
this.editorInput.onpaste=function(){
window.event.returnValue=false;
};
}else{
if(QuillUtil.getBrowser()==="moz"){
}
}
}
ToolTip.prototype={show:function(){
if(QuillUtil.getBrowser()==="moz"){
this.tdiv.style.display="table";
}else{
this.tdiv.style.display="block";
}
},hide:function(){
this.tdiv.style.display="none";
},updatePos:function(_a){
var _b=withDocument(this.textengine.doc,partial(elementPosition,_a));
var _c=iframePos();
_b.x+=_c.x;
_b.y+=_c.y+22-this.textengine.doc.body.scrollTop;
setElementPosition(this.tdiv,_b);
},update:function(_d,_e){
this.node=_d;
this.updatePos(_d);
this.setWord(_e);
setNodeText(this.optSpan,"...");
this.mgr=null;
this.show();
},changeColor:function(){
this.optSpan.style.color="#F66";
},restoreColor:function(){
this.optSpan.style.color="#66F";
},setWord:function(_f){
this.word=_f;
setNodeText(this.wordSpan,_f);
},updateOpts:function(_10,_11){
setNodeText(this.optSpan,""+_10+"/"+_11);
},getWord:function(){
return this.word;
},doneEditing:function(_12){
clearInterval(this.timer);
disconnect(this.sig1);
disconnect(this.sig2);
disconnect(this.sig3);
this.editorInput.style.display="none";
if(QuillUtil.getBrowser()==="moz"){
this.wordSpan.style.display="table-cell";
}else{
this.wordSpan.style.display="inline";
}
this.hide();
this.restoreColor();
if(this.mode==="correction"){
logger.info("Setting user mapping",this.editorInput.value,this.mgr.mapping.preferred);
wm.setUserMapping(getNodeAttribute(this.node,"lang"),this.editorInput.value,this.mgr.mapping.preferred);
}
if(this.editorInput.value===""){
this.textengine.doneEditing(this.node,true);
}else{
this.textengine.doneEditing(this.node,false,_12);
}
},editWord:function(_13,_14){
this.editorInput.style.display="inline";
this.wordSpan.style.display="none";
this.update(_13,_14);
this.oldText=_14;
this.mgr=new OptMgr(wm.getMapping(getNodeAttribute(_13,"lang"),_14));
this.mode="edit";
this.editorInput.focus();
this.editorInput.value=_14;
this.sig1=connect(this.editorInput,"onkeydown",this,this.onKeyDown);
this.sig2=connect(this.editorInput,"onblur",this,this.doneEditing);
this.sig3=connect(this.editorInput,"onkeypress",this,this.onKeyPress);
this.updateOpts(this.mgr.chosenOption,this.mgr.numOptions);
this.timer=setInterval(method(this,this.contentCheck),500);
},contentCheck:function(){
var _15=this.editorInput.value;
if(_15===this.oldText){
return;
}
this.mode="edit";
this.oldText=_15;
if(_15.length<=0){
setNodeText(this.node,"");
setNodeAttribute(this.node,"word","");
return;
}
setNodeAttribute(this.node,"word",_15);
wm.getWordMapping(getNodeAttribute(this.node,"lang"),_15,method(this,this.callbackFunc));
},callbackFunc:function(m){
this.mgr=new OptMgr(m);
this.textengine.replaceText(this.node,m.engWord,m.preferred);
this.updateOpts(this.mgr.chosenOption,this.mgr.numOptions);
this.restoreColor();
},onKeyPress:function(evt){
var s=evt.key().string;
if(!s.match(/[a-zA-Z\^\/~\.]/)&&s.length>0){
evt.stop();
}
},onKeyDown:function(evt){
var s=evt.key().string;
var opt;
logger.info(s);
switch(s){
case "KEY_BACKSPACE":
case "KEY_DELETE":
case "KEY_HOME":
case "KEY_END":
break;
case "KEY_ARROW_RIGHT":
if(getCursorPosition(this.editorInput)>=this.editorInput.value.length){
this.doneEditing();
}
break;
case "KEY_ARROW_LEFT":
if(getCursorPosition(this.editorInput)<=0){
this.doneEditing(true);
}
break;
case "KEY_Q":
if(evt.modifier().alt){
this.makeCorrection();
evt.stop();
}
break;
case "KEY_ESCAPE":
case "KEY_ENTER":
case "KEY_SPACEBAR":
evt.stop();
this.doneEditing();
break;
case "KEY_TAB":
evt.stop();
if(evt.modifier().shift){
this.chooseOption("previous");
}else{
this.chooseOption("next");
}
}
},chooseOption:function(_1c){
if(_1c==="prevous"){
opt=this.mgr.choosePrevious();
}else{
opt=this.mgr.chooseNext();
}
setNodeText(this.node,opt[1]);
this.updateOpts(opt[0],this.mgr.numOptions);
},setCursorAtStart:function(){
setCursorPosition(this.editorInput,0);
},makeCorrection:function(){
var pos=getCursorPosition(this.editorInput);
if(pos<=0){
return;
}
this.mode="correction";
var _1e=this;
var _1f=getNodeAttribute(this.node,"lang");
var opt=wm.getMapping(_1f,this.editorInput.value);
var _21=opt.optmap[this.editorInput.value];
function callback(_22,_23){
logger.info(_1f);
_1e.mgr=new OptMgr(new WordMapping(opt.engWord,_22,_22[0],"",_23),opt.preferred,_1f);
_1e.updateOpts(_1e.mgr.chosenOption,_1e.mgr.numOptions);
_1e.changeColor();
}
setNodeText(this.optSpan,"...");
if(_21){
wm.getCorrections(_1f,_21,opt.engWord,pos-1,callback,"getCorrections");
}else{
wm.getCorrections(_1f,opt.preferred,opt.engWord,pos-1,callback,"getCorrectionsStr");
}
}};

function SToolTip(_1,_2,_3,_4,_5,_6,_7){
this.tdiv=getElement(_1);
this.textengine=_7;
this.wordSpan=getElement(_2);
this.optSpan=getElement(_3);
this.editorInput=getElement(_4);
this.leftArr=getElement(_5);
this.rightArr=getElement(_6);
if(QuillUtil.getBrowser()==="ie"){
this.editorInput.onpaste=function(){
window.event.returnValue=false;
};
}else{
if(QuillUtil.getBrowser()==="moz"){
}
}
connect(this.leftArr,"onclick",this,this.prevOption);
connect(this.rightArr,"onclick",this,this.nextOption);
connect(this.wordSpan,"onclick",this,this.editIt);
}
SToolTip.prototype=clone(ToolTip.prototype);
SToolTip.prototype.updatePos=function(){
};
SToolTip.prototype.prevOption=function(_8){
if(this.mgr){
this.chooseOption("previous");
}
};
SToolTip.prototype.nextOption=function(_9){
if(this.mgr){
this.chooseOption("next");
}
};
SToolTip.prototype.updateOpts=function(_a,_b){
setNodeText(this.optSpan,""+_a+"/"+_b);
this.mgr=new OptMgr(wm.getMapping(getNodeAttribute(this.node,"lang"),getNodeAttribute(this.node,"word")),null,getNodeAttribute(this.node,"lang"));
};
SToolTip.prototype.updateOptsSpecial=function(){
this.mgr=new OptMgr(wm.getMapping(getNodeAttribute(this.node,"lang"),getNodeAttribute(this.node,"word")),null,getNodeAttribute(this.node,"lang"));
setNodeText(this.optSpan,""+this.mgr.chosenOption+"/"+this.mgr.numOptions);
};
SToolTip.prototype.restoreColor=function(){
this.optSpan.style.color="black";
};
SToolTip.prototype.editIt=function(_c){
if(!this.mgr){
return;
}
this.editWord(this.node,getNodeAttribute(this.node,"word"));
};

var STextEngine=function(_1,_2,_3,_4,_5,_6,_7){
var _8=getElement(_1);
this.bGo=getElement(_2);
this.queryURL=_4;
this.aClose=getElement(_3);
this.loadQueryInIFrame=_5;
this.key=_7;
this.doc=_8.contentDocument?_8.contentDocument:_8.contentWindow.document;
this.win=_8.contentWindow;
this.doc.designMode="on";
if(this.doc.body){
this.displayArea=this.doc.body;
}else{
this.doc.write("<head></head><body></body>");
this.doc.close();
this.displayArea=this.doc.body;
}
addStyleSheet(this.doc,QuillUtil.getServerPath()+"css/ifrsearch.css");
this.tooltip=new SToolTip("swordTip","swordTD","soptTD","seditorInput","imgLeftArr","imgRightArr",this);
this.menu=new OptMenu();
connect(this.doc,"onkeypress",this,this.onKeyPress);
connect(this.doc,"onkeydown",this,this.onKeyDownSpecial);
connect(this.doc,"onkeyup",this,this.onKeyUp);
connect(this.doc,"onclick",this,this.showOptions);
connect(this.bGo,"onclick",this,this.buttonOnClick);
if(QuillUtil.getBrowser()==="moz"){
connect(this.doc,"onblur",this,this.onBlur);
this.xlitText=this.xlitTextFF;
}else{
connect(this.win,"onblur",this,this.onBlur);
connect(this.displayArea,"onpaste",this,this.onPaste);
connect(this.displayArea,"oncut",this,this.onCut);
}
this.callback=method(this,this.callbackFunc);
};
STextEngine.prototype=clone(TextEngine.prototype);
STextEngine.prototype.onPaste=function(_9){
_9.stop();
};
STextEngine.prototype.hideMenu=function(){
};
STextEngine.prototype.showOptions=function(_a){
var _b=_a.target();
var _c;
var _d;
logger.info("got ShowOptions");
this.tooltip.hide();
if(!_b||_b===this.displayArea){
return;
}
_c=this.getWidgetContent(_b);
if(_c[0]!=="word"){
return;
}
_a.stop();
this.tooltip.update(_b,_c[1]);
this.tooltip.updateOptsSpecial();
};
STextEngine.prototype.onKeyDownSpecial=function(_e){
var s=_e.key().string;
if(s==="KEY_ENTER"){
_e.stop();
this.buttonOnClick();
}else{
this.onKeyDown(_e);
}
};
STextEngine.prototype.buttonOnClick=function(evt){
var _11=this.queryURL.replace("@quill@",this.getText());
if(this.queryURL){
if(this.loadQueryInIFrame){
req={"key":this.key,"searchstr":this.getText()};
var d=doSimpleXMLHttpRequest(QuillUtil.getServerAddr()+quillConfig.server.archiveSearch,req);
frames["externalSite"].location.href=encodeURI(_11);
}else{
_11=_11.replace("@lang@",QuillUtil.getLangLegacy());
window.open(encodeURI(_11));
}
}
};

