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>';
        output += '<ul>';		
		var myCategories = this.subCategories.getElementsByTagName("NAME");
		var myCatIds = this.subCategories.getElementsByTagName("ID");
		
		if (this.linksToDisplay > myCategories.length){
			this.linksToDisplay = myCategories.length;
		}
		var trimmed = '';
        for (var i=0; i< this.linksToDisplay; i++){
        	trimmed = myCategories[i].childNodes[0].nodeValue.toString().replace(regEx,'');
	       	output += '<li><a href="#" onclick="filterArchiveBySubCategory(\''+
        	myCatIds[i].childNodes[0].nodeValue + '\'); updateArchiveSubCategories(\'' + 
        	myCatIds[i].childNodes[0].nodeValue +'\',\'' + 
        	trimmed + '\')">' + 
        	trimmed + '</a></li>';
        	counter += 1;
        }
		if (myCategories.length > this.linksToDisplay){
    		output += '<a href="#" class="goBack" onclick="buildHiddenPanel(\'categoriesContent\',\'subCategories\'); dijit.byId(\'categoriesDialog\').show()">Display All</a>';
		}
        output += '</ul>';
        if (counter == 0){
        	output = "No subcategories available";
        }
        dojo.byId('categories1').innerHTML = output;
        //dojo.byId('categories1').style.width = '180px';
        //dojo.narrow('categories1',180);
        //dojo.byId('subCategoriesColumn').style.display = 'block';
	},
	
	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;
	}
});