//Требуется 
//	trivial.js
//	config-makers.js
//	node-by-array.js

function patchFormMessage(){
	if(!theForm||!theForm.message)return false;
	var relative=(new nodeShell(theForm.message)).previous();
	var sender=relative.runPath('../../++/1');

	function configButton16x16(c){
		if(c[0]=='br') return [['br']];
		else return [' ',
				['a',{href:c[2],target:c[3],title:c[1]},
					['img',{src:c[0],title:c[1],alt:c[1],border:'0',style:{width:16,height:16}}]
				]
			];
	}

	function configSender(c){
		if(c[0]=='br') return [['br']];
		else{
			if(!(c[1] instanceof Function)) c[1]=new Function(c[1]);
			return [' ',['input',{type:'button',className:'sender',value:c[0],onclick:c[1]}]];
		}
	}

	//фиксим косяк с таблицей цветов
	var tabcol=document.getElementById('tabcol');
	createNodeByArray.d([tabcol,{style:{position:'',visibility:'',display:'none'}}]);
	window.colorviz=function(){monopoldisplay('tabcol');};
	
	theForm.controller={
		addButtons:function(){
			relative.before(createNodesByArray.d(multiconfig(isDirective,configButton16x16,true,Array.from(arguments))));
		},
		addPane:function(paneconfig){
			var n=createNodeByArray.d(paneconfig);
			relative.append(n);
			return n;
		},
		addPaneAutotext:function(id){
			function configLink(c){
				return [['a',{href:'#',target:'_self',onclick:function(){pst3(c[1]);}},c[0]],['br']];
			}
			var config=['div',{id:id,style:{display:'none',
				oncreate:function(){this.shell=new NodeShell(this);},
				add:function(caption,text){
					this.shell.append(createNodesByArray.d(configLink([caption,text])));
				}
			}];
			if(arguments.length>1){
				var t=Array.prototype.slice.call(arguments,1);
				config.concat(t.splitStep(2).map(configLink).concatMembers());
			}
			return this.addPane(config);
		},
		addSender:function(){
			sender.append(createNodesByArray.d(multiconfig(isDirective,configSender,true,Array.from(arguments))));
		}
	};
	return true;
}
