cartData = function(ID){
	var count = $("#Product_"+ID+" > td .count").attr('value');
	cart.add(ID,count);
};

function catTree(initSettings){
    try{
        if(typeof(initSettings.selector) != 'undefined' ){ 
            this.selector = initSettings.selector} else {throw "xz"}
    }catch(e){this.selector = '.treeview'}
   
	
	
	/*$("li.lvl_1 .hitarea",this.selector).click(function(){
		$(this.selector+" li.lvl_1 a").each(function(){
			if ($(this).css('color') == '#FFFFFF')
				$(this).css({'color':'#353535'})
		})
		if (($(this).next().css('color') == '#353535'))
			$(this).next().css({'color':'#FFFFFF'})
	})*/
	
	$(this.selector).treeview({
		collapsed: true,
		persist: "location",
		animated: "fast",
		open: "open",
		unique:true
	});
	
	$("a",this.selector).hover(
		function(){
			$(this).css({'text-decoration': 'none'})
		},
		function(){
			$(this).css({'text-decoration': 'underline'})
	});
	
	$("li.lvl_1 > a",this.selector).click(function(){
		$(this).parent().find('.hitarea').trigger('click')
		return false;
	});
    
    this.treeToggler = function(ID){
    	console.log(ID)
    	
    	
    	/*$("li.lvl_1 > a",this.selector).click(function(){
			if ($(this).parent().find("ul").is(":visible")){
			//console.log('true')
				$(this).parent().find('.hitarea').trigger('click');
			}
		});*/
    }
    
	this.open = function(branches){
		for (var i = 0;i < branches.length;i++) {
			$("#Category_"+branches[i]).filter(".expandable").find("div.hitarea").trigger('click');
		}
	};

	this.setCurrent = function(id){
		$(this.selector +' .selected').removeClass("selected");
		$('#Category_'+id+' > a').addClass('selected');
	}
	
	this.loadProducts = function(id){
		
		window.location.hash='Category='+id;
    	ajax.AjaxContentRequest({
		    url: '/shop_catalog/GetByCID/',
		    data: "ID="+id,
		    target: '#catalogContent',
		    callback: function(data){
		        window.scrollTo(0,200);
		    	catTree.setCurrent(id);
		    	paginator.paginate(data.paging);
			    /*if(typeof data.comments != "undefined"){
		    		comments.setComments(data.comments);
		    	}else{
		    		comments.hide();
		    	}*/
		    }
		});			
	}
}

 function cartAdd(id,obj){
            cart.add(id,1,obj);
        }
