function renderCheck(_1){
function checkDevanagari(w1,w2){
var _4=Math.abs(w2-w1);
var _5=_4/w1;
if(w1==0||w2==0){
return false;
}
if(_5>0.3){
return false;
}
return true;
}
lang_index=new Object();
lang_index["bengali"]=0;
lang_index["gujarati"]=1;
lang_index["hindi"]=2;
lang_index["marathi"]=3;
lang_index["nepali"]=4;
lang_index["kannada"]=5;
lang_index["malayalam"]=6;
lang_index["punjabi"]=7;
lang_index["tamil"]=8;
lang_index["telugu"]=9;
var i;
var _7=[["Bengali",[["\u09b0\u09cd\u09a8\u09cd\u09a4","\ufeff\u09b0"],["\u09a4\u09cd\u09a4\u09cd\u09ac","\u09a4"],["\u09a8\u09cd\u09a4\u09cd\u09b0","\u09a8"]]],["Gujarati",[["\u0ab0\u0acd\u0aa6\u0acd\u0aa6","\ufeff\u0aa6"],["\u0ab6\u0acd\u0a9a\u0acd\u0ab0","\u0ab6"],["\u0ab0\u0acd\u0a9f\u0acd\u0ab0\u0ac7","\u0a9f"]]],["Hindi",[["\u0930\u094d\u0926\u094d\u0930","\ufeff\u0926"],["\u0930\u094d\u091f\u094d\u0930\u0947","\u091f"],["\u0937\u094d\u091f\u094d\u0930","\u0937"]]],["Marathi",[["\u0930\u094d\u0926\u094d\u0930","\ufeff\u0926"],["\u0930\u094d\u091f\u094d\u0930\u0947","\u091f"],["\u0937\u094d\u091f\u094d\u0930","\u0937"]]],["Nepali",[["\u0930\u094d\u0926\u094d\u0930","\ufeff\u0926"],["\u0930\u094d\u091f\u094d\u0930\u0947","\u091f"],["\u0937\u094d\u091f\u094d\u0930","\u0937"]]],["Kannada",[["\u0cb8\u0ccd\u0ca4\u0ccd\u0caf","\ufeff\u0cb8"],["\u0ca4\u0ccd\u0ca4\u0ccd\u0caf","\u0ca4"],["\u0cb2\u0ccd\u0cb2\u0ccd\u0cb0\u0cbf","\u0cb2"]]],["Malayalam",[["\u0d1f\u0d4d\u0d1f\u0d4d\u0d30","\ufeff\u0d1f"],["\u0d1a\u0d4d\u0d1b","\u0d1a"],["\u0d38\u0d4d\u0d31\u0d4d\u0d31","\u0d38"]]],["Punjabi",[["\u0a38\u0a4d\u0a30\u0a4d\u0a39\u0a4d\u0a30\u0a40","\ufeff\u0a38"],["\u0a2a\u0a4d\u0a30\u0a4d\u0a35","\u0a2a"],["\u0a17\u0a4d\u0a30\u0a4d\u0a39","\u0a17"]]],["Tamil",[["\u0b9f\u0bc2","\ufeff\u0b9f"],["\u0baa\u0bc1","\u0baa"],["\u0bb8\u0bcd\u0bb0\u0bc0","\u0bb8"]]],["Telugu",[["\u0c30\u0c4d\u0c18","\ufeff\u0c30"],["\u0c38\u0c4d\u0c24\u0c4d\u0c30","\u0c38"],["\u0c37\u0c4d\u0c1f\u0c4d\u0c30","\u0c37"]]]];
function computedStyle(el,_9){
var _a=_9;
if(el.currentStyle){
return el.currentStyle[_9];
}
if(typeof (document.defaultView)=="undefined"){
return undefined;
}
if(document.defaultView===null){
return undefined;
}
var _b=document.defaultView.getComputedStyle(el,null);
if(typeof (_b)=="undefined"||_b===null){
return undefined;
}
return _b.getPropertyValue(_a);
}
function elementWidth(_c){
if(computedStyle(_c,"display")!="none"){
return _c.offsetWidth;
}
var s=_c.style;
var _e=s.visibility;
var _f=s.position;
s.visibility="hidden";
s.position="absolute";
s.display="";
var _10=_c.offsetWidth;
s.display="none";
s.position=_f;
s.visibility=_e;
return _10;
}
function makeSpan(_11){
var _12=document.createElement("SPAN");
var _13=document.createTextNode(_11);
_12.appendChild(_13);
_12.style.visibility="hidden";
return _12;
}
function check(l){
var _15=0;
for(var i=0;i<l.length;i++){
var s1=makeSpan(l[i][0]);
var s2=makeSpan(l[i][1]);
document.body.appendChild(s1);
document.body.appendChild(s2);
var w1=elementWidth(s1);
var w2=elementWidth(s2);
document.body.removeChild(s1);
document.body.removeChild(s2);
if(checkDevanagari(w1,w2)){
_15+=1;
}
}
if(_15>=2){
return true;
}
return false;
}
if(typeof (lang_index[_1])!=="undefined"){
return check(_7[lang_index[_1]][1]);
}
}

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;
if(_2!=="english"){
showRenderWarning("renderWarning","closeWarn","errPng");
}
},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;
if(_6.length<1){
return false;
}
for(var i=0;i<_6.length;++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||ua.indexOf("msie 8.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_backend2/"+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.ifr=_2;
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.iframePos=function(){
return elementPosition(this.ifr);
};
TextEngine.prototype.setFontSizes=function(){
var _3=getFontSize();
this.doc.body.style.fontSize=_3[0];
this.doc.body.style.lineHeight=_3[1];
var _4=getElement("indicDiv");
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));
//this.addToLog(_12[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="";
var i,_22;
var _23=false;
for(i=0;i<_1f.length;i++){
switch(_1f.charAt(i)){
case " ":
if(!_23){
s+="<span>";
_23=true;
}
_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":
if(_23){
s=[s,"</span><br>"].join("");
_23=false;
}else{
s=[s,"<br>"].join("");
}
break;
default:
if(!_23){
s+="<span>";
_23=true;
}
s=[s,_1f.charAt(i)].join("");
}
}
if(_23){
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));
//this.addToLog(_1d[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 _29;
var _2a;
var _2b;
var _2c;
var _2d=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{
_29=this.doc.selection.createRange().duplicate();
_29.collapse(true);
_2a=this.doc.selection.createRange().duplicate();
_2a.collapse(false);
_29.pasteHTML("<span id=\"fuquaSpan1\"></span>");
_2b=this.doc.getElementById("fuquaSpan1");
ret.anchorNode=_2b.parentNode;
try{
if(_2b.previousSibling&&_2b.previousSibling.nodeName==="#text"){
ret.anchorOffset=_2b.previousSibling.nodeValue.length;
}
}
catch(e){
if(e.message==="Invalid Argument."){
ret.anchorOffset=0;
}
}
if(!_2b.nextSibling||_2b.parentNode.nodeName==="BODY"){
ret.atAnchorEnd=true;
}
if(!_2b.previousSibling){
ret.atAnchorStart=true;
}
if(_29.compareEndPoints("StartToStart",_2a)===0){
ret.isCollapsed=true;
withDocument(this.doc,function(){
removeElement(_2b);
});
return ret;
}else{
ret.isCollapsed=false;
}
_2a.pasteHTML("<span id=\"fuquaSpan2\"></span>");
_2c=this.doc.getElementById("fuquaSpan2");
ret.focusNode=_2c.parentNode;
if(_2c.previousSibling&&_2c.previousSibling.nodeName==="#text"){
ret.focusOffset=_2c.previousSibling.nodeValue.length;
}
if(!_2c.previousSibling||_2c.parentNode.nodeName==="BODY"){
ret.atFocusStart=true;
}
withDocument(this.doc,function(){
removeElement(_2b);
});
withDocument(this.doc,function(){
removeElement(_2c);
});
return ret;
}
};
TextEngine.prototype.addNewline=function(_30){
var n=withDocument(this.doc,BR);
this.add(n,_30);
return n;
};
TextEngine.prototype.setCursor=function(_32,_33){
var _34;
var sel;
if(this.win.getSelection){
_34=this.doc.createRange();
_34.selectNode(_33);
_34.collapse(_32);
sel=this.win.getSelection();
sel.removeAllRanges();
sel.addRange(_34);
}else{
if(this.doc.selection){
//logger.info("where",_32,_33);
_34=this.displayArea.createTextRange();
_34.moveToElementText(_33);
_34.collapse(_32);
_34.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 _38;
var _39;
var _3a;
if(this.win.getSelection){
sel=this.win.getSelection();
n=sel.anchorNode;
if(n.nodeName.toUpperCase()==="BODY"){
_39=sel.anchorOffset;
if(_39>0){
_39-=1;
}
n=this.displayArea.childNodes[_39];
}else{
if(n.parentNode&&n.parentNode.nodeName.toUpperCase()==="BODY"){
return n;
}
return n.parentNode;
}
return n;
}else{
_38=this.doc.selection.createRange().duplicate();
_38.collapse(true);
_38.pasteHTML("<span id=\"fuquaSpan\"></span>");
_3a=this.doc.getElementById("fuquaSpan");
if(_3a.parentNode&&_3a.parentNode.nodeName!=="BODY"){
n=_3a.parentNode;
}else{
n=_3a.previousSibling;
}
withDocument(this.doc,function(){
removeElement(_3a);
});
return n;
}
return null;
};
TextEngine.prototype.showOptions=function(evt){
var tgt=evt.target();
var _3d;
var mgr;
//logger.info("got ShowOptions");
if(this.menu.enabled()){
this.menu.cleanup();
}
this.tooltip.hide();
if(!tgt||tgt===this.displayArea){
return;
}
_3d=this.getWidgetContent(tgt);
if(_3d[0]!=="word"){
return;
}
if(evt.modifier().ctrl||evt.modifier().alt){
evt.stop();
this.tooltip.editWord(tgt,_3d[1]);
}else{
this.menu.update(tgt,wm.getMapping(_3d[2],_3d[1]));
}
};
TextEngine.prototype.getWidgetContent=function(_3f){
var c=getNodeAttribute(_3f,"word");
if(c){
return ["word",c,getNodeAttribute(_3f,"lang")];
}
return ["",""];
};
TextEngine.prototype.addText=function(_41,_42,_43,_44){
var sp=withDocument(this.doc,function(){
var s=SPAN(_43);
setElementClass(s,"spanDispArea");
setNodeAttribute(s,"word",_42);
setNodeAttribute(s,"length",_42.length);
setNodeAttribute(s,"lang",_44);
return s;
});
var _47=quillConfig.fonts[_44];
if(_47){
sp.style.fontFamily=_47+",'Arial Unicode MS',Arial, Verdana, Helvetica,sans-serif";
}else{
sp.style.fontFamily="Arial, Verdana, Helvetica,sans-serif";
}
var _48=getFontSize();
sp.style.fontSize=_48[0];
this.add(sp,_41);
return sp;
};
TextEngine.prototype.nuke=function(sel){
function removeRecurse(_4a,_4b){
if(!_4a){
return;
}
if(_4a==_4b){
withDocument(this.doc,partial(removeElement,_4a));
}else{
removeRecurse(_4a.nextSibling,_4b);
withDocument(this.doc,partial(removeElement,_4a));
}
}
removeRecurse(sel.anchorNode,sel.focusNode);
};
TextEngine.prototype.replaceText=function(n,_4d,_4e){
if(n){
setNodeText(n,_4e);
}else{
//logger.warn("Tried to replace non-existent widget at",n,_4d,_4e);
}
};
TextEngine.prototype.add=function(_4f,_50){
this.displayArea.insertBefore(_4f,_50);
};
TextEngine.prototype.addTextNode=function(_51,_52){
var n=this.doc.createTextNode(_51);
this.add(n,_52);
return n;
};
TextEngine.prototype.addSpan=function(_54,_55){
var _56=getFontSize();
var t=withDocument(this.doc,partial(SPAN,_54));
t.style.fontSize=_56[0];
this.add(t,_55);
return t;
};
TextEngine.prototype.remove=function(_58){
if(!_58){
//logger.warn("Tried to remove non-existent widget",_58);
}else{
removeElement(_58);
}
};
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]);
if(typeof (txt)!=="string"){
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 _5d;
var ret="";
for(i=0;i<this.displayArea.childNodes.length;i++){
_5d=getNodeAttribute(this.displayArea.childNodes[i],"word");
if(_5d){
ret+=_5d;
}else{
if(this.displayArea.childNodes[i].nodeName==="BR"){
ret+="\n";
}else{
ret+=getNodeText(this.displayArea.childNodes[i]);
}
}
}
return ret;
};
TextEngine.prototype.doneEditing=function(_5f,_60,_61){
this.win.focus();
if(_60){
this.remove(_5f);
}else{
if(_61){
this.setCursorBeforeWidget(_5f);
}else{
this.setCursorAfterWidget(_5f);
}
}
};
TextEngine.prototype.forceFocus=function(){
this.win.focus();
};
TextEngine.prototype.onKeyUp=function(evt){
var s=evt.key().string;
var _64;
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();
_64=this.getWidgetAtCursor();
c=this.getWidgetContent(_64);
if(c[0]==="word"){
mgr=new OptMgr(wm.getMapping(c[2],c[1]),getNodeText(_64));
this.tooltip.update(_64,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 _6a;
var n;
var c;
var _6d;
var _6e;
var mgr,opt;
var sel;
var _72;
switch(s){
case "KEY_ENTER":
this.tooltip.hide();
if(QuillUtil.getBrowser()==="moz"){
return;
}
_6a=this.getWidgetAtCursor();
if(_6a){
n=this.addNewline(_6a.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();
_6a=sel.anchorNode;
if(!sel.isCollapsed){
this.deleteSelection(sel,evt);
return;
}
c=this.getWidgetContent(_6a);
if(sel.atAnchorStart){
if(QuillUtil.getBrowser()==="moz"){
this.setCursorBeforeWidget(sel.anchorNode);
}else{
if(c[0]==="word"){
this.setCursorBeforeWidget(sel.anchorNode);
}
}
return;
}
_6d=c[1].slice(0,-1);
if(c[0]==="word"){
evt.stop();
if(_6d<=0){
_6e=_6a.prevSibling;
this.remove(_6a);
this.tooltip.hide();
if(_6e){
this.setCursorAfterWidget(_6e);
}
}else{
setNodeAttribute(_6a,"word",_6d);
this.tooltip.update(_6a,_6d);
wm.getWordMapping(c[2],_6d,partial(this.callback,_6a));
this.setCursorAfterWidget(_6a);
}
}
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();
_6a=this.getWidgetAtCursor();
c=this.getWidgetContent(_6a);
if(!c||typeof (c[2])==="undefined"){
break;
}
_72=wm.getMapping(c[2],c[1]);
if(!_72){
break;
}
if(c[0]==="word"){
evt.stop();
mgr=new OptMgr(_72);
if(evt.modifier().shift){
opt=mgr.choosePrevious();
}else{
opt=mgr.chooseNext();
}
this.tooltip.updateOpts(opt[0],mgr.numOptions);
setNodeText(_6a,opt[1]);
this.setCursorAfterWidget(_6a);
}
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 _79=this;
function modWord(_7a,_7b,_7c,_7d){
var _7e=_79;
if(_7b.length<=1){
_79.remove(_7a);
_79.tooltip.hide();
}else{
_7b=_7b.substring(1);
setNodeAttribute(_7a,"word",_7b);
//logger.info("node is",_7a);
_79.tooltip.update(_7a,_7b);
wm.getWordMapping(_7c,_7b,function(m){
_7e.callback(_7a,m);
if(_7d){
_7e.setCursorBeforeWidget(_7a);
}
});
}
}
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(_80,m){
var mgr=new OptMgr(m);
if(getNodeAttribute(_80,"word")===m.engWord){
try{
this.replaceText(_80,m.engWord,m.preferred);
}
catch(e){
//logger.warn("Exception in callbackFunc",m,_80,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 _85,_86;
var c;
var _88;
var t;
var mod=evt.modifier();
var sel=this.getSelection();
if(mod.alt||mod.ctrl){
return;
}
this.hideMenu();
if(s.match(/[a-zA-Z0-9]/)){
_85=this.getWidgetAtCursor();
if(_85){
c=this.getWidgetContent(_85);
if(c[0]==="word"){
_88=c[1]+s;
setNodeAttribute(_85,"word",_88);
this.tooltip.update(_85,_88);
wm.getWordMapping(c[2],_88,partial(this.callback,_85));
this.setCursorAfterWidget(_85);
}else{
if(QuillUtil.getBrowser()==="moz"&&_85.nodeName==="BR"&&!_85.nextSibling){
_86=this.addText(_85,s," ",QuillUtil.getLang());
_86.innerHTML="&nbsp;";
}else{
_86=this.addText(_85.nextSibling,s," ",QuillUtil.getLang());
if(QuillUtil.getBrowser()==="moz"){
_86.innerHTML="&nbsp;";
}
}
this.setCursorAfterWidget(_86);
this.tooltip.update(_86,s);
wm.getWordMapping(QuillUtil.getLang(),s,partial(this.callback,_86));
}
}else{
_86=this.addText(null,s," ",QuillUtil.getLang());
this.setCursorAfterWidget(_86);
this.tooltip.update(_86,s);
wm.getWordMapping(QuillUtil.getLang(),s,partial(this.callback,_86));
}
evt.stop();
}else{
if(s.length!=0){
this.tooltip.hide();
_85=this.getWidgetAtCursor();
if(!_85){
t=this.addSpan(s,null);
evt.stop();
this.setCursorAfterWidget(t);
return;
}
c=this.getWidgetContent(_85);
if(c[0]==="word"){
//this.addToLog(c[1]);
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(_85);
}else{
if(QuillUtil.getBrowser()==="ie"){
t=this.addSpan(s,_85.nextSibling);
this.setCursorAfterWidget(t);
evt.stop();
}
}
}
}
}
};
TextEngine.prototype.clearTextArea=function(){
var _8c=this.displayArea.firstChild;
while(_8c){
var _8d=_8c.nextSibling;
removeElement(_8c);
_8c=_8d;
}
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(_8f){
var _90=getNodeAttribute(_8f,"word");
if(_90){
return ["word",_90,getNodeText(_8f),getNodeAttribute(_8f,"lang")];
}else{
if(_8f.nodeName==="BR"){
return ["newline"];
}else{
if(_8f.nodeName==="#text"){
return (_8f.textContent?["text",_8f.textContent]:["text",_8f.data]);
}else{
if(_8f.nodeName==="SPAN"){
return ["text",getNodeText(_8f)];
}
}
}
}
},this.displayArea.childNodes));
};
TextEngine.prototype.load=function(_91){
var arr;
var i;
var s;
try{
arr=eval("("+_91+")");
}
catch(e){
//logger.warn("Got exception in load",e);
return;
}
function process(_95){
var s="";
var i,_98;
for(i=0;i<_95.length;i++){
switch(_95.charAt(i)){
case " ":
_98=0;
while(i<_95.length&&_95.charAt(i)===" "){
_98+=1;
s+="&nbsp;";
i++;
}
if(_98>1){
s=[s.slice(0,-6)," "].join("");
}
i--;
break;
default:
s=[s,_95.charAt(i)].join("");
}
}
return 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]);
}
}
};
TextEngine.prototype.addToLog=function(str){
var req={rand:QuillUtil.getRandom(),engString:str,lang:QuillUtil.getLang()};
var d=doSimpleXMLHttpRequest(quillConfig.server.log,req);
};

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.tempword="";
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);
this.inputArea.style.width=(_5.w-_4.x-_7)+"px";
}else{
if(_6=="ie"){
var _8=_5.w-_4.x-37;
if(_8>0){
this.inputArea.style.width=_8+"px";
}
}
}
var _8=elementDimensions("compose").w;
this.inputArea.style.width=_8-30+"px";
};
TwoPaneEngine.prototype.inputOnKeyDown=function(_9){
var n;
var _b;
var w;
var _d;
var _e=_9.key().code;
if(_e>=65&&_e<=91){
this.tempword+=String.fromCharCode(_e);
}
if(_9.key().string=="KEY_TAB"){
if(_9.modifier().shift){
this.optionsMgr.choosePrevOption();
}else{
this.optionsMgr.chooseNextOption();
}
w=this.optionsMgr.getChosenWord();
this.replaceWordAtCursor(w);
_9.stop();
}else{
if(_9.key().string=="KEY_Q"&&_9.modifier().alt){
this.makeCorrections();
_9.stop();
}else{
if(_9.modifier().alt){
n=parseInt(_9.key().string.substring(4,5));
if(n>=1&&n<=9){
this.optionsMgr.chooseOption(n);
this.replaceWordAtCursor(this.optionsMgr.getChosenWord());
_9.stop();
}
}else{
if(_9.key().string=="KEY_SPACEBAR"||_9.key().string=="KEY_ENTER"){
if(this.tempword!==""){
//this.addToLog(this.tempword);
this.tempword="";
}
if(this.mode==="correction"){
this.mode="edit";
_b=this.getCursorPosition();
while(_b<this.inputArea.value.length){
if(this.inputArea.value.charAt(_b).match(/\s/)){
break;
}
_b+=1;
}
this.setCursorPosition(_b);
this.altCursorPos=null;
this.forceUpdate=true;
_9.stop();
this.optionsMgr.saveUserMapping();
}
}else{
if(_9.key().string=="KEY_ESCAPE"){
w=this.optionsMgr.getChosenWord();
_d=wm.getMapping(QuillUtil.getLang(),w.engWord);
this.optionsMgr.setOptions(_d);
this.replaceWordAtCursor(_d);
this.mode="edit";
_9.stop();
}
}
}
}
}
};
TwoPaneEngine.prototype.makeCorrections=function(){
this.mode="correction";
var _f=this;
var _10=this.getCursorPosition();
var w=this.displayMgr.getWordAtCursorPos(_10);
//logger.info("w",w);
if(!w){
return;
}
var pos=this.displayMgr.getIndex(_10);
var _13=QuillUtil.getLang();
var opt=wm.getMapping(_13,w[0]);
if(!opt){
return;
}
if(opt.preferred!==w[1]){
opt.preferred=w[1];
}
function callback(_15,_16){
var _17=false;
if(_15.length<=1){
_17=true;
}
_f.optionsMgr.setOptions(new WordMapping(opt.engWord,_15,opt.preferred,opt.itrans,_16),"#FFEFF0","#FFBFC2",_17);
}
var _18=opt.optmap[opt.preferred];
if(_18){
wm.getCorrections(QuillUtil.getLang(),_18,opt.engWord,pos-1,callback,"getCorrections");
}else{
wm.getCorrections(QuillUtil.getLang(),opt.preferred,opt.engWord,pos-1,callback,"getCorrectionsStr");
}
this.altCursorPos=_10;
};
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 _1c=this.getCursorPosition();
var _1d=this.displayMgr.getWidgetPosAtCursorPos(_1c);
this.displayMgr.replaceText(_1d,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 _1e;
if(typeof (this.inputArea.selectionStart)!=="undefined"){
_1e=this.inputArea.selectionEnd;
}else{
if(document.selection){
this.inputArea.focus();
var sel=document.selection.createRange();
var _20=sel.duplicate();
_20.moveToElementText(this.inputArea);
_20.setEndPoint("EndToEnd",sel);
_1e=_20.text.length;
}
}
return _1e;
};
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 _22=this.inputArea.createTextRange();
_22.collapse(true);
_22.moveStart("character",pos);
_22.moveEnd("character",pos);
_22.select();
}
}
};
TwoPaneEngine.prototype.resetSelection=function(){
if(this.inputArea.selectionStart!=undefined){
this.inputArea.selectionEnd=this.inputArea.selectionStart;
}else{
if(document.selection){
var _23=this.getCursorPosition();
this.inputArea.focus();
var _24=this.inputArea.createTextRange();
_24.collapse(true);
_24.moveEnd("character",_23);
_24.moveStart("character",_23);
_24.select();
}
}
};
TwoPaneEngine.prototype.cursorUpdater=function(){
var _25;
_25=this.getCursorPosition();
this.displayMgr.setCursorPosition(_25);
var w=this.displayMgr.getWordAtCursorPos(_25);
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=_25;
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 _28=this;
var _29=function(_2a,pos,_2c,_2d,m){
if(_2c<_28.posMap[pos]){
//logger.info("Oops... got old message for",_2d);
return;
}
_28.displayMgr.replaceText(pos,_2d,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(_29,1,i-2,this.posMap[i-2],d));
}
}
this.cursorUpdater();
};
TwoPaneEngine.prototype.addToLog=function(str){
var req={rand:QuillUtil.getRandom(),engString:str,lang:QuillUtil.getLang()};
var d=doSimpleXMLHttpRequest(quillConfig.server.log,req);
};

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_backend2/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":[]};
}
PromoManager.prototype.setPromo=function(_c){
setNodeText(getElement("promoAnchor"),_c.text);
};
PromoManager.prototype.promoUpdater=function(){
var _d=mode;
var _e=this.msgMap[_d].counter;
this.setPromo(this.msgMap[_d].msgs[_e]);
this.msgMap[_d].counter++;
if(this.msgMap[_d].counter>=this.msgMap[_d].msgs.length){
this.msgMap[_d].counter=0;
}
};
PromoManager.prototype.addToMsgMap=function(_f,_10,_11){
var i;
_f=_f.toLowerCase();
if(_f=="all"){
this.msgMap["singlepanel"].msgs.push({"href":_10,"text":_11});
this.msgMap["twopanel"].msgs.push({"href":_10,"text":_11});
}else{
this.msgMap[_f].msgs.push({"href":_10,"text":_11});
}
};
PromoManager.prototype.promoCallback=function(r){
var _14;
var a;
var url;
var _17;
var _18;
var _19;
var _1a;
var i,j;
try{
_17=r.responseXML.getElementsByTagName("message");
for(i=0;i<_17.length;i++){
url=_17[i].getAttribute("url");
_19=_17[i].getElementsByTagName("text");
_14=_19[0].firstChild.nodeValue;
_1a=_17[i].getElementsByTagName("lang");
for(j=0;j<_1a.length;j++){
this.addToMsgMap(_1a[j].firstChild.nodeValue,url,_14);
}
}
}
catch(e){
//logger.error("Exception in callback",e);
}
this.promoUpdater();
};
function loadPromo(){
}

