/* dws-edit.js */var G={w:window,d:document,gecko:navigator.product=='Gecko',init:function(){for(var n in G)if(G[n].init)G[n].init()},set:function(a,b){for(var o in b)a[o]=b[o];return a},create:function(a,b,c,d){var o=(d||G.d).createElement(a);G.set(o,b);G.set(o.style,c);return o},append:function(a,b,c,d){var o=b.tagName?b:G.create(b,c,d);a.appendChild(o);return o}},$=function(a,b){return (b||G.d).getElementById(a)},$$=function(a,b){return (b||G.d).getElementsByTagName(a)}G.edit={blocks:' h1 h2 h3 h4 h5 h6 p ol ul li div table tr th td ',inline:' img span strong em br b i a ',init:function(){	var m=this,o=$$('div'),i	m.all=m.blocks+m.inline	m.style=G.d.styleSheets[0].href	for(i=0;i<o.length;i++)if(o[i].className=="rich-text")m.prepare(o[i])},prepare:function(a){	var m=this,tb=$$('div',a)[0],sr=$$('textarea',a)[0],o,od	G.set(tb,{className:'rte-bar',innerHTML:m.toolbar()})	o=G.append(a,'iframe',{frameBorder:0 },{width:sr.offsetWidth+'px',height:sr.offsetHeight+'px'})	sr.style.display='none';a.source=sr;a.rte=o.contentWindow;od=a.rte.document;od.designMode='On'	od.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')	od.write('<html><head><meta http-equiv="content-type" content="text/html;charset=UTF-8" />')	od.write('<link rel="stylesheet" type="text/css" href="'+m.style+'" />')	od.write('</head><body id="rte-body">'+sr.value+'</body></html>')	od.close()},toolbar:function(){	var m=this,f=m.button,x=m.option,v=[f('Bold'),f('Italic'),f('Left','justifyleft'),f('Center','justifycenter'),f('Right','justifyright'),f('Unordered list','insertunorderedlist'),f('Ordered list','insertorderedlist'),'<select onchange="G.edit.change(this)">',x('','[format]'),x('h1','Header 1'),x('h2','Header 2'),x('h3','Header 3'),x('h4','Header 4'),x('h5','Header 5'),x('h6','Header 6'),x('p','Normal'),'</select>',f('Insert link','insert-link'),f('Insert image','insert-image'),f('Source','view-toggle')]	return v.join('\n')},button:function(a,b){	var v=b?b:a.toLowerCase()	return '<b title="'+a+'" class="'+v+'" unselectable="on" onclick="G.edit.exec(this,\''+v+'\')"></b>'},option:function(a,b){	return '<option value="'+a+'">'+b+'</option>'},exec:function(a,b,c){	var m=this,op=a.parentNode.parentNode,o=op.rte,v,os,ob	switch(b){	case 'insert-link':		v=prompt('Hyperlink:','http://')		if(v && v!='' && v!='http://')o.document.execCommand('createlink',false,v)		break	case 'insert-image':		v=prompt('Image URL:','')		if(v && v!='')o.document.execCommand('insertimage',false,v)		break	case 'view-toggle':		os=$$('textarea',op)[0]		ob=(os.style.display=='none')		if(ob){					if(G.gecko)m.removeEmpty(o.document.body)//turn on /off clean			os.value=m.clean(o.document.body)			os.value=o.document.body.innerHTML // if this line is commented out then cleaning is on               document.forms[0].editmode.value = "html" 						}		else {                    document.forms[0].editmode.value = "rich" 				                    o.document.body.innerHTML=os.value 				 }						os.style.display=ob?'block':'none'		$$('iframe',op)[0].style.display=ob?'none':'block'		break	default:		o.document.execCommand(b,false,null)	}	o.focus()},change:function(a){	var o=a.parentNode.parentNode.rte,v=a.options[a.selectedIndex].value	o.document.execCommand('formatblock',false,'<'+v+'>')	a.selectedIndex=0	o.focus()},removeEmpty:function(a){	var i=0,o=a.childNodes	while(i<o.length){if(o[i] && o[i].nodeType==3 && !o[i].data.search(/^\s+$/))a.removeChild(o[i]);i++}},clean:function(a,b){	var m=this,v=[],o=a.childNodes,i,good=b?b:m.all	for(i=0;i<o.length;i++)v.push(m.cleanNode(o[i],good))	return v.join('')},cleanNode:function(a,b){	var m=this,nn,q,bt,it	if(a.nodeType==3)return a.data	nn=a.nodeName.toLowerCase()//	if (nn=='td') return a.data	it=m.inline.indexOf(' '+nn+' ')>-1	if(b.indexOf(' '+nn+' ')==-1)return m.clean(a,b)	switch(nn){//	case 'td':return a.data + ' hmm '	case 'h1':return '<h1>'+m.clean(a,b)+'</h1>'	case 'h2':return '<h2>'+m.clean(a,b)+'</h2>'	case 'h3':return '<h3>'+m.clean(a,b)+'</h3>'	case 'h4':return '<h4>'+m.clean(a,b)+'</h4>'	case 'h5':return '<h5>'+m.clean(a,b)+'</h5>'	case 'h6':return '<h6>'+m.clean(a,b)+'</h6>'	case 'br':return '<br />'	case 'img':return '<img src="'+a.src+'" alt="'+a.alt  +  '" '   +(a.className?' class="'+a.className+'"':'')+' />'	case 'a':return '<a href="'+a.href+'" title="'+a.title+'"'+(a.className?' class="'+a.className+'"':'')+'>'+m.clean(a,m.inline)+'</a>'	case 'p':return '<p'+m.attributes(a)+'>'+m.clean(a,m.inline)+'</p>\n'	default:return '<'+nn+m.attributes(a)+'>'+m.clean(a,it?m.inline:m.blocks)+'</'+nn+'>'	}},attributes:function(a){	var m=this,v=[],ac=a.className,as=m.allowedStyle(a)	if(ac && !ac.indexOf('Mso')==0)v.push(' class="'+ac+'"')	if(a.align=='center'||a.align=='right')v.push(' align="'+a.align+'"')	if(a.style!='')v.push(' style="'+as+'"')	if(as!='')v.push(' style="'+as+'"')	return v.join('')},allowedStyle:function(a){	var m=this,o=a.style,v=[],i,q	if(!o)return ''	if(o.textAlign=='center')v.push('text-align:center')	if(o.textAlign=='center')v.push('text-align:center')	if(o.textAlign=='right')v.push('text-align:right')	if(o.fontWeight=='bold')v.push('font-weight:bold')	if(o.fontStyle=='italic')v.push('font-style:italic')	return v.join(';')}}G.w.onload=G.init
