{if $printTemplate}
{* this is the xmlform template *}
<form id="{$form->id}" name="{$form->id}" action="{$form->action}" method="post" encType="multipart/form-data">
<table width='{$form->width}' cellpadding="0" cellspacing="0" border="0">
<tr><td>
<table width='100%' class="basicTable">
  <tr><td valign='top'>
{if isset($form->title) && $form->title !=='' }
   <table class="Header" >
     <tr>
      <th>{$form->title}</th>
     </tr>
   </table>
{/if}
   <table class='Record' cellspacing="0" cellpadding="0">
{foreach from=$form->fields item=field}
{if ($field->type==='title')}
     <tr>
      <td class='FormTitle' colspan="2">{$field->field}</td>
     </tr>
{elseif ($field->type==='subtitle')}
     <tr>
      <td class='FormSubTitle' colspan="2">{$field->field}</td>
     </tr>
{elseif ($field->type==='button') || ($field->type==='submit') || ($field->type==='reset')}
{elseif ($field->type==='grid')}
     <tr>
      <td class='FormField' colspan="2">{$field->field}</td>
     </tr>
{elseif ($field->type==='checkbox')}
     <tr>
      <td class='FormLabel' width="{$form->labelWidth}"></td>
      <td class='FormField'>{$field->field}</td>
     </tr>
{elseif ($field->type==='javascript')}
{elseif ($field->type==='phpvariable')}
{elseif ($field->type==='private')}
{elseif ($field->type==='hidden')}
     <tr style="display:none;">
      <td colspan="2">{$field->field}</td>
     </tr>
{elseif ($field->type==='')}
{elseif ($field->withoutLabel)}
     <tr>
      <td colspan="2">{$field->field}</td>
     </tr>
{else}
     <tr>
      <td class='FormLabel' width="{$form->labelWidth}">{$field->label}</td>
      <td class='FormField'>{$field->field}</td>
     </tr>
{/if}
{/foreach}
   </table>
  </td></tr>
</table>
</td><td width="100px" align="center" valign="bottom" style="background-image:url(file:///Z|/workflow/trunk/public_html/images/main.jpg);background-repeat:no-repeat;background-position: 100% 50%;">
  <table cellpadding="0" cellspacing="0" border="0">
  {foreach from=$form->fields item=field}
  {if ($field->type==='button') || ($field->type==='submit') || ($field->type==='reset')}
       <tr>
        <td>{$field->field}</td>
       </tr>
  {/if}
  {/foreach}
  </table>
</td></tr>
</table>
{foreach from=$form->fields item=field}
	{if ($field->type==='javascript')}
	<script type="text/javascript">
		{$field->field}
	</script>
	{/if}
{/foreach}
</form>
{/if}
{if $printJSFile}
var form_{$form->id};
var i;
function loadForm_{$form->id}(ajaxServer)
{literal}{{/literal}
swSubmitValidateForm = 1;
if (typeof(G_Form)==='undefined') return alert('form.js was not loaded');
  form_{$form->id}=new G_Form(document.getElementById('{$form->id}'),'{$form->id}');
  var myForm=form_{$form->id};
  myForm.ajaxServer=ajaxServer;
  //{$form->ajaxSubmit}
  {if isset($form->ajaxSubmit) && ($form->ajaxSubmit)}
  {literal}
    var sub = new leimnud.module.app.submit({
        form    : myForm.element
      });
    sub.sendObj = false;
  {/literal}
  {/if}
  {foreach from=$form->fields item=field key=name}
    i = myForm.aElements.length;
    {if ($field->type==='dropdown')}
      myForm.aElements[i] = new G_DropDown(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='text')}
      myForm.aElements[i] = new G_Text(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='percentage')}
      myForm.aElements[i] = new G_Percentage(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='currency')}
      myForm.aElements[i] = new G_Currency(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='textarea')}
      myForm.aElements[i] = new G_TextArea(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='date')}
      myForm.aElements[i] = new G_Date(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='hidden')}
      myForm.aElements[i] = new G_Text(myForm, myForm.element.elements['form[{$name}]'],'{$name}');
      myForm.aElements[i].setAttributes({$field->getAttributes()});
      {$field->attachEvents("myForm.aElements[i].element")}
    {elseif ($field->type==='grid')}
      myForm.aElements[i] = new G_Grid(myForm, '{$name}');
      grid_{$field->id}(myForm.aElements[i]);
      {$field->attachEvents("myForm.aElements[i].element")}
    {else}
      var element = getField("{$name}");
      {$field->attachEvents("element")}
    {/if}
  {/foreach}
  {foreach from=$form->fields item=field key=name}
    {if isset($field->dependentFields) && ($field->dependentFields!='')}
      {if ($field->type==='dropdown')}
          myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
      {elseif ($field->type==='text')}
          myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
      {elseif ($field->type==='percentage')}
          myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
      {elseif ($field->type==='currency')}
          myForm.getElementByName('{$name}').setDependentFields('{$field->dependentFields}');
      {/if}
    {/if}
  {/foreach}
{literal}}{/literal}
{/if}
{if $printJavaScript}
leimnud.event.add(window,'load',function(){literal}{{/literal}loadForm_{$form->id}('{$form->ajaxServer}');{literal}}{/literal});
{/if}
