/*
 * @author  : Greg Wilton (Queensland Treasury)
 * @version : 4.0 (2004-02-26)
 */
var PubList = Expandable;

PubList.prototype.formatItem = function (header, content, row) {
	var a = null;
	
	// create a <div> to be wrapped around the element
	var wrapper = document.createElement("DIV");
	var section = header.parentNode;
	
	// wrap a div around the heading
	section.insertBefore(wrapper, header);
	wrapper.appendChild(header);
	wrapper.className = (row % 2 == 0) ? "even" : "odd";
	
	// do formatting based on whether content exists
	if (content) {
		content.className = "content";
		content.style.display = "none";
		
		// add button
		a = document.createElement("A");
		a.href = "javascript:" + this.varName + ".toggle(" + row + ");";
		this.button.create(a, row);
		wrapper.insertBefore(a, wrapper.firstChild);
	}
	
	// return created button
	return a;
};


/*
 * @author  : Greg Wilton (Queensland Treasury)
 * @version : 2.0 (2003-11-26)
 */
var PubListButton = function (text, openOdd, closedOdd, openEven, closedEven) {
	this.text = text;
	this.openOdd = new Image();
	this.openOdd.src = openOdd;
	this.closedOdd = new Image();
	this.closedOdd.src = closedOdd;
	this.openEven = new Image();
	this.openEven.src = openEven;
	this.closedEven = new Image();
	this.closedEven.src = closedEven;
};
PubListButton.prototype.open = function (obj, row) {
	var img = obj.firstChild;
	img.src = (row % 2 == 0) ? this.openEven.src : this.openOdd.src;
	img.alt = "-";
};
PubListButton.prototype.close = function (obj, row) {
	var img = obj.firstChild;
	img.src = (row % 2 == 0) ? this.closedEven.src : this.closedOdd.src;
	img.alt = "+";
};
PubListButton.prototype.create = function (a, row) {
	var img = document.createElement("IMG");
	img.src = (row % 2 == 0) ? this.closedEven.src : this.closedOdd.src;
	img.border = 0;
	img.alt = "+";
	
	a.className = "button";
	a.appendChild(img);
	a.appendChild(document.createTextNode(this.text));
};