/**
*
* AJAX IFRAME METHOD (AIMSS - changed by summersoft for FrontPage)
* http://www.webtoolkit.info/
*
**/

AIMSS = {

    frame : function(f, c) {
		//alert('1');

        var n = 'f' + Math.floor(Math.random() * 99999);
        var d = document.createElement('DIV');
		//alert('2 ' + n);
        d.innerHTML = '<iframe style="display:none" src="'+f+'" id="'+n+'" name="'+n+'" onload="AIMSS.loaded(\''+n+'\')"></iframe>';
        document.body.appendChild(d);

		//alert('3');
        var i = document.getElementById(n);
        if (c && typeof(c.onComplete) == 'function') {
		//alert('4');
            i.onComplete = c.onComplete;
        }
		//alert('5');

        return n;
    },

    form : function(f, name) {
		//alert('6');
        ////f.setAttribute('target', name);
		//alert('7');
    },

    submit : function(f, c) {
		//alert('filename to load: ' + f);
		//alert('8');
        AIMSS.form(f, AIMSS.frame(f, c));
		//alert('9');
        if (c && typeof(c.onStart) == 'function') {
		//alert('10');
            return c.onStart();
        } else {
		//alert('11');
            return true;
        }
    },

    loaded : function(id) {
        var i = document.getElementById(id);
		//alert('12 ' + id);
		//alert('12.1 ' + i.innerHTML);
        if (i.contentDocument) {
            var d = i.contentDocument;
		//alert('13');
        } else if (i.contentWindow) {
            var d = i.contentWindow.document;
		//alert('14 ' + d.innerHTML);
        } else {
		//alert('15');
            var d = window.frames[id].document;
        }
        if (d.location.href == "about:blank") {
		//alert('16');
            return;
        }

		//alert('17');
        if (typeof(i.onComplete) == 'function') {
		//alert('18');
            i.onComplete(d.body.innerHTML);
        }
		//alert('19');
    }

}
