diff --git a/inc/html.php b/inc/html.php
index 982d01860bd9f12f1eec3e105f8a726436e7fef1..43ab397d06f8cd1c3b4e355a2139ee79e2796708 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -1434,4 +1434,81 @@ function html_form_output($data) {
   $data->printForm();
 }
 
+/**
+ * Embed a flash object in HTML
+ *
+ * This will create the needed HTML to embed a flash movie in a cross browser
+ * compatble way using valid XHTML
+ *
+ * The parameters $params, $flashvars and $atts need to be associative arrays.
+ * No escaping needs to be done for them. The alternative content *has* to be
+ * escaped because it is used as is. If no alternative content is given
+ * $lang['noflash'] is used.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @link   http://latrine.dgx.cz/how-to-correctly-insert-a-flash-into-xhtml
+ *
+ * @param string $swf      - the SWF movie to embed
+ * @param int $width       - width of the flash movie in pixels
+ * @param int $height      - height of the flash movie in pixels
+ * @param array $params    - additional parameters (<param>)
+ * @param array $flashvars - parameters to be passed in the flashvar parameter
+ * @param array $atts      - additional attributes for the <object> tag
+ * @param string $alt      - alternative content (is NOT automatically escaped!)
+ * @returns string         - the XHTML markup
+ */
+function html_flashobject($swf,$width,$height,$params=null,$flashvars=null,$atts=null,$alt=''){
+    global $lang;
+
+    $out = '';
+
+    // prepare the object attributes
+    if(is_null($atts)) $atts = array();
+    $atts['width']  = (int) $width;
+    $atts['height'] = (int) $heigh;
+    if(!$atts['width'])  $atts['width']  = 425;
+    if(!$atts['height']) $atts['height'] = 350;
+
+    // add object attributes for standard compliant browsers
+    $std = $atts;
+    $std['type'] = 'application/x-shockwave-flash';
+    $std['data'] = $swf;
+
+    // add object attributes for IE
+    $ie  = $atts;
+    $ie['classid'] = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
+
+    // open object (with conditional comments)
+    $out .= '<!--[if !IE]> -->'.NL;
+    $out .= '<object '.buildAttributes($std).'>'.NL;
+    $out .= '<!-- <![endif]-->'.NL;
+    $out .= '<!--[if IE]>'.NL;
+    $out .= '<object '.buildAttributes($ie).'>'.NL;
+    $out .= '    <param name="movie" value="'.hsc($swf).'" />'.NL;
+    $out .= '<!--><!--dgx-->'.NL;
+
+    // print params
+    if(is_array($params)) foreach($params as $key => $val){
+        $out .= '  <param name="'.hsc($key).'" value="'.hsc($val).'" />'.NL;
+    }
+
+    // add flashvars
+    if(is_array($flashvars)){
+        $out .= '  <param name="flashvars" value="'.hsc(buildURLparams($flashvars)).'" />'.NL;
+    }
+
+    // alternative content
+    if($alt){
+        $out .= $alt.NL;
+    }else{
+        $out .= $lang['noflash'].NL;
+    }
+
+    // finish
+    $out .= '</object>'.NL;
+    $out .= '<!-- <![endif]-->'.NL;
+
+    return $out;
+}
+
 //Setup VIM: ex: et ts=2 enc=utf-8 :
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php
index e206f2fc95333b66f95997cd43909e7e2a6537bf..0f270d3ee692606a694eaad36c5f47ed2770d281 100644
--- a/inc/lang/en/lang.php
+++ b/inc/lang/en/lang.php
@@ -149,6 +149,7 @@ $lang['created']    = 'created';
 $lang['restored']   = 'old revision restored';
 $lang['external_edit'] = 'external edit';
 $lang['summary']    = 'Edit summary';
+$lang['noflash']    = 'The <a href="http://www.adobe.com/products/flashplayer/">Adobe Flash Plugin</a> is needed to display this content.';
 
 $lang['mail_newpage']  = 'page added:';
 $lang['mail_changed']  = 'page changed:';
diff --git a/inc/parser/xhtml.php b/inc/parser/xhtml.php
index 565459220d6f8ba5fc42a2815ca5ba3803c112de..bad1a21dedc97f56dc4bee6ab3df4bd7512c0d94 100644
--- a/inc/parser/xhtml.php
+++ b/inc/parser/xhtml.php
@@ -966,26 +966,20 @@ class Doku_Renderer_xhtml extends Doku_Renderer {
                 // return the title of the flash
                 if (!$title) {
                     // just show the sourcename
-                    $title = $this->_xmlEntities(basename(noNS($src)));
+                    $title = basename(noNS($src));
                 }
-                return $title;
+                return $this->_xmlEntities($title);
             }
 
-            $ret .= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'.
-                    ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"';
-            if ( !is_null($width) ) $ret .= ' width="'.$this->_xmlEntities($width).'"';
-            if ( !is_null($height) ) $ret .= ' height="'.$this->_xmlEntities($height).'"';
-            $ret .= '>'.DOKU_LF;
-            $ret .= '<param name="movie" value="'.ml($src).'" />'.DOKU_LF;
-            $ret .= '<param name="quality" value="high" />'.DOKU_LF;
-            $ret .= '<embed src="'.ml($src).'"'.
-                    ' quality="high"';
-            if ( !is_null($width) ) $ret .= ' width="'.$this->_xmlEntities($width).'"';
-            if ( !is_null($height) ) $ret .= ' height="'.$this->_xmlEntities($height).'"';
-            $ret .= ' type="application/x-shockwave-flash"'.
-                    ' pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>'.DOKU_LF;
-            $ret .= '</object>'.DOKU_LF;
-
+            $att = array();
+            $att['class'] = "media$align";
+            if($align == 'right') $att['align'] = 'right';
+            if($align == 'left')  $att['align'] = 'left';
+            $ret .= html_flashobject($src,$width,$height,
+                                     array('quality' => 'high'),
+                                     null,
+                                     $att,
+                                     $this->_xmlEntities($title));
         }elseif($title){
             // well at least we have a title to display
             $ret .= $this->_xmlEntities($title);