/********************************************************************************
 *	This file contains javascript for building the content containing
 *	collapsing rows in the table in multex.NET (new NET)
 *	Author(s): Dmitry Rakovitsky
 ********************************************************************************/

/*
 *	MxRowGroupBox - Collapsing Rows in the table
 *	Author: Dmitry Rakovitsky
 */
 
// MxRowGroup - inherits from MxDHTML
function MxRowGroup(id, openImg, closeImg) {
	this.init(id, openImg, closeImg);
}
MxRowGroup.prototype = new MxDHTML();
MxRowGroup.superclass = MxDHTML.prototype;

// MxRowGroup method: init - object initialization
MxRowGroup.prototype.init = function( id, openImg, closeImg ) {
	MxRowGroup.superclass.init.call( this, false );
	
	this.elementName = 'tbody';
	this.id = id;
	this.hidden=false;

	this.openImage = null;
	this.closeImage = null;
		
	if (openImg != "" && openImg != null)
		this.openImage = openImg;

	if (closeImg != "" && closeImg != null)
		this.closeImage = closeImg;		
}


	
// MxRowGroup method: hide -  hides the object's DOM equivalant
MxRowGroup.prototype.hide = function()
{
	MxRowGroup.superclass.hide.call( this );
	
	if (this.closeImage != null) {
		var element = document.getElementById(this.id + "_img");
		element.src = this.getImageUrl() + "/" + this.closeImage;
		element.title = "Click to Show Detailed Rows";
	}
}


// MxRowGroup method: show -  shows the object's DOM equivalant
MxRowGroup.prototype.show = function()
{
	MxRowGroup.superclass.show.call( this );
	
	if (this.openImage != null) {
		var element = document.getElementById(this.id + "_img");
		element.src = this.getImageUrl() + "/" + this.openImage;
		element.title = "Click to Hide Detailed Rows";
	}	
}	

// MxRowGroup method: writeControlImage -  writes the HTML for the image that controls the 
// tbody section
MxRowGroup.prototype.writeControlImage = function() {		
	var imgOnClick = this.id + ".toggleHide();";

	var html = "<img class='noprint' src='" + this.getImageUrl() + "/";
	if (this.hidden)		
		html   += this.closeImage;
	else
		html += this.openImage;

	html += "' id=" + this.id + "_img";		
	html += " title='Click to Hide Detailed Rows' border='0' onClick='" + imgOnClick + "'/>";
	
	document.write(html);	
}

// MxRowGroup method: writeRowGroupOpen - writes the opening HTML of a rows group
MxRowGroup.prototype.writeRowGroupOpen = function() {
	var result = "";	
	result += this.openElement();	
	document.write(result);
}
	
// MxRowGroup method: writeRowGroupClose - writes the closing HTML of a rows group
MxRowGroup.prototype.writeRowGroupClose = function() {
	var result = "";
	result +=  this.closeElement();
	document.write(result);
}
