var content_collection = new Array ();
var content_browser = new checkBrowser ();

var content_Scroll_None = 0;
var content_Scroll_Vert = 1;
var content_Scroll_Horz = 2;
var content_Scroll_Both = 4;
var content_Scroll_Auto = 8;

function content ()
{
	this.instance = content_collection.length;
	content_collection[this.instance] = this;
	this.name = "Content_" + this.instance;

	this.x = 0;
	this.y = 0;
	this.width = 0;
	this.height = 0;
	this.contentHeight = 0;
	this.contentWidth = 0;
	this.value = "";
	this.scroll = content_Scroll_Auto;
	this.margin = 5;
	
	this.elContentWin = void 0;
	this.elContentArea = void 0;
	this.cssContentWin = void 0;
	this.cssContentArea = void 0;
		
	this.draw = content_draw;
}

function content_draw ()
{
	var html = "";
	var sc1 = void 0;
	var sc2 = void 0;
	
	if (content_browser.ns4)
	{
		html += "<layer name=\"" + this.name + "\" id=\"" + this.name + "\" visibility=\"hidden\">";
		html += "<layer name=\"" + this.name + "_value\" id=\"" + this.name + "_value\"  width=\"" + this.width + "\">";
		html += this.value;
		html += "</layer>";
		html += "</layer>";
	}
	else
	{
		html += "<div name=\"" + this.name + "\" id=\"" + this.name + "\" style=\"visibility: hidden; overflow: hidden;\">";
		html += "<div name=\"" + this.name + "_value\" id=\"" + this.name + "_value\" style=\"width: " + this.width + "\">";
		html += this.value;
		html += "</div>";
		html += "</div>";
	}
	
	document.open ();
	document.write (html);
	document.close ();
	
	if (content_browser.dom)
	{
		this.elContentWin = document.getElementById(this.name);
		this.elContentArea = document.getElementById(this.name + "_value");
		this.cssContentWin = document.getElementById(this.name).style;
		this.cssContentArea = document.getElementById(this.name + "_value").style;
	}
	else if (content_browser.ie4)
	{
		this.elContentWin = document.all[this.name];
		this.elContentArea = document.all[this.name + "_value"];
		this.cssContentWin = document.all[this.name].style;
		this.cssContentArea = document.all[this.name + "_value"].style;
	}
	else if (content_browser.ns4)
	{
		this.elContentWin = eval ("document." + this.name);
		this.elContentArea = eval("document." + this.name + ".document." + this.name + "_value");
		this.cssContentWin = eval ("document." + this.name);
		this.cssContentArea = eval("document." + this.name + ".document." + this.name + "_value");
	}
	else
	{
		return (void 0);
	}
	
	this.cssContentWin.position = "absolute";
	this.cssContentWin.left = this.x;
	this.cssContentWin.top = this.y;
	this.cssContentWin.width = this.width;
	this.cssContentWin.height = this.height;
	
	this.cssContentWin.clip.left = 0;
	this.cssContentWin.clip.top = 0;
	this.cssContentWin.clip.right = this.width;
	this.cssContentWin.clip.bottom = this.height;
	
	this.cssContentArea.position = "absolute";
	this.cssContentArea.left = 0;
	this.cssContentArea.top = 0;
	
	if (content_browser.ns4)
	{
		this.contentHeight = this.cssContentArea.document.height;
		this.contentWidth = this.cssContentArea.document.width;
	}
	else
	{
		this.contentHeight = this.elContentArea.offsetHeight;
		this.contentWidth = this.elContentArea.offsetWidth;
	}
	
	this.cssContentWin.visibility = "visible";
	
	if (this.scroll == content_Scroll_Vert)
	{
		sc1 = new scroller ();
		sc1.style = Scroller_Style_Vert;
		sc1.x = this.x + this.width;
		sc1.y = this.y;
		sc1.height = this.height;
		sc1.contentWindow = this;
		sc1.margin = this.margin;
		
		sc1.draw ();
	}
	else if (this.scroll == content_Scroll_Horz)
	{
		sc2 = new scroller ();
		sc2.style = Scroller_Style_Horz;
		sc2.x = this.x;
		sc2.y = this.y + this.height;
		sc2.width = this.width;
		sc2.contentWindow = this;
		sc2.margin = this.margin;
		
		sc2.draw ();
	}
	else if (this.scroll == content_Scroll_Both)
	{
		sc1 = new scroller ();
		sc1.style = Scroller_Style_Vert;
		sc1.x = this.x + this.width;
		sc1.y = this.y;
		sc1.height = this.height;
		sc1.contentWindow = this;
		sc1.margin = this.margin;
		
		sc2 = new scroller ();
		sc2.style = Scroller_Style_Horz;
		sc2.x = this.x;
		sc2.y = this.y + this.height;
		sc2.width = this.width;
		sc2.contentWindow = this;
		sc2.margin = this.margin;
		
		sc1.draw ();
		sc2.draw ();
	}
	else if (this.scroll & content_Scroll_Auto)
	{
		if (this.scroll == content_Scroll_Auto) this.scroll = this.scroll | content_Scroll_Both;
		
		if (this.scroll & (content_Scroll_Horz | content_Scroll_Both))
		{
			if (this.contentWidth > this.width) 
			{
				sc2 = new scroller ();
				sc2.style = Scroller_Style_Horz;
				sc2.x = this.x;
				sc2.y = this.y + this.height;
				sc2.width = this.width;
				sc2.contentWindow = this;
				sc2.margin = this.margin;
			
				sc2.draw ();
			}
		}
		
		if (this.scroll & (content_Scroll_Vert | content_Scroll_Both))
		{
			if (this.contentHeight > this.height)
			{
				sc1 = new scroller ();
				sc1.style = Scroller_Style_Vert;
				sc1.x = this.x + this.width;
				sc1.y = this.y;
				sc1.height = this.height;
				sc1.contentWindow = this;
				sc1.margin = this.margin;
				
				sc1.draw ();
			}
		}
	}
}