1) Some of the calls to str_replace() have four arguments. I thought that function only had three arguments?
$Body =str_replace("[align left]","<p align=left>",$Body,"</p>");
2) If you want the converted HTML to be XHTML-compliant, the attribute values need to be quoted (I think). For example:
$Body =str_replace("[align left]","<p align="left">",$Body,"</p>");
$Body =str_replace("<p align="left">","[align left]",$Body,"</p>");