
var PageAPI = Class.create({
    /* Page Service URL */
    url: "",
    /* Function to call on results */
    resultCallback: null,
    /* Function to call on faults. NOT IMPLEMENTED YET. */
    faultCallback: null,
    
    /* Constructor/Initializer */
    initialize: function(resultCallback, faultCallback){
        this.resultCallback = resultCallback;
        this.faultCallback = faultCallback;
    },
    
    fetchPage: function(url){
        return new Ajax.Request(url, {method: 'get', 
                                      onComplete: this.resultCallback});
    }
});

// Static method to force an ajax download via a hidden iframe
    PageAPI.downloadDocument = function(url) {
	var framename = '_PageAPIDownload';
	var iframe = $(framename);
	if (iframe) {
	    iframe.remove();
	}
	iframe = new Element ('iframe', {'id': framename, 'src': url});
	iframe.style.display = 'none';
	$(document.body).insert(iframe);
    }
