detach and insert after

detach and insert after

My goal is to remove 2 sections if someone resizes a window to less than 647px and re-add them if they resize to at least 647px. The code I have to remove the sections has worked great, but adding them again is not going so well. I cannot do this with a media query because of a plugin I'm using. Here is what I have so far:

  1.     // CHECKS WINDOW SIZE AND ADDS/REMOVES MUSIC & PHOTOS
  2.     var $window = $(window);
  3.     var $pane = $('#pane1');

  4.     function checkWidth() {
  5.         var windowsize = $window.width();
  6.         if (windowsize < 647) {
  7.             //if the window is greater than 647px wide then turn on jScrollPane..
  8.             $(".section-music, .section-photos").each(function() {
  9.                 $(this).detach();
  10.             });
  11.             $.scrollify.update();
  12.         }
  13.         if (windowsize >= 647) {
  14.             //if the window is greater than 647px wide then turn on jScrollPane..
  15.             $(".section-music").insertAfter(".section-about");
  16.             $.scrollify.update();
  17.         }
  18.     }
  19.     
  20.     // Execute on load
  21.     checkWidth();
  22.     // Bind event listener
  23.     $(window).resize(checkWidth);
Any ideas on how I can get the sections to add again? Thanks much!