
function Step1Validate()
{
  if (! CheckCouncil() )
	{ return false; }
  if (! CheckUnitNumber() )
	{ return false; }
  if (! CheckUnitCity() )
	{ return false; }
  if (! CheckUnitState() )
	{ return false; }
}

function CheckCouncil()
{
  var council = new String(step1.u_council.value);
  var other = new String(step1.u_council_other.value);
  var nonalpha = /[^a-zA-z0-9]/;
 
  if (council == "none") 
  {
     alert("Please select your Unit's Council");
     step1.u_council.focus();
     return false;
  }

  if (council == "other" && other == "")
  {
     alert("You have selected a Unit Council not in the list.  Please type in the name of your Council.");
     step1.u_council_other.focus();
     return false;
  }

  if (other.search(nonalpha) > -1)
  {
     alert("Council name may only contain the characters a-z, A-Z, 0-9, -, and .");
     step1.u_counil_other.value = "";
     step1.u_council_other.focus();
     return false;
  }

  return true;
}

function CheckUnitType()
{
  var type = new String(step1.u_type.value);

  if (type == "none") 
  {
     alert("Please select if your Unit is a Pack or Troop");
     step1.u_type.focus();
     return false;
  }

  return true;
}

function CheckUnitNumber()
{
  var exp = /^\d+$/;
  var num = new Number(step1.u_num.value);
  var numStr = new String(step1.u_num.value);
  var numLen = numStr.length;

  if (numStr.search(exp) < 0)
  {
     alert("Your Unit Number should only contain numeric characters.  Please fix this field");
     step1.u_num.focus();
     return false;
  }

  if (numLen > 4) 
  {
     alert("Your Unit Number may not contain more than 4 digits");
     step1.u_num.focus();
     return false;
  }

  if (num < 1) 
  {
     alert("Please enter your Unit Number");
     step1.u_num.focus();
     return false;
  }

  return true;
}

function CheckUnitCity()
{
  var city = new String(step1.u_city.value);
  var cityLen = city.length;

  if (city == "" || cityLen < 2)
  {
     alert("Please enter the city/town that your Unit resides in");
     step1.u_city.focus();
     return false;
  }

  return true;
}

function CheckUnitState()
{
  var state = new String(step1.u_state.value);

  if (state == "none") 
  {
     alert("Please select your Unit's state from the list");
     step1.u_state.focus();
     return false;
  }

  return true;
}


