aim = {
	
	frame: function(c) {
		
		var n = 'f' + Math.floor(Math.random() * 99999);
		var d = document.createElement('div');
		
		d.innerHTML = '<iframe style="display: none" src="about:blank" id="'+n+'" name="'+n+'" onload="aim.loaded(\''+n+'\')"></iframe>';
		document.body.appendChild(d);
		
		var i = document.getElementById(n);
		if(c && typeof(c.onComplete) == 'function') {
			i.onComplete = c.onComplete;
		}
		
		return n;		
	},
	
	loaded: function(id) {
		var i = document.getElementById(id);
		if(i.contentDocument) {
			var d = i.contentDocument;
		} else if (i.contentWindow) {
			var d = i.contentWindow;
		} else {
			var d = window.frames[id].document;
		}
		
		if(d.location.href == "about:blank") {
			return;
		}
		
		if(typeof(i.onComplete) == 'function'){
			return i.onComplete(d.body.innerHTML);
		}
	},
	
	form: function(f, name) {
		f.setAttribute('target', name);
	},
	
	submit: function(f, c) {
		aim.form(f, aim.frame(c))
		if(c && typeof(c.onStart) == 'function') {
			return c.onStart();
		} else {
			return true;
		}
	}
	
}