Skillopedia_CategoriesList = new function()
{
	this.Subcategories = new Array();
	this.Category = null;
	this.Max = 15;
	
	this.Prefix = "<ul class='category'>";
	this.Suffix = "</ul>"
	
	this.selectCategory = function(object, level, id)
	{
	    data = '';
	
	    max = this.Max;
	    num = this.Subcategories[id].length;
	
	    middle  = Math.round(num/2);
	    remains = num - middle;
	
	    if ( level + remains > max )
	    {
	        offset = max - num;
	    }
	    else if ( middle >= level )
	    {
	        offset = 0;
	    }
	    else offset = level-middle;
	
	    for(i=0; i<offset; i++)
	    {
	        data += '<li>&nbsp;</li>';
	    }
	
	    for(i=0; i<num; i++)
	    {
	        tmp = this.Subcategories[id][i];
	
	        if ( tmp[1] == 'skip' || tmp[1] != 0 )
	        {
	            if ( tmp[1] != 'skip' )
	            { 
	               data += "<li><a href='category.php?id="+tmp[2]+"' rel='nofollow'><nobr>"+tmp[0]+"</nobr></a><span>"+tmp[1]+"</span></li>";
	            }
	            else
	            {
	                data += "<li><a href='category.php?id="+tmp[2]+"' rel='nofollow'><nobr>"+tmp[0]+"</nobr></a></li>";
	            }
	        }
	    }
	
	    document.getElementById('subcategories').innerHTML = this.Prefix+data+this.Suffix;
	
	    if ( this.Category )
	    {
	        this.Category.className = '';
	    }

	    object.className = 'active';
	
	    this.Category = object;
	}
}
