//---------------------------------------------------------------
// Copyright (c) 2000-2003 Asset Web Design
// Pearland, Texas 281-412-3539
//
// Any use of this script without explicit permission from 
// Asset Web Design is prohibited.
//
// 2004-05-05
//---------------------------------------------------------------

function AdvAutoFillMailingAddress (theForm)
  {
  theForm.txtMailingAddressStreet.value        = theForm.txtStreetAddressStreet.value;
  theForm.txtMailingAddressStreet2.value       = theForm.txtStreetAddressStreet2.value;
  theForm.txtMailingAddressCity.value          = theForm.txtStreetAddressCity.value;
  theForm.cboMailingAddressState.selectedIndex = theForm.cboStreetAddressState.selectedIndex;
  theForm.txtMailingAddressZipCode.value       = theForm.txtStreetAddressZipCode.value;

  return (true);
  }


//---------------------------------------------------------------


function AdvAutoFillMailingAddress2 (theForm)
  {
  theForm.txtMailingAddress2Street.value        = theForm.txtStreetAddress2Street.value;
  theForm.txtMailingAddress2Street2.value       = theForm.txtStreetAddress2Street2.value;
  theForm.txtMailingAddress2City.value          = theForm.txtStreetAddress2City.value;
  theForm.cboMailingAddress2State.selectedIndex = theForm.cboStreetAddress2State.selectedIndex;
  theForm.txtMailingAddress2ZipCode.value       = theForm.txtStreetAddress2ZipCode.value;

  return (true);
  }


//---------------------------------------------------------------


function AdvAutoFillMailingAddress3 (theForm)
  {
  theForm.txtMailingAddress3Street.value        = theForm.txtStreetAddress3Street.value;
  theForm.txtMailingAddress3Street2.value       = theForm.txtStreetAddress3Street2.value;
  theForm.txtMailingAddress3City.value          = theForm.txtStreetAddress3City.value;
  theForm.cboMailingAddress3State.selectedIndex = theForm.cboStreetAddress3State.selectedIndex;
  theForm.txtMailingAddress3ZipCode.value       = theForm.txtStreetAddress3ZipCode.value;

  return (true);
  }


//- contacts ----------------------------------------------------
//---------------------------------------------------------------


function AdvAutoFillEmergencyContact (theForm)
  {
  theForm.cboEmergencyContactPrefix.value               = theForm.iSpousePrefixID.value;
  theForm.txtEmergencyContactFirstName.value            = theForm.sSpouseFirstName.value;
  theForm.txtEmergencyContactMiddleName.value           = theForm.sSpouseMiddleName.value;
  theForm.txtEmergencyContactLastName.value             = theForm.sSpouseLastName.value;
  theForm.cboEmergencyContactSuffix.value               = theForm.iSpouseSuffixID.value;
  theForm.txtEmergencyContactWorkPhoneAreaCode.value    = theForm.sSpouseWorkPhoneAreaCode.value;
  theForm.txtEmergencyContactWorkPhoneExchange.value    = theForm.sSpouseWorkPhoneExchange.value;
  theForm.txtEmergencyContactWorkPhoneLineNumber.value  = theForm.sSpouseWorkPhoneLineNumber.value;
  theForm.txtEmergencyContactWorkPhoneExtension.value   = theForm.sSpouseWorkPhoneExtension.value;
  theForm.txtEmergencyContactHomePhoneAreaCode.value    = theForm.sSpouseHomePhoneAreaCode.value;
  theForm.txtEmergencyContactHomePhoneExchange.value    = theForm.sSpouseHomePhoneExchange.value;
  theForm.txtEmergencyContactHomePhoneLineNumber.value  = theForm.sSpouseHomePhoneLineNumber.value;
  theForm.txtEmergencyContactHomePhoneExtension.value   = theForm.sSpouseHomePhoneExtension.value;
  theForm.txtEmergencyContactCellPhoneAreaCode.value    = theForm.sSpouseCellPhoneAreaCode.value;
  theForm.txtEmergencyContactCellPhoneExchange.value    = theForm.sSpouseCellPhoneExchange.value;
  theForm.txtEmergencyContactCellPhoneLineNumber.value  = theForm.sSpouseCellPhoneLineNumber.value;
  theForm.txtEmergencyContactCellPhoneExtension.value   = theForm.sSpouseCellPhoneExtension.value;
  theForm.txtEmergencyContactPagerPhoneAreaCode.value   = theForm.sSpousePagerPhoneAreaCode.value;
  theForm.txtEmergencyContactPagerPhoneExchange.value   = theForm.sSpousePagerPhoneExchange.value;
  theForm.txtEmergencyContactPagerPhoneLineNumber.value = theForm.sSpousePagerPhoneLineNumber.value;
  theForm.txtEmergencyContactPagerPhoneExtension.value  = theForm.sSpousePagerPhoneExtension.value;
  theForm.txtEmergencyContactEmail.value                = theForm.sSpouseEmail.value;
  theForm.cboMiscRelationship.value                     = 2;

  return (true);
  }


