	function open_tree(num,tpl) {
		
		var n = window.open('/mp/tree?activenode=' + num +
												'&showactive=1&grantmask=1' +
												'&OPEN=' + num + '&tpl=' + tpl,
												'',
												'width=600,height=500,scrollbars=yes,resizable=yes');
		n.focus();
	}
	function open_tree_structure(num,tpl) {
		
		var n = window.open('/mp/tree?activenode=' + num +
												'&showactive=1&showhidden=1' +
												'&OPEN=' + num + '&tpl=' + tpl,
												'',
												'width=600,height=500,scrollbars=yes,resizable=yes');
		n.focus();
	}

	function open_node_edit() {
		
    var args = open_node_edit.arguments;
			
		var num = args[0]; // the form object
		var type = args[1];
		var params = '';
		if(args.length>2) {
			params = '&' + args[2];
		}
		
		window.POPUP_PROPERLY_CLOSED=1;

		 win('/mp/u?A=EDIT&num='+num+'&TYPE='+type+params,
			 'TOKEN' + num,
             634,
             570,
             'scrollbars=yes,resizable=yes');

	}

	function new_node() {
    var args = new_node.arguments;
			
		var dd = args[0]; // the dropdown
		var extra_args = args[1];
		
    if(!extra_args) {
      extra_args='';
    } else {
      extra_args = '&' + extra_args;
    }


		window.POPUP_PROPERLY_CLOSED=0;	// Will be set by buttons().
		window.POPUP_NUM=0;							// Will be set in the popup window.


		var s=dd;


		// Vanhantyyppinen
		if(dd.options) {
			s = dd.options[dd.selectedIndex].value;
			dd.selectedIndex = 0;
		}

		if(s=='')
			return false;

		var parent = s.substring(0,s.indexOf(','));
		var type = s.substring(s.indexOf(',')+1);
		
		var n = window.open('/mp/u?A=NEW&num='+parent+'&TYPE='+type+extra_args,
												'',
												'width=634,height=570,scrollbars=yes,resizable=yes');
		n.focus();
		return true;
	}

	function ensure_proper_closing() {
		
		// See new_node().
		
		if(!window.POPUP_PROPERLY_CLOSED) {
			document.location.href='/mp/u?A=DEL&num=' + window.POPUP_NUM + '&GOTO=' + escape(document.location.href);
			
		} else if(window.LOCK_RELEASE_HREF) {
			document.location.href = window.LOCK_RELEASE_HREF;
		}
		return true;
	}


