swapping divs with .after()

swapping divs with .after()

Hey guys,
I want to swap two <div>s and decided to use the .after() method to swap them.

My problem is, that the first div contains javascript, what cause an error.
When I use two different divs with only html it works easily, but not with the script-contained-div.

I'm sorry for my bad English, I think I can't explain my problem very good, so I attached 2 images which could explain my problem a bit furhter.
Also here is a link to a testsite I set up, where you can find the source I used.
-> Testsite

I think the problem has to do with the fact that the javascript is loaded from an other site(?), other loaded javascripts like e.g. teamspeak3-viewer doesn't work, too.