//---------------------------------------------------------------

function AdvAutoFillSpouse (theForm)
  {
  theForm.cboSpousePrefix.value               = theForm.iEmergencyContactPrefixID.value;
  theForm.txtSpouseFirstName.value            = theForm.sEmergencyContactFirstName.value;
  theForm.txtSpouseMiddleName.value           = theForm.sEmergencyContactMiddleName.value;
  theForm.txtSpouseLastName.value             = theForm.sEmergencyContactLastName.value;
  theForm.cboSpouseSuffix.value               = theForm.iEmergencyContactSuffixID.value;
  theForm.txtSpouseWorkPhoneAreaCode.value    = theForm.sEmergencyContactWorkPhoneAreaCode.value;
  theForm.txtSpouseWorkPhoneExchange.value    = theForm.sEmergencyContactWorkPhoneExchange.value;
  theForm.txtSpouseWorkPhoneLineNumber.value  = theForm.sEmergencyContactWorkPhoneLineNumber.value;
  theForm.txtSpouseWorkPhoneExtension.value   = theForm.sEmergencyContactWorkPhoneExtension.value;
  theForm.txtSpouseHomePhoneAreaCode.value    = theForm.sEmergencyContactHomePhoneAreaCode.value;
  theForm.txtSpouseHomePhoneExchange.value    = theForm.sEmergencyContactHomePhoneExchange.value;
  theForm.txtSpouseHomePhoneLineNumber.value  = theForm.sEmergencyContactHomePhoneLineNumber.value;
  theForm.txtSpouseHomePhoneExtension.value   = theForm.sEmergencyContactHomePhoneExtension.value;
  theForm.txtSpouseCellPhoneAreaCode.value    = theForm.sEmergencyContactCellPhoneAreaCode.value;
  theForm.txtSpouseCellPhoneExchange.value    = theForm.sEmergencyContactCellPhoneExchange.value;
  theForm.txtSpouseCellPhoneLineNumber.value  = theForm.sEmergencyContactCellPhoneLineNumber.value;
  theForm.txtSpouseCellPhoneExtension.value   = theForm.sEmergencyContactCellPhoneExtension.value;
  theForm.txtSpousePagerPhoneAreaCode.value   = theForm.sEmergencyContactPagerPhoneAreaCode.value;
  theForm.txtSpousePagerPhoneExchange.value   = theForm.sEmergencyContactPagerPhoneExchange.value;
  theForm.txtSpousePagerPhoneLineNumber.value = theForm.sEmergencyContactPagerPhoneLineNumber.value;
  theForm.txtSpousePagerPhoneExtension.value  = theForm.sEmergencyContactPagerPhoneExtension.value;
  theForm.txtSpouseEmail.value                = theForm.sEmergencyContactEmail.value;

  return (true);
  }


//- date --------------------------------------------------------
//---------------------------------------------------------------

function AdvAutoFillEndOfYear (cboMonth, cboDay, cboYear) 
  {
  var i;
  var iLength;

  var dNow;  
  var iMonth;
  var iDay;
  var iYear;

  // init
  dNow = new Date ();
  iMonth = 12;
  iDay   = 31;
  iYear  = dNow.getFullYear ();
  
  // month
  iLength = cboMonth.length;

  for (i=0; i<iLength; i++)
    if (cboMonth.options[i].value == iMonth)
      {
      // found it!
      cboMonth.selectedIndex = i;
      }
    
  // day
  iLength = cboDay.length;
  
  for (i=0; i<iLength; i++)
    if (cboDay.options[i].value == iDay)
      {
      // found it!
      cboDay.selectedIndex = i;
      }
    
  // year
  iLength = cboYear.length;

  for (i=0; i<iLength; i++)
    if (cboYear.options[i].value == iYear)
      {
      // found it!
      cboYear.selectedIndex = i;
      }
    
  return (true);
  }
  

//---------------------------------------------------------------

function AdvAutoFillToday (cboMonth, cboDay, cboYear) 
  {
  var i;
  var iLength;

  var dNow;  
  var iMonth;
  var iDay;
  var iYear;

  // init
  dNow = new Date ();
  iMonth = dNow.getMonth () + 1;
  iDay   = dNow.getDate ();
  iYear  = dNow.getFullYear ();
  
  // month
  iLength = cboMonth.length;

  for (i=0; i<iLength; i++)
    if (cboMonth.options[i].value == iMonth)
      {
      // found it!
      cboMonth.selectedIndex = i;
      }
    
  // day
  iLength = cboDay.length;
  
  for (i=0; i<iLength; i++)
    if (cboDay.options[i].value == iDay)
      {
      // found it!
      cboDay.selectedIndex = i;
      }
    
  // year
  iLength = cboYear.length;

  for (i=0; i<iLength; i++)
    if (cboYear.options[i].value == iYear)
      {
      // found it!
      cboYear.selectedIndex = i;
      }
    
  return (true);
  }
  


