function checkPhone(t){

	t.value = parseUSNumber(t.value);
}

function parseUSNumber(PhoneNumberInitialString){

    fs = "";
    index = 0;
    var LimitCheck;

    LimitCheck = PhoneNumberInitialString.length;
    while (index != LimitCheck)
      {

        if (isNaN(parseInt(PhoneNumberInitialString.charAt(index))))
          { }
        else
          { fs = fs + PhoneNumberInitialString.charAt(index); }
        index = index + 1;
      }

    if (fs.length == 10)
      {
        fs = "(" +fs.substring(0,3) + ") " + fs.substring(3,6) + "-" + fs.substring(6,10);
      }
    else
      {
        fs=PhoneNumberInitialString;
        alert("United States phone numbers must have exactly ten digits.");
      }

    return fs;
  }
  
function getMemberCat()
{

for (var i=0; i < document.forms[0].membercat.length; i++)
   {
   if (document.forms[0].membercat[i].checked)
      {
      return document.forms[0].membercat[i].value;
      }
   }
   
   return "Selected none"; 
}

function toggleMultiple(which) {

	for (var i=1; i < document.forms[0].term.length; i++)
	{
		document.forms[0].term[i].disabled = which;
		if(which) document.forms[0].term[i].checked = false;
	}
	
	if (which) document.forms[0].term[0].checked = true;
	
	if (which) {
		document.getElementById("itp").style.display = "block";
		document.getElementById("itp").style.display = "block";
	} else {
		document.getElementById("itp").style.display = "none";
		document.getElementById("itp").style.display = "none";	
	}
}

function justAddressUpdate(which) {

	/* document.forms[0].testtype.value = which; */

	if(which == "NEW ADDRESS") {
	
		document.getElementById("step2").style.display = "none";
		document.getElementById("step3").style.display = "none";
		document.getElementById("step5").style.display = "none";
		document.getElementById("step4legend").firstChild.nodeValue = "Step 2: Share with us any comments you have";
		document.getElementById("step6legend").firstChild.nodeValue = "Step 3: Verify and Submit";

	} else {
	
		document.getElementById("step2").style.display = "block";
		document.getElementById("step3").style.display = "block";
		document.getElementById("step5").style.display = "block";
		document.getElementById("step4legend").firstChild.nodeValue = "Step 4: Share with us any comments you have";
		document.getElementById("step6legend").firstChild.nodeValue = "Step 6: Verify and Submit";
	
	}

}

function changeAppYear(curmonth, cutoff, curyr, which) {

if (curmonth < cutoff && which == "RENEWING MEMBER") {
	
	chg_yr = curyr + 1;

	document.getElementById("appyears").innerHTML = "<strong>Application for Fiscal Year " + chg_yr + " (July 1, " + chg_yr + " to June 30, " + (chg_yr+1) + ")</strong>";
	
} else {
	
	chg_yr = curyr; 
	
	document.getElementById("appyears").innerHTML = "<strong>Application for Fiscal Year " + chg_yr + " (July 1, " + chg_yr + " to June 30, " + (chg_yr+1) + ")</strong>";
	
}
	
}
