/************************* 
	Text Rollover Button
**************************/
// Constructor
function TextRolloverBtn(text, link, leftImg, leftImg2, leftImgWidth, bgImg, bgImgWidth, rightImg, rightImgWidth, idx, targetFrame)
{
	
	// properties
	this.text = text;					// button text
	this.link = link;					// button link
	this.leftImg = leftImg;				// left image
	this.leftImg2 = leftImg2;			// left image - active
	this.leftImgWidth = leftImgWidth;	// left image width
	this.bgImg = bgImg;					// background image
	this.bgImgWidth = bgImgWidth;		// background image
	this.rightImg = rightImg;			// right image
	this.rightImgWidth = rightImgWidth;	// right image
	this.margin = "0 0 0 0";			// margin: top right bottom left
	this.idx = idx;
	this.targetFrame = targetFrame;
	this.subMenu = new Array();			// sub menu object array build by CoolBar obejct
	this.bSubMenu = false;
	this.id = "TextRolloverBtn" + this.idx;
	
	// methods
	this.setMargin = trb_setMargin;
	this.display = trb_display;
	this.active = trb_active;
	this.deactive = trb_deactive;
	this.onMouseOver = trb_onMouseOver;
	this.onMouseOut = trb_onMouseOut;
	this.onMouseDown = trb_onMouseDown;
	this.onMouseUp = trb_onMouseUp;
	this.genTags = trb_genTags;				// generate button tags
}

function trb_setMargin(margin)
{
	if (margin.length > 0)
		this.margin = margin;
}
	
function trb_display(item)
{
	var oBtn = document.all(this.id);

	if (oBtn == null) 
		return;

	// get sub menu
	var oSubMenu = oBtn.nextSibling;
		
	if (item.display == "0") {
		oSubMenu.style.display="BLOCK";
		item.display = "1";
	}
	else {	
		oSubMenu.style.display="NONE";
		item.display = "0";
	}	
}

function trb_active(item)
{
	if (item == null)
		return;

	var oTable = item.childNodes(0);
	oTable.rows[0].cells[0].childNodes(0).src = this.leftImg2;
	oTable.rows[0].cells[1].className = "CB_ITEM_OVER";
}

function trb_deactive(item)
{
	if (item == null)
		return;
		
	var oTable = item.childNodes(0);
	oTable.rows[0].cells[0].childNodes(0).src = this.leftImg;
	oTable.rows[0].cells[1].className = "CB_ITEM";
}

function trb_onMouseOver(item)
{
	this.active(item);
}

function trb_onMouseOut(item)
{
	this.deactive(item);
}

function trb_onMouseDown(item)
{
	if (item == null)
		return;

	if (this.bSubMenu)	
		this.display(item);	
	else {	
		goLink(item);
	}	
}

function trb_onMouseUp(item)
{
	if (item == null)
		return;
		
	this.deactive(item);
}

// generate button tags
function trb_genTags()
{
	var s = "";

	s = s + '<DIV id="' + this.id + '" display="0" targetFrame="' + this.targetFrame + '" link="' + this.link + '" style="Cursor:HAND;margin:' + this.margin + '" onMouseOver="oCoolBar.mainMenu[' + this.idx + '].onMouseOver(this)" onMouseOut="oCoolBar.mainMenu[' + this.idx + '].onMouseOut(this)" onMouseDown="oCoolBar.onMouseDown(this)">' + '\n';

	s = s + '<table width="136" border="0" cellspacing="0" cellpadding="0"><tr>' + '\n';
	if (this.leftImgWidth > 0)
		s = s + '<td width="' + this.leftImgWidth + '"><IMG width="' + this.leftImgWidth + '" src="' + this.leftImg + '" border="0" class="CB_ITEM"></td>' + '\n';
	s = s + '<td width=125 background="images/layout_menuleft_BG.gif" class="CB_ITEM" align="right">' + '\n';
	s = s + '<a href="#">&nbsp;' + this.text + '</a>' + '\n';
	if (this.rightImgWidth > 0) 
		s = s + '<td width="' + this.rightImgWidth +'"><IMG width="' + this.rightImgWidth +'" src="' + this.rightImg + '" border="0" width="7" height="21"></td>' + '\n';
	s = s + '</tr></table>' + '\n';	
	
	s = s + '</DIV>' + '\n';

	return s;
}
  