var downloadbrowser = {

	
	createTransport: function(){
		if( typeof(this.ajax) != "object" ) {
			try {
				this.ajax = new XMLHttpRequest();
			}
			catch (e) {
				try {
					this.ajax = new ActiveXObject("Microsoft.XMLHTTP");
				}
				catch (e) {
					try {
						this.ajax = new ActiveXObject('Msxml2.XMLHTTP');
					}
					catch (e) {
						return false;
					}
				}
			}
		}
		return true;
	},

	catalogs: function(sectionId, sectionName) {
		sectionName = sectionName || "";
		sectionId = sectionId || "0";
		this.createTransport();
		this.ajax.open('GET', 'catalogs_engine.asp?section_id='+sectionId+'&section_name='+sectionName);
		this.ajax.onreadystatechange = this.updateCatalogs.bind(this);
		this.ajax.send(null);
		document.cookie = "catalogbrowser = "+sectionId+"|"+sectionName
	},

	updateCatalogs: function() {
		switch( this.ajax.readyState ) {
		case 1:
			//this.tool.firstChild.innerHTML = "<img src=\"images/waiting.gif\" width=\"40\" height=\"40\">";
			break;
		case 4:
			var e = $("ax_catalogs");
			e.innerHTML = this.ajax.responseText;
			//toolbar.fxt[0].adjust();
			break;
		}
	},
	
	drawings: function(root) {
		root = root || "/";
		this.createTransport();
		this.ajax.open('GET', 'drawings_engine.asp?root='+root);
		this.ajax.onreadystatechange = this.updateDrawings.bind(this);
		this.ajax.send(null);
		document.cookie = "drawingbrowser = "+root
	},

	updateDrawings: function() {
		switch( this.ajax.readyState ) {
		case 1:
			//this.tool.firstChild.innerHTML = "<img src=\"images/waiting.gif\" width=\"40\" height=\"40\">";
			break;
		case 4:
			var e = $("ax_files");
			e.innerHTML = this.ajax.responseText;
			//toolbar.fxt[0].adjust();
			break;
		}
	}
	
}