/**********************************
**
**	DYNAMIC AREA
**
***********************************
**
**	id		:: STRING
**	url		:: STRING
**	once		:: BOOLEAN
**	interval	:: NUMBER
**
**********************************/
function DynamicArea(id,url,once,interval) {

	var a;

	//check to see if DOM is supported and Element Exists
	if(!document.getElementById || !document.getElementById(id))
		return false;

	this._object = document.getElementById(id);
	this._url = url;
	this.contentUpdate = private(this,contentUpdate);

	if(once)
		this._interval = window.setTimeout(this.contentUpdate,interval);
	else
		this._interval = window.setInterval(this.contentUpdate,interval);

}
function Jabberwoky(target) {
	this._content = '';
	function write(str) {
		/*alert(str);*/
		this._content += str;
	}
	function print() {
		return this._content;
	}
	this.write = write;
	this.print = print;
}

DynamicArea.prototype._object;
DynamicArea.prototype._url;
DynamicArea.prototype._a;
DynamicArea.prototype._interval;

function private (object, method) {
	return function() {
		return method.apply(object, arguments);
	};
}
function contentUpdate() {
	a = new AjaxRequest(this._url,this._object,null,this.complete,Math.random());
}
function fadeout() {
	var target = this._target;
	var style = target.style;
	if(this._opacity == '')
		this._opacity = 1;
	else
	{
		this._opacity -= .03;
		this._opacity = Math.round(this._opacity*100)/100;
		if(this._opacity <= 0)
		{
			this._opacity = 0;
			window.clearInterval(this._fadeout);
			target.innerHTML = this._response;
			var scripts = target.getElementsByTagName('script');
			if(scripts.length)
			{
				var script;
				for (var i in scripts)
				{
					if(typeof scripts[i] == 'object')
					{
						script = scripts[i].innerHTML;

						document._content = '';
						function write(str) {
							this._content += str;
						}
						function print() {
							return this._content;
						}
						document.write = write;
						document.print = print;
						eval(script);
						target.innerHTML += document.print();

						delete script;
					}
				}
			}
			var noscripts = target.getElementsByTagName('noscript');
			if(noscripts.length)
			{
				for (var i in noscripts)
				{
					if(typeof noscripts[i] == 'object')
					{
						noscript = noscripts[i].innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
						target.innerHTML += noscript;
					}
				}
			}

			this._fadein = setInterval(this.fadein,1);
		}
	}
	style.opacity = this._opacity;
	style.MozOpacity = this._opacity;
	style.KhtmlOpacity = this._opacity;
	style.filter = "alpha(opacity=" + (this._opacity * 100).toString() + ")";

}
function fadein() {
	var target = this._target;
	var style = target.style;

	this._opacity += .03;
	this._opacity = Math.round(this._opacity*100)/100;
	if(this._opacity >= 1)
	{
		this._opacity = 1;
		window.clearInterval(this._fadein);
	}

	style.opacity = this._opacity.toString();
	style.MozOpacity = this._opacity.toString();
	style.KhtmlOpacity = this._opacity.toString();
	style.filter = "alpha(opacity=" + (this._opacity * 100).toString() + ")";
}

DynamicArea.prototype.complete = function() {
	this.fadeout = private(this, fadeout);
	this.fadein = private(this, fadein);
	this._opacity = 1;
	this._fadeout = setInterval(this.fadeout,1);
};