{if $printTemplate}
{* Javascript TAGs *}
{foreach from=$form->fields item=field}
  {if ($field->type==='javascript')}
  <script type="text/javascript">
    {$field->field}
  </script>
  {/if}
{/foreach}
{/if}
{if $printJavaScript}
var oPopupMenu_{$form->name};
function popupMenu_{$form->name}( target )
{literal}
{
  try {
  {/literal}
  var menuObserver=leimnud.factory(leimnud.pattern.observer,true);
  leimnud.event.add(document.body,"click",menuObserver.update);

  oPopupMenu_{$form->name} = new leimnud.module.app.menuRight();
  oPopupMenu_{$form->name}.make(
  {literal}
  {
    target: target,
  {/literal}
  theme: "{$form->theme}",
  menu:[
    {php}$this->assign('firstfield', true);{/php}
    {foreach from=$form->fields item=field key=name}
    {if $field->type==='popupoption'}
      {if !$firstfield},{/if}
      {$field->getEvents()}
      {php}$this->assign('firstfield', false);{/php}
    {/if}
    {/foreach}
    {literal}
    ],
    parent:leimnud
    });
    {/literal}
    menuObserver.register(oPopupMenu_{$form->name}.remove,oPopupMenu_{$form->name});
	{literal}

  } catch (e) {
  }
}
{/literal}
{/if}