Wont give up on this border thing:)
I would try to fix this with classes.
On the index page #content and #sidebar wouldn’t have borders defined in id but in another class.
Then, whenewer you want a border to be on sidebar or on content, just add class to an element.
for instance in the article page: