function ButtonGroup(text){
	this.name=text;
	this.buttons=null;
	this.buttonsHtml="ButtonGroup: Html not created";
	this.selectedIndex=0;
	this.doc="pageFrame.document";
	this.loc="top";
	this.listeners=new Array();
	this.eventType="";
  // style properties
	this.buttonPadding=20;
	this.buttonTopPadding=2;
	this.buttonSpacing=4;
	this.buttonColor="#aaa";
	this.buttonFontFamily="Arial, Helvitica, sans-serif";
	this.buttonFontSize=9;
	this.buttonFontStyle="normal";
	this.buttonFontWeight="bold";
	this.buttonBackgroundColor="transparent";
	this.buttonBorderColor="#aaa";
	this.buttonBorderStyle="solid";
	this.buttonBorderWidth=1;
	this.buttonHighlightColor="navy";
	this.buttonHighlightBackgroundColor="#ccf";
	this.buttonHighlightBorderColor="navy";
	this.buttonSelectedBackgroundColor="white";
	this.buttonSelectedBorderColor="black";
	this.buttonSelectedColor="black";
}
function buttongroup_actionPerformed(source){
	this.clearUnselectedButtons();
}
function buttongroup_addActionListener(listener){
	this.listeners[this.listeners.length]="actionListener";
	this.listeners[this.listeners.length]=listener;
}
function buttongroup_addButton(text){
	if(this.buttons==null){
		this.buttons=new Array(1);
		this.buttons[0]=new ButtonLabel(text);
	}else this.buttons[this.buttons.length]=new ButtonLabel(text);

}
function buttongroup_addChangeListener(listener){
	this.listeners[this.listeners.length]="changeListener";
	this.listeners[this.listeners.length]=listener;
}
function buttongroup_clearUnselectedButtons(){
	for(var i=0;i<this.buttons.length;i++){
		this.unhighlightButton(i);
	}
}
function buttongroup_createButtonsHtml(){
	this.buttonsHtml="<table style='border-spacing: "+this.buttonSpacing+"px 0px;'><tr>";
	for(var i=0;i<this.buttons.length;i++){
		this.buttonsHtml+="<td id='"+this.buttons[i].buttonName+"' "+
		"style='"+
		"cursor:pointer;"+
		"color:"+this.buttonColor+";"+
		"font-family:"+this.buttonFontFamily+";"+
		"font-size:"+this.buttonFontSize+"pt;"+
		"font-style:"+this.buttonFontStyle+";"+
		"font-weight:"+this.buttonFontWeight+";"+
		"border-style:"+this.buttonBorderStyle+";"+
		"border-color:"+this.buttonBorderColor+";"+
		"border-width:"+this.buttonBorderWidth+"px;"+
		"padding-top:"+this.buttonTopPadding+"px;"+
		"padding-bottom:"+this.buttonTopPadding+"px;"+
		"padding-left:"+this.buttonPadding+"px;"+
		"padding-right:"+this.buttonPadding+"px;'"+
		"onmouseover='"+this.loc+"."+this.name+".fireStateChanged(\"onmouseover\","+i+")' "+
		"onmouseout='"+this.loc+"."+this.name+".fireStateChanged(\"onmouseout\","+i+")' "+
		"onclick='"+this.loc+"."+this.name+".fireActionPerformed("+i+")'>"+
		this.buttons[i].label+"</td>";
	}
	this.buttonsHtml+="</tr></table>";
}
function buttongroup_fireActionPerformed(index){
	this.selectedIndex=index;
	this.eventType="onclick";
	for(var i=0;i<this.listeners.length;i+=2){
		if(this.listeners[i]=="actionListener"){
			var l=this.listeners[i+1]==""?"":this.listeners[i+1]+".";
			eval(l+"actionPerformed(\""+this.name+"\");");
		}
	}
}
function buttongroup_fireStateChanged(eType,index){
	this.eventType=eType;
	for(var i=0;i<this.listeners.length;i+=2){
		if(this.listeners[i]=="changeListener"){
			var l=this.listeners[i+1]==""?"":this.listeners[i+1]+".";
			eval(l+"stateChanged(\""+this.name+"\","+index+")");
		}
	}
}
function buttongroup_getElementAt(index){
	return this.buttons[index];
}
function buttongroup_getHtml(){
	return this.buttonsHtml;
}
function buttongroup_getLength(){
	if(this.buttons!=null)return this.buttons.length;
	else return 0;
}
function buttongroup_highlightButton(index){
	eval("var element="+this.doc+".getElementById(this.buttons[index].buttonName)");
	if(index==this.selectedIndex){
		element.style.backgroundColor=this.buttonSelectedBackgroundColor;
		element.style.color=this.buttonSelectedColor;
		element.style.borderColor=this.buttonSelectedBorderColor;
	}else{
		element.style.backgroundColor=this.buttonHighlightBackgroundColor;
		element.style.color=this.buttonHighlightColor;
		element.style.borderColor=this.buttonHighlightBorderColor;
	}
}
function buttongroup_stateChanged(source,index){
	if(this.eventType=="onmouseover")this.highlightButton(index);
	else if(this.eventType == "onmouseout")this.unhighlightButton(index);
}
function buttongroup_unhighlightButton(index){
	eval("var element="+this.doc+".getElementById(this.buttons[index].buttonName)");
	if(index==this.selectedIndex){
		element.style.backgroundColor=this.buttonSelectedBackgroundColor;
		element.style.color=this.buttonSelectedColor;
		element.style.borderColor=this.buttonSelectedBorderColor;
	}else{
		element.style.backgroundColor=this.buttonBackgroundColor;
		element.style.color=this.buttonColor;
		element.style.borderColor=this.buttonBorderColor;
	}
}
ButtonGroup.prototype.actionPerformed=buttongroup_actionPerformed;
ButtonGroup.prototype.classId="ButtonGroup";
ButtonGroup.prototype.clearUnselectedButtons=buttongroup_clearUnselectedButtons;
ButtonGroup.prototype.addActionListener=buttongroup_addActionListener;
ButtonGroup.prototype.addButton=buttongroup_addButton;
ButtonGroup.prototype.addChangeListener=buttongroup_addChangeListener;
ButtonGroup.prototype.createButtonsHtml=buttongroup_createButtonsHtml;
ButtonGroup.prototype.fireActionPerformed=buttongroup_fireActionPerformed;
ButtonGroup.prototype.fireStateChanged=buttongroup_fireStateChanged;
ButtonGroup.prototype.getElementAt=buttongroup_getElementAt;
ButtonGroup.prototype.getHtml=buttongroup_getHtml;
ButtonGroup.prototype.getLength=buttongroup_getLength;
ButtonGroup.prototype.highlightButton=buttongroup_highlightButton;
ButtonGroup.prototype.stateChanged=buttongroup_stateChanged;
ButtonGroup.prototype.unhighlightButton=buttongroup_unhighlightButton;
