CompareGraphs = function(){}
CompareGraphs.prototype = newsi;
CompareGraphs.prototype.init = function(){
	this.elmGrps=new Array();
	this.eb = new newsi.EventBroadcaster(this);
}
CompareGraphs.prototype.addListenerToArray = function(elms,idSuffix){
	if(arguments.length != 2 || typeof(idSuffix)!='string'){return false;}
	this.elmGrps[idSuffix]=elms;
	for(var i=0; i<elms.length; i++){
		if(!elms[i].id){return false;}
		var ev=new newsi.Event();
		ev.addListener("onclick", elms[i].id, this, "buttonSelected", false, elms[i].id);
	}
	this.selectItem([elms[0].id])
	return true;
}
CompareGraphs.prototype.buttonSelected = function(ev){
	this.broadcastMessage('buttonSelected', ev); 
	this.selectItem(ev);
}
CompareGraphs.prototype.deselectBySuffix = function(suffix){
	if(arguments.length != 1 || typeof(suffix)!='string'){ return false;}
	for(var i=0;i<this.elmGrps[suffix].length;i++){
		newsi.css.hiliteRestore(this.elmGrps[suffix][i].id);
		newsi.html.showHide(suffix +"_"+(i+1),"hide");	
	}
	return true;
}
CompareGraphs.prototype.selectItem = function(ev){
	var id = ev[0];
	if(arguments.length != 1 || typeof(id)!='string'){ return false;}
	var activeSuffix=null;
	for(var i in this.elmGrps){if(id.indexOf(i)!=-1){activeSuffix=i};}
	if(!activeSuffix){return false;}; 
	for(var i=0;i<this.elmGrps[activeSuffix].length;i++){
		var elmnt=this.elmGrps[activeSuffix][i];
		var id_tmp = activeSuffix +"_"+(i+1);
		if(id_tmp +"_btn" == id){
			newsi.css.hiliteActive(id);
			newsi.html.showHide(id_tmp,"show");
		}else{
			newsi.css.hiliteRestore(elmnt.id);
			newsi.html.showHide(id_tmp,"hide");	
		}
	}
	return true;
}



