/*
	SimpleNodeUI - extend the original TreeNodeUI for:
	(1) remove expand/minimize icon
	(2) remove icon
*/
Ext.tree.SimpleTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
		renderElements : function(n, a, targetNode, bulkRender){
			this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';

			var cb = typeof a.checked == 'boolean';

			var href = a.href ? a.href : Ext.isGecko ? "" : "#";
			var customizable = a.type == 'user' ? 'customizable ' : '';
	    var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ',customizable, a.cls,'" unselectable="on">',
        '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
		'<div class="x-tree-ec-icon x-tree-elbow-end-minus"></div>',
        '<span class="dummy"></span>',
        cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
        '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
         a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
        '<ul class="x-tree-node-ct" style="display:none;"></ul>',
        "</li>"].join('');

        var nel;
        if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
            this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
        }else{
            this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
        }
        
        this.elNode = this.wrap.childNodes[0];
        this.ctNode = this.wrap.childNodes[1];
        var cs = this.elNode.childNodes;
        this.indentNode = cs[0];
				this.ecNode = cs[1];
        var index = 2;
        this.anchor = cs[index];
        this.textNode = cs[index].firstChild;
    }
 });
 
 Ext.tree.CategoryTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
		renderElements : function(n, a, targetNode, bulkRender){
			this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';

  		var cb = typeof a.checked == 'boolean';

      var href = a.href ? a.href : Ext.isGecko ? "" : "#";
/*
		var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
        '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
        '<span class="dummy"></span>',
        cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
        '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
         a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
        '<ul class="x-tree-node-ct" style="display:none;"></ul>',
        "</li>"].join('');
*/
	
	var href = a.href ? a.href : Ext.isGecko ? "" : "#";
	    var buf = ['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
        '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
		'<div class="x-tree-ec-icon x-tree-elbow-end-minus"></div>',
		'<div class="btn_add" onclick="createNewPlaylist(this);"></div>',
        '<span class="dummy"></span>',
        cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
        '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
         a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
        '<ul class="x-tree-node-ct" style="display:none;"></ul>',
        "</li>"].join('');
	
        var nel;
        if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
            this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
        }else{
            this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
        }
        
        this.elNode = this.wrap.childNodes[0];
        this.ctNode = this.wrap.childNodes[1];
        var cs = this.elNode.childNodes;
        this.indentNode = cs[0];
				this.ecNode = cs[1];
        var index = 2;
        this.anchor = cs[index];
        this.textNode = cs[index].firstChild;
    }
 });
 
 
 /* SimpleTreeSelectionModel - change to ignore selection of cateogry */
 Ext.tree.SimpleSelectionModel = Ext.extend(Ext.tree.DefaultSelectionModel, {
 		onNodeClick: function(node, e) {
 			if (node.attributes.unselectable != true) {
 				this.select(node);
 			}
 		}
 });
 
 

