SEP_PADDING = 5 HANDLE_PADDING = 7 var yToolbars = new Array(); var YInitialized = false; function document.onreadystatechange() { YInitialized = true; var i, s, curr; for (i=0; i"); mytext.document.close() mytext.document.designMode="On" } function InitBtn(btn) { btn.onmouseover = BtnMouseOver; btn.onmouseout = BtnMouseOut; btn.onmousedown = BtnMouseDown; btn.onmouseup = BtnMouseUp; btn.ondragstart = YCancelEvent; btn.onselectstart = YCancelEvent; btn.onselect = YCancelEvent; btn.YUSERONCLICK = btn.onclick; btn.onclick = YCancelEvent; btn.YINITIALIZED = true; return true; } function InitTB(y) { y.TBWidth = 0; if (! PopulateTB(y)) return false; y.style.posWidth = y.TBWidth; return true; } function YCancelEvent() { event.returnValue=false; event.cancelBubble=true; return false; } function BtnMouseOver() { if (event.srcElement.tagName != "IMG") return false; var image = event.srcElement; var element = image.parentElement; if (image.className == "Ico") element.className = "BtnMouseOverUp"; else if (image.className == "IcoDown") element.className = "BtnMouseOverDown"; event.cancelBubble = true; } function BtnMouseOut() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; yRaisedElement = null; element.className = "Btn"; image.className = "Ico"; event.cancelBubble = true; } function BtnMouseDown() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; event.returnValue=false; return false; } var image = event.srcElement; var element = image.parentElement; element.className = "BtnMouseOverDown"; image.className = "IcoDown"; event.cancelBubble = true; event.returnValue=false; return false; } function BtnMouseUp() { if (event.srcElement.tagName != "IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()"); element.className = "BtnMouseOverUp"; image.className = "Ico"; event.cancelBubble = true; return false; } function PopulateTB(y) { var i, elements, element; elements = y.children; for (i=0; i"); return false; } } y.TBWidth += 1; return true; } function DebugObject(obj) { var msg = ""; for (var i in TB) { ans=prompt(i+"="+TB[i]+"\n"); if (! ans) break; } } function LayoutTBs() { NumTBs = yToolbars.length; if (NumTBs == 0) return; var i; var ScrWid = (document.body.offsetWidth) - 6; var TotalLen = ScrWid; for (i = 0 ; i < NumTBs ; i++) { TB = yToolbars[i]; if (TB.TBWidth > TotalLen) TotalLen = TB.TBWidth; } var PrevTB; var LastStart = 0; var RelTop = 0; var LastWid, CurrWid; var TB = yToolbars[0]; TB.style.posTop = 0; TB.style.posLeft = 0; var Start = TB.TBWidth; for (i = 1 ; i < yToolbars.length ; i++) { PrevTB = TB; TB = yToolbars[i]; CurrWid = TB.TBWidth; if ((Start + CurrWid) > ScrWid) { Start = 0; LastWid = TotalLen - LastStart; } else { LastWid = PrevTB.TBWidth; RelTop -= TB.offsetHeight; } TB.style.posTop = RelTop; TB.style.posLeft = Start; PrevTB.style.width = LastWid; LastStart = Start; Start += CurrWid; } TB.style.width = TotalLen - LastStart; i--; TB = yToolbars[i]; var TBInd = TB.sourceIndex; var A = TB.document.all; var item; for (i in A) { item = A.item(i); if (! item) continue; if (! item.style) continue; if (item.sourceIndex <= TBInd) continue; if (item.style.position == "absolute") continue; item.style.posTop = RelTop; } } function DoLayout() { LayoutTBs(); } function isRTextMode() { if (! bTextMode) return true; alert("Please uncheck the \"View HTML source\" checkbox."); mytext.focus(); return false; } function RunCom(what,opt) { if (!isRTextMode()) return; if (opt=="removeFormat") { what=opt; opt=null; } if (opt==null) mytext.document.execCommand(what); else mytext.document.execCommand(what,"",opt); pureText = false; mytext.focus(); } function setMode(newMode) { bTextMode = newMode; var cont; if (bTextMode) { cleanHtml(); cleanHtml(); cont=mytext.document.body.innerHTML; mytext.document.body.innerText=cont; } else { cont=mytext.document.body.innerText; mytext.document.body.innerHTML=cont; } mytext.focus(); } function getEl(sTag,start) { while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement; return start; } function createLink() { if (!isRTextMode()) return; var isA = getEl("A",mytext.document.selection.createRange().parentElement()); var str=prompt("Enter URL :", isA ? isA.href : "http:\/\/"); if ((str!=null) && (str!="http://")) { if (mytext.document.selection.type=="None") { var sel=mytext.document.selection.createRange(); sel.pasteHTML(""+str+" "); sel.select(); } else RunCom("CreateLink",str); } else mytext.focus(); } function cleanHtml() { var fonts = mytext.document.body.all.tags("FONT"); var curr; for (var i = fonts.length - 1; i >= 0; i--) { curr = fonts[i]; if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML; } } function getPureHtml() { var str = ""; var paras = mytext.document.body.all.tags("P"); if (paras.length > 0) { for (var i=paras.length-1; i >= 0; i--) str = paras[i].innerHTML + "\n" + str; } else { str = mytext.document.body.innerHTML; } return str; }