function preButton(){
	document.write( "<input type=\"button\" value=\"Preview\" onclick=\"wbPreview()\" />" );
}
function preBlock(){
	document.write( "<div id=\"wbpreview\"><h5 class=\"wbtitle\">Preview comment</h5></div>" );
}
function wbPreview() {
  var name  = document.forms[0].name.value;
  var subject = document.forms[0].subject.value;
  var mail = document.forms[0].mail.value;
  var url = document.forms[0].url.value;
  var comment  = document.forms[0].comment.value;

  comment = comment.replace( /</g, "&lt;" );comment = comment.replace( />/g, "&gt;" ); 
  comment = comment.replace( /\r\n/g, "\n" );comment = comment.replace( /\n/g, "<br \/>" ); 
  comment = comment.replace( /\[\太字\]/g, "<b>" ); comment = comment.replace( /\[\/太字\]/g, "<\/b>" );
  comment = comment.replace( /\[\斜体\]/g, "<i>" ); comment = comment.replace( /\[\/斜体\]/g, "<\/i>" );
  comment = comment.replace( /\[\下線\]/g, "<u>" ); comment = comment.replace( /\[\/下線\]/g, "<\/u>" );
  comment = comment.replace( /\[\打消\]/g, "<s>" ); comment = comment.replace( /\[\/打消\]/g, "<\/s>" );

  comment = comment.replace( /\[色:([A-F0-9]{6})\]/g, "<font color=\"#$1\">" );
  comment = comment.replace( /\[\/色\]/g, "<\/font>" );
  
  comment = comment.replace( /\[絵文字:(e|i|v)-(\d+)\]/g, "<img src=\"http:\/\/blog10.fc2.com\/image\/$1\/$2\.gif\" alt=\"$1-$2\" class=\"emoji\" style=\"border:0;\">" );

  document.getElementById("wbpreview").innerHTML = '<h5 class="wbtitle">'
	+ '<input type=\"button\" value=\"close" onclick=\"closePreview()\" style=\"float: right;\" />'
	+ subject + '&nbsp;by&nbsp;' + name
	+ '<\/h5><div class="wb"><p>'
	+ comment
	+ '</p><hr /><ul>'
	+ '<li>Mail:&nbsp;' + mail + '</a></li>'
	+ '<li>URL:&nbsp;' + url + '</li>'
	+ '</ul></div>';

}
function closePreview() {
  document.getElementById("wbpreview").innerHTML = '<h5 class=\"wbtitle\">Preview comment</h5></div>';
  location.href='#comment_post';
}
