/*
** (C)Copyright Internet Intuitive - a division of ADB Internet Services Limited
**
** All code (including but not limited to HTML, JavaScript and PHP) and images
** (C)Copyright 2001-2003 ADB Internet Services Limited - all rights reserved.
**
** Filename: mod_login.js
** Version:  V1.00.a
** Date:     29-Jun-2004
*/

/*
**
** Validate User Details Update Form
**
*/
function Form_Validate_admin_members(theForm)
{
  /*
  ** Validate selection
  */
  if ( ( theForm.submit.value == "Delete" )
    || ( theForm.submit.value == "Modify" ) )
  {
    if ( theForm.id.selectedIndex == 0 )
    {
      alert("Please select the member to modify/delete!");
      theForm.id.focus();
      return (false);
    }
  }

  return (true);
}



/*
**
** Validate User Details Update Form
**
*/
function Form_UU_Validator(theForm)
{
  /*
  ** Validate passwords
  */
  if ( theForm.password1.value != "" )
  {
    if ( theForm.password1.value != theForm.password2.value )
    {
      alert("Passwords do not match!");
      theForm.password1.focus();
      return (false);
    }
  }

  /*
  ** Get current Contact_Type selection
  */
  company_type_selection = theForm.company_type.options[theForm.company_type.selectedIndex].value;

  if ( company_type_selection == "" )
  {
    alert("Please select company type!");
    theForm.company_type.focus();
    return (false);
  }

  if ( ( theForm.company_name.value == "--- please specify ---" )
    || ( theForm.company_name.value == "" ) )
  {
    alert("Please specify the company/buiness name");
    theForm.company_name.focus();
    return (false);
  }

  if ( ( theForm.company_number.value == "--- please specify ---" )
    || ( theForm.company_number.value == "" ) )
  {
    alert("Please specify the registration number");
    theForm.company_number.focus();
    return (false);
  }
  
  /*
  ** Validate contact details
  */
  if ( ( theForm.personal_name.value == "--- please specify ---" )
    || ( theForm.personal_name.value == "" ) )
  {
    alert("Please specify the a contact name");
    theForm.personal_name.focus();
    return (false);
  }

  if ( ( theForm.email_address.value == "--- please specify ---" )
    || ( theForm.email_address.value == "" ) )
  {
    alert("Please specify the a contact email address");
    theForm.email_address.focus();
    return (false);
  }

  if ( ( theForm.reg_address1.value == "--- please specify ---" )
    || ( theForm.reg_address1.value == "" ) )
  {
    alert("Please specify the registrant's address");
    theForm.reg_address1.focus();
    return (false);
  }

  if ( ( theForm.reg_town_city.value == "--- please specify ---" )
    || ( theForm.reg_town_city.value == "" ) )
  {
    alert("Please specify the registrant's town/city");
    theForm.reg_town_city.focus();
    return (false);
  }

  if ( ( theForm.reg_county.value == "--- please specify ---" )
    || ( theForm.reg_county.value == "" ) )
  {
    alert("Please specify the registrant's county");
    theForm.reg_county.focus();
    return (false);
  }

  if ( ( theForm.reg_postcode.value == "--- please specify ---" )
    || ( theForm.reg_postcode.value == "" ) )
  {
    alert("Please specify the registrant's postcode");
    theForm.reg_county.focus();
    return (false);
  }

  if ( ( theForm.reg_country.value == "--- please specify ---" )
    || ( theForm.reg_country.value == "" ) )
  {
    alert("Please specify the registrant's country");
    theForm.reg_country.focus();
    return (false);
  }

  /*
  ** Got here... must be OK
  **
  ** ... remove "optional" prompts
  */
//  if ( ( theForm.company_tradingname.value == "" ) | ( theForm.company_tradingname.value == "--- optional ---" ) ) { theForm.company_tradingname.value = "n/a"; }
  if (                                                 theForm.company_address2.value    == "--- optional ---" )   { theForm.company_address2.value    = "";    }

  return (true);
}


function Form_UC_Validator(theForm)
{
  /*
  ** Validate passwords
  */
  if ( theForm.password1.value == "" )
  {
    alert("You must enter a password!");
    theForm.password1.focus();
    return (false);
  }

  if ( theForm.password1.value != theForm.password2.value )
  {
    alert("Passwords do not match!");
    theForm.password1.focus();
    return (false);
  }

  return (true);
}


function Form_Change_CompanyType(theSelection)
{
  /*
  ** Get current Contact_Type selection
  */
  company_type_selection = theSelection.options[theSelection.selectedIndex].value;

  if ( ( company_type_selection == "IND"  )
	|| ( company_type_selection == "FIND" ) )
  {
    theSelection.form.company_name.disabled		= true;
    theSelection.form.company_name.value    	= "n/a";
    theSelection.form.company_number.disabled	= true;
    theSelection.form.company_number.value		= "n/a";
  }
  
  if ( ( company_type_selection == "LLP"   )
	|| ( company_type_selection == "LTD"   )
	|| ( company_type_selection == "PLC"   )
	|| ( company_type_selection == "RCHAR" ) )
  {
    theSelection.form.company_name.disabled 	= false;
    theSelection.form.company_name.value   		= "--- please specify ---";
    theSelection.form.company_number.disabled   = false;
    theSelection.form.company_number.value      = "--- please specify ---";
  }
  
  if ( ( company_type_selection == "STRA"   )
	|| ( company_type_selection == "PTNR"   )
	|| ( company_type_selection == "OTHER"  )
	|| ( company_type_selection == "FCORP"  )
	|| ( company_type_selection == "FOTHER" ) )
  {
    theSelection.form.company_name.disabled = false;
    theSelection.form.company_name.value    = "--- please specify ---";
    theSelection.form.company_number.disabled      = false;
    theSelection.form.company_number.value         = "n/a";
  }
}
