/*
 * $URL:$
 * $Id: versionbrowse.js 54922 2009-06-13 17:00:30Z tripod $
 *
 * Copyright (c) 1997-2005 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */


/**
 * VersionBrowse constructor.
 */
function VersionBrowse(/*string*/name) {
	this.name = name;
}

//-----------------------------------------------------------------------------
// static members
VersionBrowse.docroot = "";

/** map containing all the registred browse controls */
VersionBrowse.controls = new Object();

/**
 * Creates a new NodeTree and puts it into the control registry
 * @param name     name of new node tree
 * @param provider the html provider
 * @param levelURI the location to fetch level data
 *
 * @return newly created node tree instance
 */
/*NodeTree*/ VersionBrowse.create = function(/*string*/ name) {
	return this.controls[name] = new VersionBrowse(name);
};

/**
 * Returns the tree control with the given name
 * @param name the name of the control to return
 *
 * @return the tree control with the given name
 */
/*NodeTree*/ VersionBrowse.getControl = function(/*String*/ name) {
	return this.controls[name];
};



//-----------------------------------------------------------------------------
// static functions

/*void*/ VersionBrowse.setDocroot = function(/*String*/ docroot) {
    this.docroot = docroot;
};

/**
 */
/* void */ VersionBrowse.prototype.browse = function(/*string*/path, /*function */ callback) {
    this.callback = callback;
    this.value = path;
    var uri = VersionBrowse.docroot + "/ui/versionbrowse.jsp";
    uri+= "?ck=" + new Date().valueOf();
    uri+= "&Name=" + encodeURIComponent(this.name);
    uri+= "&Path=" + encodeURIComponent(path);
    uri+= "&_charset_=utf-8";
    if (false && window.showModalDialog) {
    	// IE only
	var feat = "scroll:No; resizable:Yes; status:No; dialogHeight:450px; dialogWidth:690px;";
    	this.close(window.showModalDialog(uri, "", feat));
    } else {
	//var feat = "scroll:no, resizable:yes, status:no, windowheight:250px, windowwidth: 600px,dialog";
	var feat = "scroll=no, height=450, width=690, dialog, resizable=yes";
    	var w = window.open(uri, "versionbrowser", feat);
    }
};

/*void*/VersionBrowse.prototype.close = function(/*String*/value) {
    this.value = value;
    if (this.callback) {
    	this.callback(this);
    }
};