Vault in Windows

I have a vault loaded into a window and am facing a small issue.

When I initially open the window, the vault loads using attachObject() just fine. However whenever I close the window and try to reopen it, I get the following errors.

Message: Object required
Line: 14
Char: 58
Code: 0
URI: dhtmlxvault.js

My code is as follows.

// Create Vault
function CreateVault(){
        vault=new dhtmlXVaultObject();
        vault.setImagePath("dhtmlx/imgs/");
        vault.setServerHandlers("UploadHandler.php","GetInfoHandler.php","GetIdHandler.php");
        vault.onUploadComplete = function(files) { myGridUpload.updateFromXML("fileslistconnector.php");}; 
        vault.create("vaultDiv");
}

// Create Window
function UploadFiles(){
        CreateVault();
	    dhxWins = new dhtmlXWindows();
	    dhxWins.enableAutoViewport(false);
	    dhxWins.attachViewportTo("parentId");
	    dhxWins.setImagePath("dhtmlx/imgs/");
		UploadWindowContainer = dhxWins.createWindow("UploadWindowContainer", 200, 200, 400, 240);
	    UploadWindowContainer.setText("Upload Files");
		dhxWins.window("UploadWindowContainer").center();
		dhxWins.window("UploadWindowContainer").denyResize();
		dhxWins.window("UploadWindowContainer").setModal(true);
		Uploadobj = document.getElementById("vaultDiv");
		dhxWins.window("UploadWindowContainer").attachObject(Uploadobj);
}

// Launch Window
onclick='UploadFiles()'

I figured it out … stupid me kept recreating the vault instance in an attempt to reuse it.

Resolved problem by just putting a condition that checks for the existence of the object, if it exists then do thing, else create it.(so easy a cave man could so it!)

if(!vault)CreateVault();

so freaking simple … K.I.S.S.

yes. thank you.