//belenusHome.registerModule("Table", self);
//belenusHome.registerModule("TableFilter", self);

function showFilter(state) {
  applet.call('TableShadePanel','setShaded',state);
}

function messageHandler(message, params) {
  document.TableApplet.sendMessage("Table", message, params);
}

function getProperty(property, params) {
  return document.getElementById('TableApplet').getProperty("Table", property, params);
}

function addAppletParam(appletNode, key, val) {
  var elem = document.createElement('param');
  elem.setAttribute("name", key);
  elem.setAttribute("value", val);
  appletNode.appendChild(elem);
}	

function embedTableViaDOM() {
    var tc = document.getElementById("TableCanvas");
    var appletNode = document.createElement('applet');
    appletNode.setAttribute('id', 'TableApplet');
    appletNode.setAttribute('code', 'com.belenus.interparts.PartsApplet');
    appletNode.setAttribute('mayscript', 'true');
    appletNode.setAttribute('width', '100%');
    appletNode.setAttribute('height', '100%');
    appletNode.setAttribute('vspace', '0');
    appletNode.setAttribute('hspace', '0');
    addAppletParam(appletNode, 'scriptable', 'true');
    addAppletParam(appletNode, 'archive', 'core.jar,xml.jar,table.jar');
	if(belenusHome.interpartsVersion == "static") 
		addAppletParam(appletNode, 'GUIDef', belenusHome.getPath('table_guidef.xml'));
	else 
		addAppletParam(appletNode, 'GUIDef', belenusHome.getPath('table_guidef.jsp'));
    addAppletParam(appletNode, 'DataLocales', belenusHome.getLanguagesCurrentFirst('DATA'));
    addAppletParam(appletNode, 'LocaleDef', belenusHome.getPath('lang/'+belenusHome.currentLanguage+'/localedef.txt'));
    addAppletParam(appletNode, 'GUILocale', belenusHome.currentLanguage);
    var msgCount = 0;
	while (true) {
		var message = belenusHome.getQueryField(window.location.search, "Message" + msgCount);
		if (message == null) break;
		addAppletParam(appletNode, 'Message' + msgCount++ , message);
	}
	addAppletParam(appletNode, 'Message' + msgCount++ , 'Table,SetGUIParam,Name=LogicColumns&Value='+belenusHome.getPath('logcol.xml'));
	addAppletParam(appletNode, 'Message' + msgCount++ , 'Table,EnableShopping,Enable=' + belenusHome.shoppingEnabled);
    var tableStyles = belenusHome.getTableStyleAppletParams("Table");
    for(styles in tableStyles) addAppletParam(appletNode, "Message"+msgCount++, tableStyles[styles]);
    tc.appendChild(appletNode);
}