HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy
===

I am trying to figure out why I am getting: "*HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy*", when my back button is clicked. The script works great, well decent for a ruff draft, but I cannot get my CSS to revert back to its previous state before the map-container.click event. My Google API map pops up perfectly full screen, hides all other divs, it edits the current CSS body to "*overflow: hidden*" as I wanted it to, but I cannot get it to revert back to "*overflow: visible*". I have read from other people with the same problem as me and their consensus is that I need to specifying a "dataType: html". Does anyone know where/ how to include this in my current script, that is, if declaring the data type is the solution? I am very new to JS so please walk me through this if at all possible. Thank in advance for your time and consideration. 

   


    $(document).ready(function expand() { 
    var div = $('div#map-container'); //DIV TO EXPAND FULLSCREEN AS TO CSS STYLE 
    var beforeFullscreen = "";

     $('#map-container').click(function() //EVENT TO LISTEN FOR
    {	
        if (!div.hasClass('fullscreen'))
   	  {
         beforeFullscreen = {
	 	 parentElement: div.parent(),
	 	 index: div.parent().children().index(div),
	 	 x: $(window).scrollLeft(), y: $(window).scrollTop()
	     };

	     $('html').css('overflow', 'hidden');
	     $('body').css('overflow', 'hidden');
	     $('body').append(div).css('overflow', 'hidden');
	     //$('#map-container').append(div).css('height', '100%');
	     div.addClass('fullscreen');
	     window.scroll(0,0);
	     initialize();	                                                            $('#backButton').show(0);								
			$('#basic-info-textbox').hide(0);
			$('#display-name').hide(0);
			$('#utility-nav').hide(0);
			$('#main-nav').hide(0);
			$('#share-bar').hide(0);
			$('#top-bar').hide(0);
			$('#bottom-bar').hide(0);
			$('#content-box').hide(0);
			$('#markers').hide(0);	
		 
		 $('#backButton').click(function(e) {
			$('#backButton').hide(0);	    
			$('map-containerA').show(0);			
			$('#map-container').show(0);
			$('#basic-info-textbox').show(0);
			$('#display-name').show(0);
			$('#utility-nav').show(0);
			$('#main-nav').show(0);
			$('#share-bar').show(0);
			$('#top-bar').show(0);
			$('#bottom-bar').show(0);
			$('#content-box').show(0);		
		    
			div.removeClass('fullscreen');
		     if (beforeFullscreen.index >=                                          beforeFullscreen.parentElement.children().length) 
		     {
		        beforeFullscreen.parentElement.append(div);	        
	         } 
		     
			 else 
		  	 {
		        div.insertBefore(beforeFullscreen.parentElement.children().get(beforeFullscreen.index));
		     }
		     $('html').css('overflow', 'visible');
		     $('body').css('overflow', 'visible');
		  	 
		     window.scroll(beforeFullscreen.x, beforeFullscreen.y);	
		     return false;
		 });
   	  }
  	  
	  else 
   	  { 
         div.removeClass('fullscreen');
	     if (beforeFullscreen.index >= beforeFullscreen.parentElement.children().length) 
	     {
	        beforeFullscreen.parentElement.append(div);
         } 
	     
		 else 
	  	 {
	        div.insertBefore(beforeFullscreen.parentElement.children().get(beforeFullscreen.index));
	     }
	  
	     $('body').css('overflow', 'visible');
	  	 $('html').css('overflow', 'visible');
	     window.scroll(beforeFullscreen.x, beforeFullscreen.y);
      }          	
      return false;
   });
      
});

