AIM = {
    submit : function(f, c) {
        var x=document.getElementById('aimframe')
        if(x) document.body.removeChild(x.parentNode)
        var d=document.createElement('div')
        d.innerHTML="<iframe id='aimframe' name='aimframe' onload=AIM.loaded() src=javascript:false style=display:none></iframe>"
        document.body.appendChild(d)
        if (c && typeof(c.onComplete) == 'function') {
            d.getElementsByTagName('iframe')[0].onComplete = c.onComplete;
        }
        f.setAttribute('target', 'aimframe');
        if (c && typeof(c.onStart) == 'function') {
            return c.onStart();
        } else {
            return true;
        }
    },

    loaded : function() {
        var i = document.getElementById('aimframe');
        if (i.contentDocument) {
            var d = i.contentDocument;
        } else if (i.contentWindow) {
            var d = i.contentWindow.document;
        } else {
            var d = window.frames[id].document;
        }
        if (d.location.href=="javascript:false") return

        if (typeof(i.onComplete) == 'function') {
            i.onComplete(d.body.innerHTML);
        }
    }
}

