var qwd = {
	ajax: {
		_init_funcs: new Array(),
		
		init: function() {
			for(var n in this._init_funcs) {
				this._init_funcs[n]();
			}
		},

		add_init_func: function(f) {
			this._init_funcs.push(f);
		},
		
		post: function(what,where,thendo) {
			try {
				var req = window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHttp');
				var data = '';
				req.onreadystatechange = function() {
					if(4==req.readyState) {
						if(200==req.status) {
							thendo(req.responseText);
						}
						else {
							thendo();
						}
					}	
				};
				what["__ajax__"] = 1;
				for (var n in what) {
					if(data.length>0) data += '&';
					data += escape(n) + '=' + escape(what[n]);
				};
				req.open('POST',where,true);
				req.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				req.setRequestHeader("Content-length", data.length);
				req.setRequestHeader("Connection", "close");
				req.send(data);
				return true;
			}
			catch(e)
			{	
			};
			return false;
		},
		
		button: function(id,href,imgalt,imgsrc,imgtitle,fn) {
			//var img = document.createElement('img');
			//var anchor = document.createElement('a');
			//var o = document.getElementById(id);
			//img.setAttribute('src',imgsrc);
			//img.setAttribute('alt',imgalt);
			//img.setAttribute('title',imgtitle);
			//anchor.setAttribute('href',href);
			//anchor.setAttribute('title',imgtitle);
			//anchor.setAttribute('onclick',fn);	// f*****g IE 5.5... I mean geez!!!!
			document.getElementById(id).innerHTML = '<a href="' + href + '" title="' + imgtitle + '" onclick="' + fn + '"><img src="' + imgsrc + '" alt="' + imgalt + '" title="' + imgtitle + '"/></a>';
		},
		
		// TODO: add support for select and anything else
		getform: function(id) {
			var o = document.getElementById(id);
			var elements = o.getElementsByTagName("input");
			var i,n;
			var data = new Array();
			for(i=0;i<elements.length;i++) {data[elements[i].name] = elements[i].value;}
			elements = o.getElementsByTagName("textarea");
			for(i=0;i<elements.length;i++) {data[elements[i].name] = elements[i].value;}
			return data;
		}
	}
}

