

function AttributesPopupTab() {
	this.objControlList = new AttributesControlList();
	this.strDisplayName = '';
	this.strGroupId = '';
	this.intParentId = -1;
	this.intParentValue = -1;
	this.blnVisible = true;
	
	this.addControl = function (objControl){
		this.objControlList.addControl(objControl);
	}
	
	this.getUrlParam = function (){
		if (this.blnVisible){
			return this.objControlList.getUrlParam();
		}
		return '';
	}
	
	this.resetState = function (){
		return this.objControlList.resetState();
	}
	
	this.updateControls = function (){
		return this.objControlList.updateControls();
	}
	
	this.setDisplayName = function (strName){
		this.strDisplayName = strName;
	}
	
	this.setGroupId = function (strGroupId){
		this.strGroupId = strGroupId;
	}
	
	this.displayTab = function (strGroupId){
		if (strGroupId != this.strGroupId){
			return false;
		}
		document.getElementById('ap_title').innerHTML = this.strDisplayName;
		document.getElementById('ap_left_content').innerHTML = this.objControlList.getHtml();
		return true;
	}
	
	/**
	 * Check if the tab has no visible controls
	 */
	this.isEmpty = function (){
		return this.objControlList.isEmpty();
	}
	
	this.getButton = function (strGroupId){
		if (!this.blnVisible && this.isEmpty()){
			return '';
		}
		if (this.strGroupId == strGroupId){
			return '<li class="active">'+this.strDisplayName+'</li>';
		}
		return '<li><a href="javascript:;" onclick="AttributesPopup.displayTab(\''+this.strGroupId+'\');" >'+this.strDisplayName+'</a></li>';
	}
	
	this.getState = function (intControlId){
		return this.objControlList.getState(intControlId);
	}
	
	this.getAttributeId = function (intControlId){
		return this.objControlList.getAttributeId(intControlId);
	}
	
	this.getParent = function (intControlId){
		return this.objControlList.getParent(intControlId);
	}
	
	this.getValue = function (intControlId){
		return this.objControlList.getValue(intControlId);
	}
	
	this.changeState = function (intControlId, mixNewState){
		return this.objControlList.changeState(intControlId, mixNewState);
	}
	
	this.updateState = function (intAttributeId, intAttributeValue){
		return this.objControlList.updateState(intAttributeId, intAttributeValue);
	}
	
	this.hideDependent = function (intParentId, intParentValue){
		if (this.intParentId == intParentId && this.intParentValue == intParentValue){
			this.blnVisible = false;
		}
		this.objControlList.hideDependent(intParentId, intParentValue);
	}
	
	this.hideDependentFilters = function (intParentId, intParentValue){
		if (this.intParentId == intParentId && this.intParentValue == intParentValue){
			this.blnVisible = false;
			document.getElementById('atg_'+this.strGroupId).style.display = 'none';
		}
		this.objControlList.hideDependentFilters(intParentId, intParentValue);
	}
	
	this.showDependent = function (intParentId, intParentValue){
		if (this.intParentId == intParentId && this.intParentValue == intParentValue){
			this.blnVisible = true;
		}
		this.objControlList.showDependent(intParentId, intParentValue);
	}
	
	this.hideDependentByAttributeId = function (intAttributeId){
		if (this.intParentId == intAttributeId){
			this.blnVisible = false;
		}
		this.objControlList.hideDependentByAttributeId(intAttributeId);
	}
	
	this.setParent = function (intParentId, intParentValue){
		this.intParentId = intParentId;
		this.intParentValue = intParentValue;
	}
	
	this.updateFilters = function (){
		if (!this.blnVisible){
			document.getElementById('atg_'+this.strGroupId).style.display = 'none';
		}
		if (this.objControlList.hasActiveFilters()){
			this.objControlList.rebuildFilters(this.strGroupId);
			document.getElementById('atfe_'+this.strGroupId).style.display = 'none';
			document.getElementById('atfc_'+this.strGroupId).style.display = '';
			document.getElementById('atgv_'+this.strGroupId).style.display = '';
			document.getElementById('atm_'+this.strGroupId).style.display = '';
		} 
//		if (this.objControlList.getFiltersCount() == this.objControlList.getInactiveFiltersCount()){
//		if (document.getElementById('atgm_'+this.strGroupId).innerHTML.length == 1){
//			document.getElementById('atm_'+this.strGroupId).style.display = 'none';
//		}
	}
	
	this.build = function (){
		this.objControlList.build();
	}
	
	this.dump = function (){
		return '<ul><li>AttributesPopupTab<ul>'
					+'<li>strDisplayName = '+this.strDisplayName+'</li>'
					+'<li>strGroupId = '+this.strGroupId+'</li>'
					+'<li>intParentId = '+this.intParentId+'</li>'
					+'<li>intParentValue = '+this.intParentValue+'</li>'
					+'<li>blnVisible = '+(this.blnVisible?'true':'false')+'</li>'
					+'<li>objControlList = '+(this.objControlList==null?'null':this.objControlList.dump())+'</li>'
					+'</ul></li></ul>';
	}
}