I've got an insert Link to File script for a text area replacement that I'm trying to get to function properly. Everything works except the ability to create a new folder. Here's how the folder functions look from start to finish, across a couple different files:

newfolder.html (dialog box to take user's folder name input)
Code:
function onOK()
{
	 // pass data back to the calling window
  var fields = ["f_foldername"];
  var param = new Object();
  for (var i in fields) {
     var id = fields[i];
    var el = MM_findObj(id);
    param[id] = el.value;
  }
  __dlg_close(param);
  return false;
}
initializes dialog box, then passes information to newFolder function in files.php
Code:
function newFolder()
{
	var selection = document.forms[0].dirPath;
	var dir = selection.options[selection.selectedIndex].value;
	Dialog("newFolder.html", function(param) {
		if (!param) {
		// user must have pressed Cancel
		return false;
		}
		else
		{
			var folder = param['f_foldername'];
			if (folder && folder != '') {
			imgManager.newFolder(dir,folder);
			}
		}
	}, null);
}
Code:
function newFolder(oldDir, newFolder)
{
	location.href = "files.php?dir="+oldDir+"&foldername="+newFolder+"&create=folder";
}

if(isset($HTTP_GET_VARS['create']) && isset($HTTP_GET_VARS['dir']))
{
	create_folder();
}

function create_folder()
{
	global $BASE_DIR, $FILE_ROOT, $refresh_dirs;
	$folder_name = $HTTP_GET_VARS['foldername'];

	if(strlen($folder_name) > 0)
	{
		$folder = $BASE_DIR.$FILE_ROOT.$folder_name;
		if(!is_dir($folder) && !is_file($folder))
		{
			mkdir($folder,0755);
			$refresh_dirs = true;
		}
	}
	else echo "Folder name is empty";
}
The folder name makes it to files.php, but disappears after refreshing here: location.href = "files.php?dir="+oldDir+"&foldername="+newFolder+"&create=folder";

I'm not sure why... can anyone help me out? I'm wondering if I'm just missing something incredibly obvious, but I just can't figure it out.