function ajaxcall (url, poststring)
{
	this.get 	= function (ajaxobj)
	{
		if (window.XMLHttpRequest)
			var XHR = new XMLHttpRequest();
		else if (window.ActiveXObject)
			var XHR = new ActiveXObject("Microsoft.XMLHTTP");
		XHR.onreadystatechange = function()
		{
			if (XHR.readyState ==2)
				ajaxobj.load(XHR);
			if (XHR.readyState ==4)
				ajaxobj.onload(XHR);
		};
		XHR.open("GET", url, true);
		XHR.send("");
	};
	this.post 	= function (ajaxobj)
	{
		if (window.XMLHttpRequest)
			var XHR = new XMLHttpRequest();
		else if (window.ActiveXObject)
			var XHR = new ActiveXObject("Microsoft.XMLHTTP");
		XHR.open("POST", url, true);
		XHR.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
		XHR.onreadystatechange = function()
		{
			if (XHR.readyState ==2)
				ajaxobj.load(XHR);
			if (XHR.readyState ==4)
				ajaxobj.onload(XHR);
		};
		
		XHR.send(poststring);
	};
	this.toJSON	= function (XHR)
	{
		var json = "json = " + XHR.responseText + ";";
		eval (json);
		return json;
	};
	this.load = function ()
	{ }
	this.onload = function ()
	{ }
	if (poststring == undefined)
		this.get(this);
	else
		this.post(this);
}
function form_class(object)
{
	var elements = object.getElementsByTagName("input");
	this.disable 	= function ()
	{
		var count		= elements.length;
		for (var i = 0; i < count; i++)
		{
			elements[i].disabled = true;
			
		}
	};
	this.enable		= function ()
	{
		var count		= elements.length;
		for (var i = 0; i < count; i++)
		{
			elements[i].disabled = false;
			
		}
	};
	this.enablestate = function ()
	{
		var count		= elements.length;
		for (var i = 0; i < count; i++)
		{
			if (!elements[i].disabled)
				return true;
		}
		return false;
	};
	this.elements	=function ()
	{
		return elements;
		
	}
}

function getobject (id)
{
	this.object 	= document.getElementById(id);
	this.form;
	this.ctentheight= null;
	this.getopacity = function()
	{
		if(this.object.filters)
		{
			if (this.object.filters.alpha == undefined)
				return 100;
			else
				return parseInt(this.object.filters.alpha.opacity);	
		}
		else
		{
			if (this.object.style.opacity == "")
				return 100;
			else
				return (parseFloat(this.object.style.opacity) * 100);
		}
	};
	this.erase	= function ()
	{
		document.body.removeChild(this.object);
	}
	this.active = function ()
	{
		if (this.object ==null)
			return false;
		else
			return true;
	}
	this.fixform = function ()
	{
		
		
	}
	this.setopacity = function(value)
	{
		if(this.object.filters)
		{
			this.object.style.filter = "alpha(opacity:" + value + ")";
			
		}
		else
		{
			this.object.style.opacity = value / 100;
			
		}
	};
	this.getheight	= function()
	{
		if (this.object.style.height == "")
		{
			this.object.style.height = "0px";
		}
		return parseInt(this.object.style.height);
	}
	this.setheight	= function(value)
	{
		this.object.style.height = parseInt(value) + "px";
		return this.getheight();
	}
	this.getwidth	= function()
	{
		if (this.object.style.width == "")
		{
			return this.object.offsetWidth;
		}
		return parseInt(this.object.style.width);
	}
	this.setwidth	= function (value)
	{
		this.object.style.width = parseInt(value) + "px";
		return this.getwidth();
		
	}
	this.contentheight = function ()
	{
		if (this.ctentheight != null)
		{
			return this.ctentheight;
		}
		else
		{
			var cache = "" + this.object.innerHTML;
			this.object.innerHTML ="<div id='height'>" + cache + "</div>";
			var height = document.getElementById("height").offsetHeight;
			this.object.innerHTML =cache;
			this.ctentheight = parseInt(height);
			return parseInt(height);
		}
	}
	this.fixform		= function ()
	{
		if (this.active())
		{
			this.form = new form_class(this.object);
			return true;
		}
		return false;
	}
	this.fixform();

}

function windowhelper ()
{
	this.onclickevents;
	this.init  = function ()
	{
		window.onclick = function ()
		{
			if (this.onclickevents != null)
			{
				for (var i =0; i < this.onclickevents.length; i++)
				{
					this.onclickevents[i];
					
				}
			}
		};	
	}
	this.addonclick = function (event)
	{
		if (this.onclickevents != null)
		{
			this.onclickevents[this.onclickevents.length] = event;
		}
		else
		{
			this.onclickevents = Array();
			this.onclickevents[0] = event;
		}
		
	}
	this.init();
}

var windowhelper = new windowhelper();
