var fID; //*** IFRAME ID
var TXTOBJ; //*** TEXT Obj
var format = new Array();
var viewm = new Array();
/**************************************/
document.onmousedown=doMousedown
document.onmouseup=doMouseup
function changetoIframeEditor(el)
{
var wi= '', hi= '';
if(el.style.height) hi= " height=" + el.style.height
else if(el.rows) hi= " height=" + (14*el.rows+28)
if(el.style.width) wi= " width=" + el.style.width
else if(el.cols) wi= " width=" + (6*el.cols +25)
var parent= el.parentElement
while(parent.tagName != 'FORM') parent= parent.parentElement
var oform= parent
var fidx=0; while(document.forms[fidx] != oform) fidx++ ; // form index
var val=''
if(el.tagName=='TEXTAREA'){ fID= fidx+'VDevID'+el.name; val= el.innerText }
else fID= fidx+'VDevID'+el.id
var strx = createEditor(fID,wi,hi);
el.outerHTML= strx
iEditor(fID)
if(el.tagName!='TEXTAREA') return
var reg= eval("/ /i") ;
if( reg.test(val) ) val= val.replace(/\n/g, "");
else val= val.replace(/\n/g, " ");
val= val.replace(/\r/g, "");
val= val.replace(/\t/g, "");
val= val.replace(/\\/g, "\");
val= val.replace(/\'/g, "'");
setTimeout("document.frames['"+fID+"'].document.body.innerHTML='"+val+"'",200)
oform[fID.split('VDevID')[1]].value= val
}
function iEditor(idF)
{
var obj=document.frames[idF]
obj.document.designMode="On"
obj.document.onmousedown= function(){ TXTOBJ=null; fID=idF; FMousedown();}
format[idF]='HTML'
viewm[idF]=1;
}
function formatDialogF()
{
var y = screen.height - parseInt('30em')*14 - 30
var feature = "font-family:Tahoma; font-size:10pt; dialogWidth:30em; dialogHeight:27em; dialogTop:"+y
feature+= ";edge:sunken; help:no; status:no"
var dialog= QBPATH+'/dialog.html'
var arr= showModalDialog(dialog, "visual", feature);
if(arr==null) return ;
doFormatF(arr)
}
function FMousedown()
{
var objF=document.frames[fID];
// if(objF && objF.event && objF.event.button==2) formatDialogF();
var el = objF.event.srcElement
doClick(el)
}
// init all found TEXTAREA in document
function changeAllTextareaToEditors()
{
var i=0;
while(document.all.tags('textarea')[i])
{
changetoIframeEditor(document.all.tags('textarea')[i])
if(++i>0 && !document.all.tags('textarea')[i] ) i=0;
}
}
// init all found IFRAME in document to Editable
function changeAllIframeToEditors()
{
var i=0;
while(document.all.tags('iframe')[i])
{
changetoIframeEditor(document.all.tags('iframe')[i])
i++
}
}
// init only IFRAMEs that have "id=argument of initEditors"
// e.g. changeIframeToEditor('id1','id2',...)
function changeIframeToEditor()
{
for(var j=0;j\
"
str = str.replace(/IURL/g, iurl);
return str ;
}
function createEditor(id,wi,hi)
{
var strx = ""
var idA= id.split('VDevID')
strx += ""
var str="
"
str += strx + "
"
str += controlRows();
str += "
" ;
return str ;
}
/////////////////////////////////////////////////////////////////
function doFormatF(arr)
{
var objF=document.frames[fID];
if(!objF){alert('Please click to select the editor');return}
objF.focus()
var cmd = new Array();
cmd = arr.split(',')
if(cmd[0]=='SelectAll') selectAll();
else if(cmd[0]=='Swap[Text/HTML]') swapMode();
else if(cmd[0]=='Swap[Uni/View]') swapView();
else if(cmd[0]=='InsertTable') insertTable();
else if(cmd[0]=='TablePropeties') tableProp();
else if(cmd[0]=='CellPropeties') cellProp();
else if(cmd[0]=='InsertLayer') insertDivLayer();
else if(cmd[0]=='EditLayerBorder') editDivBorder();
else if(cmd[0]=='EditLayerFilter') editDivFilter();
else if(cmd[0]=='Emotions') editEmotions(cmd[1],objF);
else
{
var edit=objF.document;
if(cmd[0]=='formatBlock') edit.execCommand(cmd[0],false,"<"+cmd[1]+">")
else if(cmd[0]=='InsertImage' && !cmd[1] )
{
alert('Please notice:\nThe "Picture Source" in follow Dialog must be a URL, not a local address.');
// alert(cmd[0]);
// alert(cmd[1]);
edit.execCommand(cmd[0],true,"")
}
else
{
// alert(cmd[0]);
// alert(cmd[1]);
edit.execCommand(cmd[0],false,cmd[1]);
}
}
}
function editEmotions(wrd,obj)
{
var caret=obj.document.selection.createRange();
obj.curword=caret.duplicate();
obj.curword.text= wrd + ' '
}
function swapView()
{
var objF=document.frames[fID];
if(!objF){alert('Please click to select the editor');return}
objF.focus()
if(format[fID]=="HTML")
{
objF.document.body.style.fontFamily="Tahoma"
objF.document.body.style.fontSize="10pt"
objF.document.body.style.color="black"
objF.document.body.style.background="#e0e0f0"
var strx=objF.document.body.innerHTML
if(viewm[fID]) strx=toUnicode(strx)
else strx=viewISOCode(strx)
format[fID]="Text"
}
else
{
var strx=objF.document.body.innerText
if(viewm[fID]) strx=toUnicode(strx)
else strx=viewISOCode(strx)
}
objF.document.body.innerText=strx
viewm[fID]=1 - viewm[fID]
}
function swapMode()
{
var objF=document.frames[fID];
if(!objF){alert('Please click to select the editor');return}
objF.focus()
if(format[fID]=="HTML")
{
var strx=objF.document.body.innerHTML
objF.document.body.innerText=strx
objF.document.body.style.fontFamily="monospace"
objF.document.body.style.fontSize="10pt"
objF.document.body.style.color="black"
objF.document.body.style.background="#e0e0f0"
format[fID]="Text"
}
else
{
objF.document.body.style.fontFamily='Tahoma'
objF.document.body.style.color="#000000"
objF.document.body.style.background=""
var strx=objF.document.body.innerText
objF.document.body.innerHTML=strx
format[fID]="HTML"
viewm[fID]=1
}
}
function selectAll()
{
var objF=document.frames[fID];
if(!objF){alert('Please click to select the editor');return}
objF.focus()
var s=objF.document.body.createTextRange()
s.execCommand('SelectAll')
}
function doFormatDialog(file,cmd,arg)
{
var urlx= QBPATH + '/' + file
var objF=document.frames[fID];
if(!objF){alert('Please click to select the editor');return}
var arr=showModalDialog(urlx, arg, "font-family:Tahoma; font-size:12px; dialogWidth:30em; dialogHeight:34em; edge:sunken; help:no; status:no");
if(arr !=null) doFormatF(cmd+','+arr)
}
function selectEmoticon()
{
doFormatDialog('emoticon.html','InsertImage',QBPATH)
}
function selectBgColor()
{
doFormatDialog('selcolor.html','BackColor','')
}
function selectFgColor()
{
doFormatDialog('selcolor.html','ForeColor','')
}
function characters()
{
var objF=document.frames[fID];
if(!objF){alert('Please click to select the editor');return}
objF.focus();
var sel = objF.document.selection;
if(sel.type=="Control") return
var urlx= QBPATH + '/selchar.html'
var arr=showModalDialog(urlx, '', "font-family:Tahoma; font-size:12px; dialogWidth:30em; dialogHeight:34em; edge:sunken; help:no; status:no");
if(arr==null) return
var arrA = arr.split(';QuIcKbUiLd;')
var strx= "" + arrA[1] + ""
var Range = sel.createRange();
if(!Range.duplicate) return;
Range.pasteHTML(strx);
}
function doUploadFile()
{
var urlx= QBPATH + '/contents_upload.php'
var twidth= 0.8*screen.width, theight=190;
var tposx= (screen.width- twidth)/2
var tposy= screen.height- theight - 55
var newWin1=window.open(urlx,"upload","toolbar=no,width=600,height=250,directories=no,status=no,scrollbars=yes,resizable=no, menubar=no")
newWin1.moveTo(tposx,tposy);
newWin1.focus()
}
function help2()
{
var urlx= QBPATH + '/iconhelp.html'
/* var twidth= 0.1*screen.width, theight=300;
var tposx= (screen.width- twidth)/2
var tposy= screen.height- theight - 25*/
var newWin1=window.open(urlx,"help","toolbar=no,width=710,height=700,directories=no,status=no,scrollbars=yes,resizable=no, menubar=no")
// newWin1.moveTo(tposx,tposy);
newWin1.focus()
}
function dolinkFile()
{
var urlx= QBPATH + '/loadlinkgo.php'
var twidth= 0.8*screen.width, theight=190;
var tposx= (screen.width- twidth)/2
var tposy= screen.height- theight - 55
var newWin1=window.open(urlx,"linkins","toolbar=no,width=500,height=360,directories=no,status=no,scrollbars=yes,resizable=no, menubar=no")
newWin1.moveTo(tposx,tposy);
newWin1.focus()
}
function insertLink(linkurl,namelink)
{
var objF=document.frames[fID];
if(!objF && !TXTOBJ){alert('Please click a text element');return}
if( objF )
{
objF.focus();
var sel = objF.document.selection;
var strx= "" + namelink + ""
var Range = sel.createRange();
if(!Range.duplicate) return;
Range.pasteHTML(strx);
}
else
{
TXTOBJ.focus();
var caret= TXTOBJ.document.selection.createRange()
TXTOBJ.curword=caret.duplicate();
var strx= "" + namelink + ","
doFormat(strx,caret)
}
}
function insertflash(infla)
{
var objF=document.frames[fID];
if(!objF && !TXTOBJ){alert('Please click a text element');return}
if( objF )
{
objF.focus();
var sel = objF.document.selection;
var strx= ""
var Range = sel.createRange();
if(!Range.duplicate) return;
Range.pasteHTML(strx);
}
}
function linkins(linkurl,linkname)
{
var objF=document.frames[fID];
if(!objF && !TXTOBJ){alert('Please click a text element');return}
if( objF )
{
objF.focus();
var sel = objF.document.selection;
var strx= "" + linkname + ""
var Range = sel.createRange();
if(!Range.duplicate) return;
Range.pasteHTML(strx);
}
else
{
TXTOBJ.focus();
var caret= TXTOBJ.document.selection.createRange()
TXTOBJ.curword=caret.duplicate();
var strx= "" + linkname + ","
doFormat(strx,caret)
}
}
function linkinimg(linkurl,linkname)
{
var objF=document.frames[fID];
if(!objF && !TXTOBJ){alert('Please click a text element');return}
if( objF )
{
objF.focus();
var sel = objF.document.selection;
var strx= ""
var Range = sel.createRange();
if(!Range.duplicate) return;
Range.pasteHTML(strx);
}
else
{
TXTOBJ.focus();
var caret= TXTOBJ.document.selection.createRange()
TXTOBJ.curword=caret.duplicate();
var strx= ""
doFormat(strx,caret)
}
}
function field2form(str1)
{
var str2
var index
var lenx
index=str1.indexOf('