 /* Copyright (C) 2006-2009 by Joseph McVerry - American Coders, Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

function comp_display()
{
  var alength = this.dataelements.length;
  var docmnt = "";
  docmnt+="<center>\n";
  if (this.help != null)      
   	docmnt+='<div title="header=['+this.name+'] body=['+this.help+'] delay=[450] singleclickstop=[on] offsetx=[-200]">'
  docmnt+="<table width=100% border=4 bgcolor=#FAEBD0>";
  
  docmnt+="<tr><td>"+this.name+"";
  if (this.required == 'M')
    docmnt+="<br><font size=-2>Required</font>";
  docmnt+="</td></tr>\n";
    

  docmnt+="<tr><td>";
  var i;
  for (i=0; i<alength; i++)
    {
       docmnt+= this.dataelements[i].display();
    }
  docmnt+="</td></tr>";
  docmnt+="</table>";
  if (this.help != null)      
     	docmnt+='</div>'
  docmnt+="</center>\n";
  return docmnt;
}

function comp_clear()
{
  var alength = this.dataelements.length;
  var i;
  for (i=0; i<alength; i++)
    {
        this.dataelements[i].clear();
    }
  
}
function comp_verify()
{
  var ok = true;
  var i;
  var alength = this.dataelements.length;
  for (i=0; i<alength; i++)
    {
       testvalue = this.dataelements[i].verify();
       if (testvalue != true)
         return false;
    }
  return ok;
}
function comp_get()
{
  var a = "";
  var alength = this.dataelements.length;
  var i;
  for (i=0; i<alength; i++)
    {
       a+=this.dataelements[i].get();
    }

  return a
}
function comp_didUserEnterData()
{
  var alength = this.dataelements.length;
  var i;
  for (i=0; i<alength; i++)
    {
      if (this.dataelements[i].didUserEnterData()  == true)
        return true;
    }

  return false
}
function Composite(node)
{


  if (node == null)
     return;

  var attr=node.attributes
  

       for (var i = 0; i < attr.length; i++) {
              
          if (attr[i].name == 'name')
             this.name = attr[i].value
          if (attr[i].name == 'pos')
             this.pos = attr[i].value
          if (attr[i].name == 'required')
             this.required = attr[i].value
          if (attr[i].name == 'help')
             this.help = attr[i].value
          }

	//<comp pos='1' name='test comp' title='testing out the comp' required='M'/>


  
  var des=node.getElementsByTagName("de");
  
  this.dataelements = new Array()
  
  for (var i = 0; i < des.length; i++)
    {  
     //alert(i)
      this.dataelements[i]=new DataElement(des.item(i));
      }
  

}
  new Composite(null);
  Composite.prototype.display = comp_display;
  Composite.prototype.clear = comp_clear;
  Composite.prototype.verify = comp_verify;
  Composite.prototype.get = comp_get;
  Composite.prototype.didUserEnterData = comp_didUserEnterData;

