
function copyValues(cFrom, cTo)
{
  for (var i = 0; i < cFrom.length; i++)
  {
    if (cFrom[i].tagName == 'INPUT')
    {
      copyContorlValue(cFrom[i], cTo[i]);
    }
    else if ((cFrom[i].tagName == 'SPAN') || (cFrom[i].tagName == 'DIV') || (cFrom[i].tagName == 'TABLE'))
    {
      getChildControls(cFrom[i].getElementsByTagName('INPUT'), cTo[i].getElementsByTagName('INPUT'));
    }
  }
}

function copyContorlValue(oSrc, oDest)
{
  if (oSrc.tagName == 'INPUT')
  {
    if (oSrc.type == 'text')
    {
      oDest.value = oSrc.value;
    }
    else if ((oSrc.type == 'radio') || (oSrc.type == 'checkbox'))
    {
      oDest.checked = oSrc.checked;
    }
  }
  else if (oSrc.tagName == 'SELECT')
  { 
    oDest.selectedIndex = oSrc.selectedIndex;
  }
}


function getChildControls(oSrc, oDest)
{
  if (oSrc.length != oDest.length)
    return;
  for (var i = 0; i < oSrc.length; i++)
  {
    oDest[i].checked = oSrc[i].checked;
  }
}

