{if $printTemplate}
{* this is the xmlform template *}
<form id="form[{$form->id}]" name="form[{$form->name}]" action="{$form->action}" method="post" style="margin:0px;" class="formSearch">
<table class="borderForm" id="{$form->name}" name="{$form->name}" class="basicTable" width='{$form->width}' cellspacing="0" cellpadding="0" style="display:none;width:{$form->width};">
  <tr>
    <td valign='top'>
{if isset($form->title) && $form->title !=='' }
   <table class="Header"  width='100%'>
     <tr>
      <th>{$form->title}</th>
     </tr>
   </table>
   {/if}
<div class="boxTopBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>
<div class="content">


   <table class='Record' >{assign var='colCount' value=0}
	   {foreach from=$form->fields item=field}
{if ($field->type==='title')}
     <tr>
      <td class='FormTitle' colspan="2">{$field->field}</td>
     </tr>{assign var='colCount' value=0}
{elseif ($field->type==='subtitle')}
     <tr>
      <td class='FormSubTitle' colspan="2">{$field->field}</td>
     </tr>{assign var='colCount' value=0}
{elseif ($field->type==='button') || ($field->type==='submit') || ($field->type==='reset')}
     {if $colCount ==0}<tr valign="top">{/if}
      {math equation="(colCount + 1) % cols" colCount=$colCount cols=$form->cols format="" assign="colCount"}
      <td class='FormLabel' align="center">{$field->field}</td>
     {if $colCount ==0}</tr>{/if}
{elseif ($field->type==='grid')}
     {if $colCount==0}<tr>{/if}
      <td class='FormLabel' colspan="2">{$field->field}</td>
     </tr>{assign var='colCount' value=0}
{elseif ($field->type==='javascript')}
{elseif ($field->type==='phpvariable')}
{elseif ($field->type==='private')}
{elseif ($field->type==='cellmark')}
{elseif ($field->type==='')}
{elseif ($field->type==='link')}
{elseif ($field->type==='hidden')}
{else}
     {if $colCount ==0}<tr valign="top">{/if}
      {math equation="(colCount + 1) % cols" colCount=$colCount cols=$form->cols format="" assign="colCount"}
      <td class='FormLabel' valign="top" style="width:{$form->labelWidth};"><a href="#" onclick="hideShowControl(this , '{$field->name}')">{$field->label}</a><div style="width:100%;">{$field->field}</div></td>
     {if $colCount ==0}</tr>{/if}
{/if}
{/foreach}
   </table>
   </div>
<div class="boxBottomBlue"><div class="a"></div><div class="b"></div><div class="c"></div></div>

  </td></tr>
</table>
{foreach from=$form->fields item=field}
{if ($field->type==='hidden')}
    {$field->field}
{elseif ($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[{$form->id}]'),'{$form->id}');
  var myForm=form_{$form->id};
  myForm.ajaxServer=ajaxServer;
  {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==='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}
