TINY={}; function T$(i){return document.getElementById(i)} function T$$$(){return document.all?1:0} TINY.editor=function(){ var c=[], offset=-30; c['cut']=[1,'Cut','a','cut',1]; c['copy']=[2,'Copy','a','copy',1]; c['paste']=[3,'Paste','a','paste',1]; c['bold']=[4,'Bold','a','bold']; c['italic']=[5,'Italic','a','italic']; c['underline']=[6,'Underline','a','underline']; c['strikethrough']=[7,'Strikethrough','a','strikethrough']; c['subscript']=[8,'Subscript','a','subscript']; c['superscript']=[9,'Superscript','a','superscript']; c['orderedlist']=[10,'Insert Ordered List','a','insertorderedlist']; c['unorderedlist']=[11,'Insert Unordered List','a','insertunorderedlist']; c['outdent']=[12,'Outdent','a','outdent']; c['indent']=[13,'Indent','a','indent']; c['leftalign']=[14,'Left Align','a','justifyleft']; c['centeralign']=[15,'Center Align','a','justifycenter']; c['rightalign']=[16,'Right Align','a','justifyright']; c['blockjustify']=[17,'Block Justify','a','justifyfull']; c['undo']=[18,'Undo','a','undo']; c['redo']=[19,'Redo','a','redo']; c['image']=[20,'Insert Image','i','insertimage','Enter Image URL:','http://']; c['hr']=[21,'Insert Horizontal Rule','a','inserthorizontalrule']; c['link']=[22,'Insert Hyperlink','i','createlink','Enter URL:','http://']; c['unlink']=[23,'Remove Hyperlink','a','unlink']; c['unformat']=[24,'Remove Formatting','a','removeformat']; c['print']=[25,'Print','a','print']; function edit(n,obj){ this.n=n; window[n]=this; this.t=T$(obj.id); this.obj=obj; this.xhtml=obj.xhtml; var p=document.createElement('div'), w=document.createElement('div'), h=document.createElement('div'), l=obj.controls.length, i=0; this.i=document.createElement('iframe'); this.i.frameBorder=0; this.i.width=obj.width||'500'; this.i.height=obj.height||'250'; this.ie=T$$$(); h.className=obj.rowclass||'teheader'; p.className=obj.cssclass||'te'; p.style.width=this.i.width+'px'; p.appendChild(h); for(i;i'],['Header 1','

'],['Header 2','

'],['Header 3','

'],['Header 4','

'],['Header 5','

'],['Header 6','
']], sl=styles.length, x=0; sel.className='testyle'; sel.onchange=new Function(this.n+'.ddaction(this,"formatblock")'); for(x;x'} if(obj.css){m+=''} m+=''+(obj.content||this.t.value); m+=''; this.e.write(m); this.e.close(); this.e.designMode='on'; this.d=1; if(this.xhtml){ try{this.e.execCommand("styleWithCSS",0,0)} catch(e){try{this.e.execCommand("useCSS",0,1)}catch(e){}} } }; edit.prototype.print=function(){ this.i.contentWindow.print() }, edit.prototype.hover=function(div,pos,dir){ this.getSelection(); div.style.backgroundPosition=(dir?'34px ':'0px ')+(pos)+'px' }, edit.prototype.ddaction=function(dd,a){ var i=dd.selectedIndex, v=dd.options[i].value; this.action(a,v) }, edit.prototype.getSelection=function(){ if (this.e.getSelection && this.ie) { sel = this.e.getSelection(); if (sel.getRangeAt && sel.rangeCount) { this.range = sel.getRangeAt(0); } } }, edit.prototype.restoreSelection=function(){ if (this.range && this.ie) { if (this.e.getSelection) { sel = this.e.getSelection(); sel.removeAllRanges(); sel.addRange(this.range); } } }, edit.prototype.action=function(cmd,val,ie){ if(ie&&!this.ie){ alert('Your browser does not support this function.') }else{ this.restoreSelection(); this.e.execCommand(cmd,0,val||null) } }, edit.prototype.insert=function(pro,msg,cmd){ var val=prompt(pro,msg); if(val!=null&&val!=''){this.e.execCommand(cmd,0,val)} }, edit.prototype.setfont=function(){ this.restoreSelection(); execCommand('formatblock',0,hType) }, edit.prototype.resize=function(e){ if(this.mv){this.freeze()} this.i.bcs=TINY.cursor.top(e); this.mv=new Function('event',this.n+'.move(event)'); this.sr=new Function(this.n+'.freeze()'); if(this.ie){ document.attachEvent('onmousemove',this.mv); document.attachEvent('onmouseup',this.sr) }else{ document.addEventListener('mousemove',this.mv,1); document.addEventListener('mouseup',this.sr,1) } }, edit.prototype.move=function(e){ var pos=TINY.cursor.top(e); this.i.height=parseInt(this.i.height)+pos-this.i.bcs; this.i.bcs=pos }, edit.prototype.freeze=function(){ if(this.ie){ document.detachEvent('onmousemove',this.mv); document.detachEvent('onmouseup',this.sr) }else{ document.removeEventListener('mousemove',this.mv,1); document.removeEventListener('mouseup',this.sr,1) } }, edit.prototype.toggle=function(post,div){ if(!this.d){ var v=this.t.value; if(div){div.innerHTML=this.obj.toggletext||'source'} if(this.xhtml&&!this.ie){ v=v.replace(/(.*)<\/strong>/gi,'$1'); v=v.replace(/(.*)<\/em>/gi,'$1') } this.e.body.innerHTML=v; this.t.style.display='none'; this.i.style.display='block'; this.d=1 }else{ var v=this.e.body.innerHTML; if(this.xhtml){ v=v.replace(/(.*)<\/span>/gi,'$1'); v=v.replace(/ class="apple-style-span"/gi,''); v=v.replace(//gi,''); v=v.replace(/
/gi,'
'); v=v.replace(/
$/gi,''); v=v.replace(/^
/gi,''); v=v.replace(/(]+[^\/])>/gi,'$1 />'); v=v.replace(/]*>(.*?)<\/b[^>]*>/gi,'$1'); v=v.replace(/]*>(.*?)<\/i[^>]*>/gi,'$1'); v=v.replace(/]*>(.*?)<\/u[^>]*>/gi,'$1'); v=v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,'$2'); v=v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<$4>$3'); v=v.replace(/(.*)<\/span>/gi,'$1'); v=v.replace(/(.*)<\/span>/gi,'$1'); v=v.replace(/(.*)<\/span>/gi,'$1'); v=v.replace(/(.*)<\/span>|]*>(.*?)<\/b[^>]*>/gi,'$1') } if(div){div.innerHTML=this.obj.toggletext||'wysiwyg'} this.t.value=v; if(!post){ this.t.style.height=this.i.height+'px'; this.i.style.display='none'; this.t.style.display='block'; this.d=0 } } }, edit.prototype.post=function(){ if(this.d){this.toggle(1)} }; return{edit:edit} }(); TINY.cursor=function(){ return{ top:function(e){ return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:e.clientY+window.scrollY } } }();