I have a wonderfully-laid-out magazine and I want to export it into EPUB format so I can sell a digital version. I want it to look exactly the same. But when I export it with InDesign, the EPUB file comes out a complete mess, with pictures and text mixed up in all the wrong places.
Isn't this supposed to be the leading publishing software? Why is it doing this to me? Is there more I need to know; is there something I'm doing wrong?
Short answer: Exporting to EPUB is a completely different animal than printing or exporting to PDF.
EPUB is a reflowable format. Only one text stream can be exported, and graphics, sidebars, etc. must be anchored in the text stream. There are some objects which are not exported at all unless you do some preparation work. It's essential that everything should be styled (paragraph styles, character styles, object styles, table and cell styles).
Export order is determined by the settings in EPUB Export dialog. If you choose the default, InDesign exports objects from left to right, top to bottom. Graphics which are not inline or anchored will end up at the bottom, most likely. A story will be exported in its entirety before that non-anchored objects which appear to be within it. But you can fix this by using the CS5.5 Articles panel.
You also need to learn how to set up a navigational TOC for your EPUB, include metadata, and use settings to set page breaks. (Just because you start a new page in the print file with a new page, that doesn't mean it will create a new EPUB page which requires creating a new XHTML file.
You have a lot to learn. I'd suggest starting with either the eBooks of Liz Castro:
Or Anne-Marie Concepcion's excellent videos on Lynda.com. (If Bob Levine stops by and sees this, he can give you a link for a few week.)
And, there's a great new book by Sandee Cohen and Diane Burns called "Digital Publishing in InDesign CS6" (Adobe Press, just came out). I wrote the EPUB chapter which gives you some starting tips.