//---------------------------------------------------------------
// 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.
//
// 08-04-2005
//---------------------------------------------------------------

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);
  }


//- organization ------------------------------------------------
//---------------------------------------------------------------

function AdvAutoFillOrganizationSales (theForm)
  {
  theForm.txtSalesPhoneAreaCode.value    = theForm.txtOrganizationPhoneAreaCode.value;
  theForm.txtSalesPhoneExchange.value    = theForm.txtOrganizationPhoneExchange.value;
  theForm.txtSalesPhoneLineNumber.value  = theForm.txtOrganizationPhoneLineNumber.value;
  theForm.txtSalesPhoneExtension.value   = theForm.txtOrganizationPhoneExtension.value;
  theForm.txtSalesPhone2AreaCode.value   = theForm.txtOrganizationPhone2AreaCode.value;
  theForm.txtSalesPhone2Exchange.value   = theForm.txtOrganizationPhone2Exchange.value;
  theForm.txtSalesPhone2LineNumber.value = theForm.txtOrganizationPhone2LineNumber.value;
  theForm.txtSalesPhone2Extension.value  = theForm.txtOrganizationPhone2Extension.value;
  theForm.txtSalesEmail.value            = theForm.txtOrganizationEmail.value;

  return (true);
  }


//---------------------------------------------------------------

function AdvAutoFillOrganizationService (theForm)
  {
  theForm.txtServicePhoneAreaCode.value    = theForm.txtOrganizationPhoneAreaCode.value;
  theForm.txtServicePhoneExchange.value    = theForm.txtOrganizationPhoneExchange.value;
  theForm.txtServicePhoneLineNumber.value  = theForm.txtOrganizationPhoneLineNumber.value;
  theForm.txtServicePhoneExtension.value   = theForm.txtOrganizationPhoneExtension.value;
  theForm.txtServicePhone2AreaCode.value   = theForm.txtOrganizationPhone2AreaCode.value;
  theForm.txtServicePhone2Exchange.value   = theForm.txtOrganizationPhone2Exchange.value;
  theForm.txtServicePhone2LineNumber.value = theForm.txtOrganizationPhone2LineNumber.value;
  theForm.txtServicePhone2Extension.value  = theForm.txtOrganizationPhone2Extension.value;
  theForm.txtServiceEmail.value            = theForm.txtOrganizationEmail.value;

  return (true);
  }


//- members -----------------------------------------------------
//---------------------------------------------------------------


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.txtEmergencyContactPagerAreaCode.value       = theForm.sSpousePagerAreaCode.value;
  theForm.txtEmergencyContactPagerExchange.value       = theForm.sSpousePagerExchange.value;
  theForm.txtEmergencyContactPagerLineNumber.value     = theForm.sSpousePagerLineNumber.value;
  theForm.txtEmergencyContactPagerExtension.value      = theForm.sSpousePagerExtension.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.txtSpousePagerAreaCode.value       = theForm.sEmergencyContactPagerAreaCode.value;
  theForm.txtSpousePagerExchange.value       = theForm.sEmergencyContactPagerExchange.value;
  theForm.txtSpousePagerLineNumber.value     = theForm.sEmergencyContactPagerLineNumber.value;
  theForm.txtSpousePagerExtension.value      = theForm.sEmergencyContactPagerExtension.value;
  theForm.txtSpouseEmail.value               = theForm.sEmergencyContactEmail.value;

  return (true);
  }


//- member directory --------------------------------------------
//---------------------------------------------------------------

function AdvAutoFillMemberDirectorySelect (theForm)
  {
  theForm.chkMemberDirectoryName.checked           = true;
  theForm.chkMemberDirectoryWorkPhone.checked      = true;
  theForm.chkMemberDirectoryHomePhone.checked      = true;
  theForm.chkMemberDirectoryCellPhone.checked      = true;
  theForm.chkMemberDirectoryPager.checked          = true;
  theForm.chkMemberDirectoryFax.checked            = true;
  theForm.chkMemberDirectoryEmail.checked          = true;
  theForm.chkMemberDirectoryMailingAddress.checked = true;

  return (true);
  }


//---------------------------------------------------------------

function AdvAutoFillMemberDirectoryClear (theForm)
  {
  theForm.chkMemberDirectoryName.checked           = false;
  theForm.chkMemberDirectoryWorkPhone.checked      = false;
  theForm.chkMemberDirectoryHomePhone.checked      = false;
  theForm.chkMemberDirectoryCellPhone.checked      = false;
  theForm.chkMemberDirectoryPager.checked          = false;
  theForm.chkMemberDirectoryFax.checked            = false;
  theForm.chkMemberDirectoryEmail.checked          = false;
  theForm.chkMemberDirectoryMailingAddress.checked = false;

  return (true);
  }


//---------------------------------------------------------------

function AdvAutoFillMemberDirectoryName (theForm)
  {
  if (theForm.chkMemberDirectoryName.checked == false)
    {
    // name was deselected
    AdvAutoFillMemberDirectoryClear (theForm);
    }

  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);
  }
  

