/*
 * @author  : Greg Wilton (Queensland Treasury)
 * @version : 1.0 (2004-02-26)
 */
var Doc = Expandable;

Doc.prototype.formatItem = function (header, content, row) {
	var a = null;
	
	// do formatting based on whether content exists
	if (content) {
		content.style.display = "none";
		
		// add the read more button
		var node = content.previousSibling;
		while (node != null && !this.match.isHeader(node)) {
			if (node.tagName == "P") {
				a = document.createElement("A");
				a.href = "javascript:" + this.varName + 
						".toggle(" + row + ");";
				this.button.create(a, row);
				node.appendChild(a);
				node =  null;
			} else {
				node = node.previousSibling;
			}
		}
		
		// add the close button
		a2 = document.createElement("A");
		a2.href = "javascript:" + this.varName + ".toggle(" + row + ");";
		var p = document.createElement("P");
		p.appendChild(a2);
		this.button.create2(p, row);
		content.appendChild(p);
	}
	
	// return created button
	return a;
};


/*
 * @author  : Greg Wilton (Queensland Treasury)
 * @version : 1.0 (2004-02-25)
 */
var DocButton = function (openText, closeText) {
	this.openText = openText;
	this.closeText = closeText;
};
DocButton.prototype.open = function (obj, row) {
	obj.style.display = "none";
};
DocButton.prototype.close = function (obj, row) {
	obj.style.display = "inline";
};
DocButton.prototype.create = function (a, row) {
	var text = document.createTextNode(this.openText);
	a.className = "more";
	a.appendChild(text);
};
DocButton.prototype.create2 = function (p, row) {
	var text = document.createTextNode(this.closeText);
	p.className = "close";
	p.firstChild.appendChild(text);
};