function showRenderWarning(_1,_2,_3){
var _4=QuillUtil.getLang();
var _5=quillConfig.ErrorMsgs["renderCheckMsg_head"];
var _6=quillConfig.ErrorMsgs["renderCheckMsg_tail"];
var _7=getElement("render_table");
_5=_5.replace(/%language%/,_4.charAt(0).toUpperCase()+_4.slice(1));
_6=_6.replace(/%language%/,_4.charAt(0).toUpperCase()+_4.slice(1));
if(renderCheck(QuillUtil.getLang())){
if(_7){
if(QuillUtil.getBrowser()==="ie"){
_7.style.display="block";
}else{
_7.style.display="table";
}
}
return;
}
_7.style.display="none";
function close_rendertext(){
var te=getElement("render_table");
te.style.display="none";
}
var _9=quillConfig.ErrorMsgs["renderError"];
_9=_9.replace(/%language%/,_4.charAt(0).toUpperCase()+_4.slice(1));
var cc=CookieManager.get("closedCount");
if(!cc){
cc=2;
}
cc=parseInt(cc);
if(!cc){
show_bottomRenderMSG();
return;
}
function show_bottomRenderMSG(){
var _b=getElement("render_table");
if(!renderCheck(QuillUtil.getLang())){
_5=_5.replace(/supports/,"doesn't support");
}
setNodeText(getElement("render_text_head"),_5);
setNodeText(getElement("render_text_tail"),_6);
if(QuillUtil.getBrowser()==="ie"){
_b.style.display="block";
}else{
_b.style.display="table";
}
}
function closeErrPanel(_c){
CookieManager.set("closedCount",cc-1);
this.style.display="none";
show_bottomRenderMSG();
}
var _d=getElement(_1);
if(_d){
setNodeText(getElement("renderWarning_Message"),_9);
if(QuillUtil.getBrowser()==="ie"){
_d.style.display="block";
}else{
_d.style.display="table";
}
}
connect(getElement(_2),"onclick",getElement(_1),closeErrPanel);
}
function managePanels(){
var _e=getElement("tEmail");
var _f=true;
connect(getElement("imgEmail"),"onclick",function(evt){
evt.stop();
if(_f){
_e.style.display="block";
_f=false;
ep.grabFocus();
}else{
_e.style.display="none";
_f=true;
t.forceFocus();
}
});
connect(getElement("bClose"),"onclick",function(evt){
evt.stop();
_e.style.display="none";
_f=true;
t.forceFocus();
});
}
function toggleButtons(){
var _12=QuillUtil.getLangLegacy();
if(indicMode){
getElement("langSelected").src="images/langButtons/English-off.png";
setNodeText(getElement("selectedLanguage"),"English");
getElement("langSelected").title="Click to switch to "+_12.charAt(0).toUpperCase()+_12.slice(1);
indicMode=0;
}else{
getElement("langSelected").src="images/langButtons/"+_12.charAt(0).toUpperCase()+_12.slice(1)+"-off.png";
setNodeText(getElement("selectedLanguage"),_12.charAt(0).toUpperCase()+_12.slice(1));
getElement("langSelected").title="Click to switch to English";
indicMode=1;
}
if(mode==="singlepanel"){
t.setFocus();
}
}
function rotateLogos(){
var _13=[["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"],["guruji.png","http://www.guruji.com"],["ibibo.png","http://www.ibibo.com"],["fropper.png","http://www.fropper.com"],["indiatimes.gif","http://www.indiatimes.com"],["social.png",""]];
var idx=0;
var img=getElement("imgClients");
var _16=getElement("aClients");
if(!img||!_16){
return;
}
setInterval(function(){
if(idx>=_13.length){
idx=0;
}
setNodeAttribute(img,"src","images/clients/"+_13[idx][0]);
setNodeAttribute(_16,"href",_13[idx][1]);
idx+=1;
},5000);
}
connect(window,"onload",function(){
QuillUtil.setupLogging();
mode="singlepanel";
var _17;
var _18=false;
var _19="";
var key="1949";
indicMode=1;
QuillUtil.setCharEncoding("UTF-8");
var _1b=QuillUtil.getMeta();
_17=_1b["queryURL"];
if(_1b["loadQueryInIFrame"]){
_18=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 _1c=QuillUtil.getLangLegacy();
QuillUtil.setLang(QuillUtil.getLangLegacy());
try{
setNodeAttribute(getElement("aLearn"),"href",["help/",QuillUtil.getLang(),"_help.html"].join(""));
}
catch(e){
}
connect(getElement("lang_support"),"onclick",show_renderSupport);
connect(getElement("show_lang_support"),"onclick",show_renderSupport);
showRenderWarning("renderWarning","closeWarn","errPng");
loadPromo();
wm=new WordMap();
t=new TextEngine("indicOutput");
t2=new STextEngine("searchKeyInput","bGo","aClose",_17,_18,_19,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 _1e=getElement("printText");
if(mode==="twopanel"){
_1e.value=[tpengine.displayMgr.getText()," "].join("");
}else{
_1e.value=[t.getText()," "].join("");
}
var _1f=getElement("printForm");
_1f.submit();
});
var _20=getElement("encDiv");
var _21=getElement("mainArea");
var _22=getElement("imgSwitch");
createIframe();
function switchInterfaces(evt){
evt.stop();
if(mode==="singlepanel"){
setNodeAttribute(_22,"src","images/btnsingle.png");
setNodeAttribute(_22,"title","");
setNodeText(getElement("aSwitchInterface"),"");
mode="twopanel";
_20.style.display="none";
_21.style.display="block";
tpengine.onWindowResize();
tpengine.inputArea.value=t.getEnglishText();
tpengine.activateTimer();
}else{
setNodeAttribute(_22,"src","images/btntwopanel.png");
setNodeAttribute(_22,"title","");
setNodeText(getElement("aSwitchInterface"),"");
tpengine.deactivateTimer();
if(QuillUtil.getBrowser()==="ie"){
t.setText(tpengine.inputArea.value);
}
mode="singlepanel";
_20.style.display="block";
_21.style.display="none";
}
}
connect(getElement("langSelected"),"onmousedown",function(){
var _24=QuillUtil.getLangLegacy();
if(indicMode){
getElement("langSelected").src="images/langButtons/English-on.png";
}else{
getElement("langSelected").src="images/langButtons/"+_24.charAt(0).toUpperCase()+_24.slice(1)+"-on.png";
}
});
connect(getElement("langSelected"),"onclick",function(){
if(indicMode){
QuillUtil.setLang("english");
}else{
QuillUtil.setLang(QuillUtil.getLangLegacy());
}
toggleButtons();
});
connect(_22,"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=this.textengine.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());
var _12=document.getElementById("search_engine").value;
_11=_11.replace("@key@",_12);
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));
}
}
};

