function fetchResponse(page,str,div){
document.getElementById(div).innerHTML="
";
var clshttp = ajObj();
if (clshttp.readyState == 4 || clshttp.readyState == 0 ) {
clshttp.open('POST',page, true);
clshttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
clshttp.send(str);
clshttp.onreadystatechange = function() {
if (clshttp.readyState == 4) {
if(clshttp.responseText!=''){
document.getElementById(div).innerHTML=clshttp.responseText;
}
}
};
}
}
function fetchResult(page,str,div1,txt,type,lang){
if (clshttp.readyState == 4 || clshttp.readyState == 0 ){
clshttp.open('POST',page, true);
clshttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
clshttp.onreadystatechange = function() {
if (clshttp.readyState == 4) {
if(clshttp.responseText!=''){
document.getElementById(div1).value=clshttp.responseText;
if(type=='dictionary'){
updatesearch(str);
}
}else {
if(type=='dictionary'){
document.getElementById(div1).value='There is no result for '+txt+'
';
}else {
document.getElementById(div1).value='There is no result for "'+txt+'"';
}
}
gE('loading').style.display='none';
if(type=='dictionary'){
gE('dict_div').innerHTML=gE('txtResult').value;
}
}
};
clshttp.send(str);
}
}
function ajObj(){
var obj = null;
if(window.XMLHttpRequest){
obj = new XMLHttpRequest();
} else if(window.ActiveXObject){
obj = new ActiveXObject("Microsoft.XMLHTTP");
} else {
alert("Ajax is not suppoted on your browser");
}
return obj;
}
var clshttp = ajObj();
function gE(control){
return document.getElementById(control);
}
var copytoclip=1;
function HighlightAll(theField){
if(document.getElementById('txtResult').value==''){
alert("There is no content to copy.");
return false;
}
var tempval=theField;
tempval.focus()
tempval.select()
if (document.all&©toclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
return true;
}
function getTrns(type,lang,dictParam,langparam,txtSource,divid){
var str1='';
if(type=='dataconversion' || type=='editor'){
if(gE('drpFonts').value=='') {
alert('Please select source font');
return false;
}else {
str1='&drpFonts='+gE('drpFonts').value;
}
}
if(type=='dataconversion' || type=='transliteration'){
if(gE('txtSource').value.length>2000){
alert("Words excceds the limit.Please enter the words with 2000 limit");
return false;
}
}
if(txtSource!=''){
gE('txtSource').value=txtSource;
}
if(gE('txtSource').value=='') {
if(type=='dictionary'){
alert('Please enter the English Word');
} else if(type=='dataconversion'){
alert('Please enter the Font Text');
} else {
alert('Please enter the Roman Text');
}
gE('txtSource').focus();
return false;
}else {
var adttl=gE('txtSource').value;
var txt=gE('txtSource').value;
adttl=adttl.replace(/&/g, "##AND##");
adttl=adttl.replace('+', "##PLUS123##");
var str='txtSource='+adttl+'&type='+type+str1+'&lang='+lang+'&dictParam='+dictParam+'&LANG_PARAM='+langparam;
gE('txtResult').value='';
var loc = getOffset(gE(divid));
gE('loading').style.display='block';
// alert(loc.x+"--"+loc.y);
if(type=='dataconversion' || type=='transliteration'){
gE('loading').style.left = parseInt(loc.x+81)+"px";
gE('loading').style.top = parseInt(loc.y-181)+"px";
} else if(type=='dictionary'){
//alert(loc.x+"--"+loc.y);
gE('loading').style.left = parseInt(loc.x+110)+"px";
gE('loading').style.top = parseInt(loc.y+240)+"px";
//alert(gE('loading').style.top);
}
fetchResult('/process/response.php',str,'txtResult',txt,type,lang);
return false;
}
}
function setfonts(font){
gE('txtSource').style.fontFamily=font;
gE('txtSource').style.fontSize='14px';
}
function setHelp(helpid,lang,divid){
var str='helpid='+helpid+'&lang='+lang;
fetchResponse('setHelp.php',str,divid);
}
function showhelp(val){
document.getElementById('help').style.display = "block";
setDivPosition('help',val,350);
}
function setDivPosition(div,elementId,cltrw) {
var element = document.getElementById(elementId);
var left = 0;
var top = 0;
if (element != null){
try{
while (element.offsetParent){
left += element.offsetLeft;
if (element.offsetParent.scrollLeft) {left -= element.offsetParent.scrollLeft; }
top += element.offsetTop;
if (element.offsetParent.scrollTop) { top -= element.offsetParent.scrollTop; }
element = element.offsetParent;
}
}
catch (e){// Do nothing
}
left += element.offsetLeft + document.body.scrollLeft - document.body.clientLeft;
top += element.offsetTop + document.body.scrollTop - document.body.clientTop;
}
var colordiv = document.getElementById(div);
var width=document.body.clientWidth;
if(width < (left + cltrw)){
left=left-(cltrw + 39);
}
colordiv.style.left = left+-365+"px";
colordiv.style.top = top+25+"px";
colordiv.style.position = "absolute";
}
function showPopup(divid){
document.getElementById(divid).style.display="block";
}
function hidePopup(divid){
document.getElementById(divid).style.display="none";
}
function setlang(path,lang){
var path=path.replace("SEL_LANGVAL",lang);
var redirectpath=path.replace("#LANGNAME#",lang);
//alert(path+"=="+lang);
//alert(redirectpath);
window.location.href=redirectpath;
return false;
}
function getSourceFont(div,lang,type){
var clshttp1 = ajObj();
if (clshttp1.readyState == 4 || clshttp1.readyState == 0 ) {
clshttp1.open('POST','process_dc.php', true);
clshttp1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
str='lang='+lang+'&type='+type;
clshttp1.onreadystatechange = function() {
if (clshttp1.readyState == 4 ) {
document.getElementById('loadfont').innerHTML=clshttp1.responseText;
document.getElementById('txtResult').className=document.getElementById('getfont').value;
}else {
strimg='
';
document.getElementById('loadfont').innerHTML=strimg;
}
};
clshttp1.send(str);
}
}
function gettranslang(div,lang,type){
var clshttp2 = ajObj();
if (clshttp2.readyState == 4 || clshttp2.readyState == 0 ) {
clshttp2.open('POST','process_dc.php', true);
clshttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
str='lang='+lang+'&type='+type;
clshttp2.send(str);
clshttp2.onreadystatechange = function() {
if (clshttp2.readyState == 4 ) {
document.getElementById(div).innerHTML=clshttp2.responseText;
document.getElementById('txtResult').className=document.getElementById('getfont').value;
}
};
}
}
function savedata(langdata){
if(langdata=='') {
alert('Please write the data in editor');
document.getElementById('txtResult').focus();
return false;
}
return true;
}
function updatesearch(str){
var clshttp_new = ajObj();
if (clshttp_new.readyState == 4 || clshttp_new.readyState == 0 ) {
clshttp_new.open('POST','recentword.php', true);
clshttp_new.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
clshttp_new.onreadystatechange = function() {
if (clshttp_new.readyState == 4 ) {
}
};
clshttp_new.send(str);
}
}
function NewWindow(mypage,myname,w,h,scroll,pos){
LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
}
function getOffset(obj){
var curleft = 0, curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft;
curtop = obj.offsetTop;
while ((obj = obj.offsetParent)) {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
}
}
return {
x: curleft,
y: curtop
};
}
function resetall(){
document.getElementById('txtSource').value='';
document.getElementById('txtResult').value='';
}
function errmsg(){
alert("Please select the language.");
gE('lang').focus()
return false;
}
function rate_rte(ratedval) {
var cmObj = ajObj(); cmObj.abort();
if (cmObj.readyState == 4 || cmObj.readyState == 0) {
gE('rtevotediv').innerHTML='
';
var param = 'ptype=vote&ratedval='+ ratedval;
cmObj.open('POST', '/rte_voting.php', true);
cmObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
cmObj.onreadystatechange = function(){
if (cmObj.readyState==4 && cmObj.status==200){
var res =cmObj.responseText;
gE('rtevotediv').innerHTML='
Like
Dislike';
return false;
}
};
cmObj.send(param);
return false;
}
}