
uploader = {
	submit: function(form, callbacks) {
		form.setAttribute('target', uploader.iframe(callbacks));
		return callbacks && typeof(callbacks.onStart) == 'function' ? callbacks.onStart() : true;
	},
	iframe: function(callbacks) {
		var id = 'uploader_' + Math.floor(Math.random() * 99999);
		var div = document.createElement('DIV');
		div.innerHTML = '<iframe style="display:none" src="about:blank" id="' + id + '" name="' + id + '" onload="uploader.setup(\'' + id + '\')"></iframe>';
		document.body.appendChild(div);
		var iframe = document.getElementById(id);
		if (callbacks && typeof(callbacks.onComplete) == 'function') iframe.onComplete = callbacks.onComplete;
		else iframe.onComplete = ajax.exec;
		return id;
	},
	setup: function(id) {
		var doc, response = '', iframe = document.getElementById(id);
		if (iframe.contentDocument) doc = iframe.contentDocument;
		else if (iframe.contentWindow) doc = iframe.contentWindow.document;
		else doc = window.frames[id].document;
		if (doc.location.href == "about:blank") return;
		response = doc.body.textContent || doc.body.innerText;
		if (typeof(iframe.onComplete) == 'function') iframe.onComplete(response);
	}
}