function renderCheck(_1){
function checkDevanagari(w1,w2){
var _4=Math.abs(w2-w1);
var _5=_4/w1;
if(w1==0||w2==0){
return false;
}
if(_5>0.3){
return false;
}
return true;
}
lang_index=new Object();
lang_index["bengali"]=0;
lang_index["gujarati"]=1;
lang_index["hindi"]=2;
lang_index["marathi"]=3;
lang_index["nepali"]=4;
lang_index["kannada"]=5;
lang_index["malayalam"]=6;
lang_index["punjabi"]=7;
lang_index["tamil"]=8;
lang_index["telugu"]=9;
var i;
var _7=[["Bengali",[["\u09b0\u09cd\u09a8\u09cd\u09a4","\ufeff\u09b0"],["\u09a4\u09cd\u09a4\u09cd\u09ac","\u09a4"],["\u09a8\u09cd\u09a4\u09cd\u09b0","\u09a8"]]],["Gujarati",[["\u0ab0\u0acd\u0aa6\u0acd\u0aa6","\ufeff\u0aa6"],["\u0ab6\u0acd\u0a9a\u0acd\u0ab0","\u0ab6"],["\u0ab0\u0acd\u0a9f\u0acd\u0ab0\u0ac7","\u0a9f"]]],["Hindi",[["\u0930\u094d\u0926\u094d\u0930","\ufeff\u0926"],["\u0930\u094d\u091f\u094d\u0930\u0947","\u091f"],["\u0937\u094d\u091f\u094d\u0930","\u0937"]]],["Marathi",[["\u0930\u094d\u0926\u094d\u0930","\ufeff\u0926"],["\u0930\u094d\u091f\u094d\u0930\u0947","\u091f"],["\u0937\u094d\u091f\u094d\u0930","\u0937"]]],["Nepali",[["\u0930\u094d\u0926\u094d\u0930","\ufeff\u0926"],["\u0930\u094d\u091f\u094d\u0930\u0947","\u091f"],["\u0937\u094d\u091f\u094d\u0930","\u0937"]]],["Kannada",[["\u0cb8\u0ccd\u0ca4\u0ccd\u0caf","\ufeff\u0cb8"],["\u0ca4\u0ccd\u0ca4\u0ccd\u0caf","\u0ca4"],["\u0cb2\u0ccd\u0cb2\u0ccd\u0cb0\u0cbf","\u0cb2"]]],["Malayalam",[["\u0d1f\u0d4d\u0d1f\u0d4d\u0d30","\ufeff\u0d1f"],["\u0d1a\u0d4d\u0d1b","\u0d1a"],["\u0d38\u0d4d\u0d31\u0d4d\u0d31","\u0d38"]]],["Punjabi",[["\u0a38\u0a4d\u0a30\u0a4d\u0a39\u0a4d\u0a30\u0a40","\ufeff\u0a38"],["\u0a2a\u0a4d\u0a30\u0a4d\u0a35","\u0a2a"],["\u0a17\u0a4d\u0a30\u0a4d\u0a39","\u0a17"]]],["Tamil",[["\u0b9f\u0bc2","\ufeff\u0b9f"],["\u0baa\u0bc1","\u0baa"],["\u0bb8\u0bcd\u0bb0\u0bc0","\u0bb8"]]],["Telugu",[["\u0c30\u0c4d\u0c18","\ufeff\u0c30"],["\u0c38\u0c4d\u0c24\u0c4d\u0c30","\u0c38"],["\u0c37\u0c4d\u0c1f\u0c4d\u0c30","\u0c37"]]]];
function computedStyle(el,_9){
var _a=_9;
if(el.currentStyle){
return el.currentStyle[_9];
}
if(typeof (document.defaultView)=="undefined"){
return undefined;
}
if(document.defaultView===null){
return undefined;
}
var _b=document.defaultView.getComputedStyle(el,null);
if(typeof (_b)=="undefined"||_b===null){
return undefined;
}
return _b.getPropertyValue(_a);
}
function elementWidth(_c){
if(computedStyle(_c,"display")!="none"){
return _c.offsetWidth;
}
var s=_c.style;
var _e=s.visibility;
var _f=s.position;
s.visibility="hidden";
s.position="absolute";
s.display="";
var _10=_c.offsetWidth;
s.display="none";
s.position=_f;
s.visibility=_e;
return _10;
}
function makeSpan(_11){
var _12=document.createElement("SPAN");
var _13=document.createTextNode(_11);
_12.appendChild(_13);
_12.style.visibility="hidden";
return _12;
}
function check(l){
var _15=0;
for(var i=0;i<l.length;i++){
var s1=makeSpan(l[i][0]);
var s2=makeSpan(l[i][1]);
document.body.appendChild(s1);
document.body.appendChild(s2);
var w1=elementWidth(s1);
var w2=elementWidth(s2);
document.body.removeChild(s1);
document.body.removeChild(s2);
if(checkDevanagari(w1,w2)){
_15+=1;
}
}
if(_15>=2){
return true;
}
return false;
}
if(typeof (lang_index[_1])!=="undefined"){
return check(_7[lang_index[_1]][1]);
}
}

