Just an idea:
try removing
<div id="footer">...</div>
from
<div id="main">...</div>
, so put it outside and give the footer a fixed position.
#footer{position:fixed}
I'm not really quite sure but you can give a try.
The fact that the height of the main content is 100%
the other way I managed to resolve this issue is just expanding the width of the enclosing divs for the thankyou/error, but you don't want this solution.
Keep in mind, by placing the footer stick to the bottom, you will need to give a white background if you don't want to expand the enclosing divs for the thankyou/error, because it will place out of the main content
Hope this give you a lil' idea