function html2ubb(str) {
	str = str.replace(/\r/g,"");
	str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
	str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");

	str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"\n[url=\"$1\"]$2[/url]\n");

	str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"\n[color=\"$1\"]$2[/color]\n");

	str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"\n[img]$1[/img]\n");

	str = str.replace(/<([\/]?)b>/ig,"[$1b]");
	str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
	str = str.replace(/<([\/]?)u>/ig,"[$1u]");
	str = str.replace(/<([\/]?)i>/ig,"[$1i]");

	str = str.replace(/&nbsp;/g," ");
	str = str.replace(/&amp;/g,"&");
	str = str.replace(/&quot;/g,"\"");
	str = str.replace(/&lt;/g,"<");
	str = str.replace(/&gt;/g,">");

	//str = str.replace(/<br>/ig,"\n");
	str = str.replace(/<[^>]*?>/g,"");
	str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2");
	str = str.replace(/\n+/g,"\n");

  return str;
}

function trans(){
  var str = "";
  rtf.focus();
  rtf.document.formp.innerHTML = "";
  rtf.document.execCommand("paste");
  str = rtf.document.formp.innerHTML;
  if(str.length == 0) {
    alert("剪切板不存在超文本数据");
    return "";
  }
  return html2ubb(str);
}

function zoomImg(o){
  var zoom=parseInt(o.style.zoom, 10)||100;zoom+=event.wheelDelta/12;if (zoom>0) o.style.zoom=zoom+'%';
  return false;
}

function html2text(str) {
	str = str.replace(/\r/g,"");
	str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
	str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");

	str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"");

	str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"");

	str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"");

	str = str.replace(/<([\/]?)b>/ig,"");
	str = str.replace(/<([\/]?)strong>/ig,"");
	str = str.replace(/<([\/]?)u>/ig,"");
	str = str.replace(/<([\/]?)i>/ig,"");

	str = str.replace(/&nbsp;/g,"");
	str = str.replace(/&amp;/g,"");
	str = str.replace(/&quot;/g,"");
	str = str.replace(/&lt;/g,"");
	str = str.replace(/&gt;/g,"");

	//str = str.replace(/<br>/ig,"\n");
	str = str.replace(/<[^>]*?>/g,"");
	str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"");
	str = str.replace(/\n+/g,"");

  return str;
}

//rtf.document.designMode="On";
