/* Copyright (c) 2006 N2N Consulting Pte Ltd. All rights reserved. */

/**
* @author Antonius Ng
* 
* $Id: Div.js,v 1.1 2007/05/30 09:10:42 antonius Exp $
*/

/**
* @class A Div object. This div object will be drawn at the call of the constructor method.
* This object inherits all the method from table DOM API
*
* Usage:
* var o = new n2n.Div("div_id"); //Draw a div with id div_id
*
* // add content to div
* o.write("Some text");
*
*/

dojo.provide("n2n.Div");
dojo.require("dojo.lang.*");

n2n.Div = Class.create();

n2n.Div.prototype= {
	
	initialize: function(id, container) {
		this.id = id;
		if (!container) {
			container = document;
		}
		this.container = container;
		
	},
	
	clear: function() {
		var thisDiv = this.getDiv();
		thisDiv.innerHTML = "";
	},
	
	write: function(s) {
		var thisDiv = this.getDiv();
		
		thisDiv.innerHTML = thisDiv.innerHTML + s;
	},
	
	toHTML: function() {
		return "<div id=\""+this.id+"\"></div>";
	},
	
	paint: function() {
		if (!this.getDiv()) {
			this.container.write(this.toHTML());
		}
		this.HTMLObject = document.getElementById(this.id);
	},
	getDiv: function() {
		return document.getElementById(this.id);
	},
	hide: function() {
		document.getElementById(this.id).style.display='none';
	},
	show: function() {
		document.getElementById(this.id).style.display='';
	}
}