title: I can't figure out how to close a simple popup
body: <p>Sorry, for the simplistic question.
  I am not sure if all of this is important or not, but I will mention it just in case. : When a user clicks a link, this is what happens:</p>
  
  <pre><code>function begin(some info) is called-&gt;Makes an Ajax request to backend PHP-&gt;
  PHP calls the callback function-&gt;Callback function calls another JS function that creates a popup-&gt;
  In the popup creating function, The Save button is assigned a function that makes an ajax request and sends PHP some user input.-&gt;
  PHP makes a callback to another function that does nothing.
  </code></pre>
  
  <p>Here, this is the function that puts together the popup box.</p>
  
  <pre><code>function collection(name, description, data){
      var json = data;
      var cont = openSitePopup("400","300");
      //We create div objects.
      var namecell = ce("div","sitePopupCell");   
      //Stuff
      // We create a button and assign the createProducts Method to it.
      var sbtbutton = createBtn("submitObject","SAVE","createProducts()");
      //We append all the div objects to the popup.   
      cont.appendChild(namecell);
      //..
  }
  
  function openSitePopup(width,height) {
  
  //try to center the popup if values are not passed
  var xPos = (getWinWidth()/2) - (width/2) + sl;
  var yPos = (getWinHeight()/2) - (height/2) + st;
  
  sitepopupwin = ge("sitePopupWin");
  clearElement(sitepopupwin);
  
  var winhandle = ce("div","","sitePopupHandle");
  
  sitepopupwin.style.display = "block";
  //Other style assignments.  
  
  //closebutton
  var close = ce("img","sitePopupCloseBtn");
  close.setAttribute("src",theme_path + "/images/icons/close.png");
  
  //start adding goodies
  var mydiv = ce("div","sitePopupContainer");
  
  winhandle.appendChild(close);
  winhandle.appendChild(createCleaner());
  sitepopupwin.appendChild(winhandle);
  sitepopupwin.appendChild(mydiv);
  
  //return reference to the container for adding stuff
  return mydiv;
  }
  
  function createProducts()
  {
      //Some exciting Ajax stuff with a callback to writeNewFolder()
  }
  
  function writeNewFolder(data){
      //Nothing of interest here...yet.
  }
  </code></pre>
  
  <p>Now, when I press the <code>Save</code> button on the popup, the request is made successfully, but the popup does not close. I know of the <code>Window.Close()</code> function, but it didn't work. <code>cont.Close()</code> seems like an obvious choice, but in that case, I get this error: <code>Uncaught TypeError: Object #&lt;HTMLDivElement&gt; has no method 'Close'</code> So, Cont is only a div element. The <code>openSitePopup()</code> method only returns a div.  </p>
  
  <p>Thanks for all your help.</p>
  
  <p>edit:</p>
  
  <pre><code>function ce(elementType,elementClass,elementId,txt) {
  
  var e = document.createElement(elementType);
  
  //add optional parameters
  if (elementId) e.setAttribute("id",elementId);
  if (elementClass) setClass(e,elementClass);
  
  //append extra text.  If passed an object, append with without the textnode wrapper
  if (isData(txt)) {
      if (typeof(txt)=="object") e.appendChild(txt);
      else e.appendChild(ctnode(txt));
  }
  
  return e;
  
  }
  </code></pre>
  
  <p>Hopefully the original creator does not mind me posting some of his code here. Well, it's free and open source, so it should be fine...I think.</p>
  
  <p>edit 2: The <code>ge</code> function. This one is simple.</p>
  
  <pre><code>function ge(element) {
  return document.getElementById(element);
  }
  </code></pre>