dojo.declare("com.mgh.ArchiveSubCategories",[com.mgh.SubCategories], {
	constructor : function(configParams) {
		this.getXmlString();
		this.previousCat;
	},
	updateQuery : function()
	{
		var m = this.queryParams;
		this.query = m.href + '?az=' + m.az + '&age=' + m.age + '&cat=' + m.cat +  '&subcat=' + m.subcat + '&type=' + m.type + '&query=' + m.query + 
		'&month=' + (m.month + 1) + '&audience=' + m.audience + '&eventType=' + m.eventType + '&mediaType=' + m.mediaType + '&newsType=' + m.newsType + 
		'&year=' + m.year + '&topic=' + m.topic;
		//alert(this.query);
	}, 
		
	buildSubCategories : function (){
		var counter = 0;
		var output = '';
		var regEx = /\(.*\)/;
		var output = '<h3>Topic:</h3><ul>%1</ul>';
		var link = '<li><a href="#" onclick="filterArchiveBySubCategory(\'%1\'); updateArchiveSubCategories(\'%1\',\'%2\')">%2</a></li>';
		var links = '';
		var categoryNames = this.subCategories.getElementsByTagName("NAME");
		var categoryIds = this.subCategories.getElementsByTagName("ID");
		var categoryId;
		var categoryName;
		
		if (this.linksToDisplay > categoryNames.length){
			this.linksToDisplay = categoryNames.length;
		}

		//Modification 6/23/2010: 
		//The first category is the data type so start from index 1.
        for (var i=1; i< this.linksToDisplay; i++){
        	categoryName = categoryNames[i].childNodes[0].nodeValue.toString().replace(regEx,'');
			categoryId = categoryIds[i].childNodes[0].nodeValue
			links += formatString(link,categoryId,categoryName);
        	counter += 1;
        }
		if (myCategories.length > this.linksToDisplay){
    		output += '<a href="#" class="goBack" onclick="buildHiddenPanel(\'categoriesContent\',\'subCategories\'); dijit.byId(\'categoriesDialog\').show()">Display All</a>';
		}

        output = counter == 0 ? "No subcategories available" : formatString(output,links);
        dojo.byId('categories1').innerHTML = output;
	},
	
	updateSubCategories : function (id,nodeName){
		var output = '<h3>Topic:</h3>';
        output += '<ul>';
		var nodes = dojo.query('li', id);
		output += '<li id="' + nodeName + '" class="active"><strong>' + nodeName + '</strong></li>';
		output += '<li><a href="#" class="goBack" onclick="removeFilter(\'archiveSubCategories\')">Show all topics</a></li>';
		output += '</ul>';
		dojo.byId('categories1').innerHTML = output;
		this.previousCat = id;
	}
});