function createIframe(){
var _1=document.createElement("iframe");
_1.id="render_summary";
_1.width=1;
_1.height=1;
_1.scrolling="no";
_1.frameBorder="0";
_1.marginWidth="20";
_1.marginHeight="20";
_1.style.position="absolute";
if(QuillUtil.getBrowser()!=="ie"){
_1.style.border="1px #ccc solid";
}
i=MochiKit.DOM.appendChildNodes(document.body,_1);
var _2=document.getElementById("render_summary");
var _3=_2.contentDocument?_2.contentDocument:_2.contentWindow.document;
iframe_html="<head></head><body>\n\t\t\t<table id=\"lang_render\" width=\"210px\" align=\"center\"><thead>\n             <tr>\n              <td  colspan=3  style=\"font-weight: bold; font-size: 14px;top : 0px; left: 0px; align:center\"><center>Unicode font display test results for your browser</center></td>\n              </tr>\n\t\t\t<tr height=\"20px\"></tr>\n\t\t\t  </thead>\n            <tbody id=\"testHere\">\n            </tbody>\n\t\t\t<tr></tr>\n\t\t\t<tr></tr>\n\t\t\t<tfoot><tr height=\"10px\"></tr>\n\t\t\t<tr>\n\t\t\t<td id=\"show_help_link\" colspan=3 align=\"left\" style=\"font-size: 11px; display:none\"><span id=\"help_link\" ><a href=\"#\">Click here</a></span> for font rendering help.</td></tr>\n\t\t\t<tr height=\"10px\"></tr>\n\t\t\t<tr><td colspan=3 align=\"center\"><a href=\"#\" onClick=\"top.close_renderSupport(); return false;\" ><span id=\"close_iframe\" align=\"center\" style=\"font-size :11px; \">Close</span></a></td></tr></tfoot>\n        </table>\n\t\t</body></html>\n ";
_3.write("<head></head><body>"+iframe_html+"</body>");
_3.close();
_3.body.style.zIndex=1000;
if(QuillUtil.getBrowser()==="ie"){
_3.body.style.border="1px #ccc solid";
}
_3.body.style.backgroundColor="#E9ECFB";
_3.body.style.fontFamily="Verdana, Lucida Grande, Arial, sans-serif";
connect(_3.getElementById("help_link"),"onclick",show_help);
}
function show_renderSupport(){
var _4=document.getElementById("render_summary");
if(!_4){
createIframe();
setTimeout("_show_renderSupport()",1000);
}else{
_show_renderSupport();
}
}
function _show_renderSupport(){
var _5=document.getElementById("render_summary");
var _6=_5.contentDocument?_5.contentDocument:_5.contentWindow.document;
var _7=_6.getElementById("testHere");
var _8=_6.getElementById("show_help_link");
if(_6.getElementById("testHere").getElementsByTagName("tr").length!=0){
if(QuillUtil.getBrowser()==="ie"){
_5.style.display="block";
}else{
_5.style.display="table";
}
return;
}
function addTR(a,b){
MochiKit.DOM.withDocument(_6,function(){
var tr=_6.createElement("TR");
var _c=_6.createElement("TD");
var _d=_6.createElement("TD");
var _e=_6.createElement("TD");
var t1=_6.createTextNode(a.substr(0,1).toUpperCase()+a.substr(1));
var t2=_6.createElement("IMG");
t2.setAttribute("src","images/"+b+".gif");
_c.style.paddingRight="1em";
_d.style.paddingLeft="1em";
_c.style.borderBottom="1px dotted gray";
_c.style.fontSize="11px";
_d.style.fontSize="11px";
_d.align="right";
_c.style.padding="2px 4px 2px 2px";
_d.style.padding="2px 4px 2px 2px";
_c.appendChild(t1);
_d.appendChild(t2);
tr.appendChild(_c);
tr.appendChild(_e);
tr.appendChild(_d);
tr.setAttribute("id","render_line");
_7.appendChild(tr);
});
}
function log(_11,_12){
if(_12){
addTR(_11,"pass");
}else{
addTR(_11,"fail");
_8.style.display="block";
}
}
for(lang in quillConfig.supportedLanguages){
if(lang!="english"){
var _13=renderCheck(lang);
log(lang,_13);
}
}
var _14=document.getElementById("render_summary");
var _15=_14.contentDocument?_14.contentDocument:_14.contentWindow.document;
var _16=_15.getElementById("lang_render");
var _17=MochiKit.DOM.elementDimensions(_16);
_5.style.top="30%";
_5.style.left="50%";
_5.width=_17.w+40;
_5.height=_17.h+40;
_5.style.zIndex=1000;
if(QuillUtil.getBrowser()==="ie"){
_5.style.display="block";
}else{
_5.style.display="table";
}
}
function close_renderSupport(){
var _18=document.getElementById("render_summary");
_18.style.display="none";
}
function show_help(){
close_renderSupport();
window.location="http://quillpad.in/help/index.html#renderingProblem";
}

