function XMLMODULE(div, root_node) {
    if (typeof div == "object") this.div = div;
    else if (div) {
	this.div = document.getElementById(div);
	if (!this.div) adei.ReportError(translate("Element \"%s\" is not present in current document model", div));
    } else return;  /* inheritance */
    
    if (typeof root_node == "undefined") this.root_node = this.div;
    else if (typeof root_node == "object") this.root_node = root_node;
    else this.root_node = document.getElementById(root_node);
    
    this.module_type = HISTORY_MODULE_TYPE;
}

XMLMODULE.prototype.Update = function(json, forced) {
    if ((json.xml)&&(json.xslt)) {
	adei.UpdateDIV(this.div, json.xml, json.xslt);
	adei.SetSuccessStatus(translate("Done"));
    } else {
	adei.SetStatus(translate("Update failed: Incomplete response received by the module"));
    }
}

XMLMODULE.prototype.GetNode = function() {
    return this.root_node;
}


XMLMODULE.prototype.SetModuleType = function(type) {
    this.module_type = type;
}

XMLMODULE.prototype.GetModuleType = function() {
    return this.module_type;
}

function WIKI(div) {
    WIKI.superclass.call(this, div);
    this.pageid = 1;
}

classExtend(WIKI, XMLMODULE);

WIKI.prototype.SetID = function(id) {
    this.div.innerHTML=translate("Loading...");
    adei.config.SetWikiSettings(id);
    adei.config.Save();
    adei.updater.Update();
}

WIKI.prototype.SetConfiguration = function(query) {
    adei.config.Load(query, true);
}

function EVENTDATA(div, event_name, search_module) {
    EVENTDATA.superclass.call(this, div);

    this.module = null;
    this.event_name = event_name;
    this.search_module = search_module;

    adei.RegisterCropperButton({
	name: event_name,
	tooltip: translate('Search ' + event_name),
	object: this,
	callback: 'onSelect',
	css: 'imgCrop_button_' + event_name,
	vertical: true,
	keep_selection: true
    });

}

classExtend(EVENTDATA, XMLMODULE);


EVENTDATA.prototype.onSelect = function(from, to) {
    adei.Search('{' + this.search_module + '} interval:' + from + '-' + to);
}

EVENTDATA.prototype.SetAutoOpen = function(module) {
    this.module = module;
}

EVENTDATA.prototype.SetCustomProperties = function(query) {
    adei.SetCustomProperties(query+"&module="+this.module);
/*
    SetCustomProperty calls 'CONFIG.Load' which is async, therefore new
    configuration is not set than page is changed 
    adei.SetCustomProperties(query);
    if (this.module) adei.OpenModule(this.module);
*/
}
