var Zoom = {
    folded: new Array(),
    connector: null,
    method: 'post',
    treenode: null,
    treePinned: true,
    treeDrag: null,
    treePos: null,
    treeCaptionPos: null,
    treeObj: null,
    req_uri: 'ajaxcallback.php',
    site_uri: '',
    activeCat: '0',
    activeSubcat: '0',
    element:null,
    site_id:null,
    p:null,
    start_id:0,
    
    getGalleryTree :
    function(elmnt) {
        if (!elmnt) elmnt = 'cats_tree';
        this.treenode = elmnt;
        var params = 'comp='+this.p+'&action=get_cat_tree&site_id='+this.site_id+'&album_id='+this.start_id;
		new Ajax.Request(this.req_uri, {
            method: this.method,
            parameters: params,
            onSuccess: this.buildTree});
    },
    buildTree : 
    function(callback) {
        $('cats_tree').innerHTML = "";
        Zoom.treeObj = new JSDragDropTree();
        Zoom.treeObj.setTreeId('cats_tree');
        Zoom.treeObj.setUserFunction('onItemSelect', function(){
            var item = this;
            if (item.nodeName.toLowerCase() == "img" || item.nodeName.toLowerCase() == "a")
                item = item.parentNode; 
            var id = item.id.replace(/node/, '');
			Zoom.ongalleryclick(id,'text');
        });
        Zoom.treeObj.initTree('xml', callback.responseXML);
    },
    ongalleryclick :
    function (id,target) {
    	main.show_loader(target,'<p>Itemdetails worden geladen</p>');
    	var params = 'comp='+this.p+'&action=load_itemdetail&catid='+id+'&site_id='+this.site_id;
        this.connector = new Ajax.Updater(target,this.req_uri, {
            method: this.method,
            encoding: this.charset,
            parameters: params,
            asynchronous:0
        });
    }
}
