// formValidations.js

// newFunction
//==========================================
function CheckAll(fmobj) {

  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
   if ( (e.name != 'trgSelection') && (e.type=='checkbox')) {
      e.checked = fmobj.trgSelection.checked;
    }
  }
}

//==========================================
// Check all or uncheck all?
//==========================================
function CheckCheckAll(fmobj) {
  var TotalBoxes = 0;
  var TotalOn = 0;
  for (var i=0;i<fmobj.elements.length;i++) {
    var e = fmobj.elements[i];
    if ((e.name != 'trgSelection') && (e.type=='checkbox')) {
      TotalBoxes++;
      if (e.checked) {
       TotalOn++;
      }
    }
  }
  if (TotalBoxes==TotalOn) {
    fmobj.trgSelection.checked=true;
  }
  else {
   fmobj.trgSelection.checked=false;
  }
}


/*
* Description: library of Form Validator functions 
* This library is called by forms for a variety of both Validation
*   and formatting purposes
*/


// ====== Support Functions =============================
function popupWindow(myURL, windowName) {
    
        windowAttributeString = "width=750,height=450,toolbar=no,location=no," +
		"directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
    
        window.open( myURL, windowName, windowAttributeString)
      }
function popupWindowThisSize(myURL, windowName, myWidth, myHeight) {
    
        windowAttributeString = "width=" + myWidth + ",height=" + myHeight + ",toolbar=no,location=no," +
		"directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no";
    
        window.open( myURL, windowName, windowAttributeString)
      }		    
function strip(filter,str){
  var i,curChar;
  var retStr = '';
  var len = str.length;
  for(i=0; i<len; i++) {
    curChar = str.charAt(i);
    
    if(filter.indexOf(curChar) < 0 ) //not in filter, keep it
    retStr += curChar;
  }
  return retStr;
}

function reformat(str){
 var arg;
 var pos = 0;
 var retStr = '';
 var len = reformat.arguments.length;
 for(var i=1; i<len; i++) {
  arg = reformat.arguments[i];
  if(i%2==1)
   retStr += arg;
  else {
   retStr += str.substring(pos, pos + arg);
   pos += arg;
  }
 }
 return retStr;
}

// ======== End Support Functions ======================



// ======== Begin Validation Rules =====================

// is form field empty?
function notEmpty(str){
 if(strip(" \n\r\t",str).length ==0)
  return false;
 else
  return true;
}

// is input an integer(s)
function validateInteger(str){
 str = strip(' ',str);
 //remove leading zeros, if any
 while(str.length > 1 && str.substring(0,1) == '0') {
  str = str.substring(1,str.length);
 }
 if (isInteger(str)) {
  return true;
 } else {
  return false;
 }
}

function validateFloat(str){
 str = strip(' ',str);
 //remove leading zeros, if any
 while(str.length > 1 && str.substring(0,1) == '0'){
  str = str.substring(1,str.length);
 }
 var val = parseFloat(str);
 if(isNaN(val))
  return false;
 else
  return true;
}

function validateUSPhone(str){
 str = strip("*() -./_\n\r\t\\",str);
 //if(str.length == 10 || str.length == 7)
 if(str.length == 10)
  return true;
 else
  return false; 
}

function validateDAMPhone(str){
  str = strip("*() -./_\n\r\t\\",str);
  //if(str.length == 10 || str.length == 7)
  if(str.length < 21) {
    return true;
  }
  else {
    return false; 
  }
}

function validateSSN(str){

	if (str.substring(0,1).toUpperCase() == 'R') {
		// FEP member id
		return isInteger(str.substring(1));
	} else {
		str = strip(" -.\n\r\t",str);
		if(isInteger(str) && str.length == 9) {
			return true;
		} else {
			return false;
		}
	}
}

function validateZip(str){
 str = strip("- \n\r\t",str);
 if(isInteger(str)&&(str.length==9 || str.length==5))
  return true;
 else
  return false;
}

function validateCC(str,type){
 str = strip("-./_\n\r\t\\",str);
 if(type=="1")
  if(str.charAt(0)!="4")
   return false;
 if(type=="2")
  if(str.charAt(0)!="5")
   return false;
 if(type=="3")
  if(str.charAt(0)!="6")
   return false;
 if(type=="4")
  if(str.charAt(0)!="3")
   return false;
 if(isInteger(str)&&((str.length==15&&type=="4") || str.length==16))
  return true;
 else
  return false;
}

function validateDate(str){
 var dateVar = new Date(str);
 if(isNaN(dateVar.valueOf()) || (dateVar.valueOf() ==0))
  return false;
 else
  return true;
}

function validateEMail(str){
 str = strip(" \n\r\t",str);
 if(str.indexOf("@")>-1 && str.indexOf(".")>-1)
  return true;
 else
  return false;
}

//check for two fields being equal
function compare(str, str2){
 if(str != str2){
  return false;
 }
 else {
  return true;
 }
}

//check for password length (min 6 - max 32)
function validatePasswordLength(str) {
 if(str.length < 8 || str.length > 32) {
  return false;
 }
 else { 
  return true;
 }
}

//check for UserID length (min 8 - max 64)
function validateUserIDLength(str) {
 if(str.length < 8 || str.length > 64) {
  return false;
 }
 else { 
  return true;
 }
}

//check for valid day 
function validateDayFormat(mStr, dStr, yStr) {
  if ((isInteger(mStr)== false) || 
      (isInteger(dStr)== false) || 
      (isInteger(yStr)== false) ) {
     return false;
  } 
  var mo = parseInt(mStr, 10);
  var da = parseInt(dStr, 10);
  
// needed? 
// strip century if present
// if(yStr.length == 4) {
//   yStr = yStr.substring(2,5);
// }
      
  var ye = parseInt(yStr, 10);

  if (da < 1 || da > 31 ||mo < 1 || mo > 12 || mStr == "" || dStr == "" || yStr == "") { 
    return false; 
  }

  if ((mo == 4) || (mo == 6) || (mo == 9) || (mo == 11)) {
    //it is a 30 day month
    if (da > 30) { 
      return false; 
    }
  } 
  else if (mo == 2) {  
    // it is february (either 28 or 29 depending on leap year)
    if (isLeapYear(ye) == true) { 
      if (da > 29) {
        //leap years have 29 days in february
        return false;
      } 
    } 
    else {
      if (da > 28) {
        //non leap years have 28 days in february
        return false;
      }
    } 
  } 
  else {
    // it is a 31 day month
    if (da > 31) {
      return false;
    }
  }
  // must be valid
  return true;
}


//check for valid month
function validateMonthFormat(str) {
  if (isInteger(str)== false) {
    return false;
  }
  if (isInteger(str)== true) {
    if (str < 1 || str > 12) {
      return false;
    }
  }
  else { 
    return true; 
  }
}

//check for valid year
function validateYearFormat(str) {
  str = strip("-./_\n\r\t\\",str);
  if (isInteger(str) == false) {
    return false;
  }
  
  // check for one or three digits, can't 
  // tell year from that 
  // Defect 552, can't really guess 19 or 20 anyway, so it has to be length 4
  // this now defaults to a length of 4 - anything else is false
  //if ((str.length == 1) || (str.length == 3) || (str.length == 2)) {
  //  return false;
  //}
  
  if (str.length == 4) {
    // check century
    var century = str.substring(0,2);
    
    // if first two digits are not 19 or 20, no good
    if ((century < "19" ) || (century > "20")) {
      return false;
    }
    
    return true;
  } 
  return false;
}

//check for valid year and centrury 2000
function validateYearFormat2000(str) {
  str = strip("-./_\n\r\t\\",str);
  if (isInteger(str) == false) {
    return false;
  }
  
  if (str.length == 4) {
    // check century
    var century = str.substring(0,2);
    
    // if first two digits are not 20, no good
    if (century != "20") {
      return false;
    }
    
    return true;
  } 
  return false;
}

// expects date in M or MM-D or DD - YY or CCYY
// will strip out hyphens and add leading zeros in month if needed
function parseMonth(dateString) {
  month =  dateString.substring (0, dateString.indexOf ("-"));
  month = formatLeadingZero(month);
  return month;
}

// expects date in M or MM-D or DD - YY or CCYY
// will strip out hyphens and add leading zeros in day if needed
function parseDay(dateString) {  
  day = dateString.substring (dateString.indexOf ("-")+1, dateString.lastIndexOf ("-"));
  day = formatLeadingZero(day);
  return day;
}

// expects date in M or MM-D or DD - YY or CCYY
// will strip out hyphens
function parseYear(dateString) {  
  year = dateString.substring (dateString.lastIndexOf ("-")+1, dateString.length);
  return year;
}

// compare dates, returns 1, -1 or 0
// expecting date in mm-dd-ccyy or mm-dd-yy
function compareDates (value1, value2) {
  var date1, date2;
  var month1, month2;
  var year1, year2;

  month1 = value1.substring (0, value1.indexOf ("-"));
  date1 = value1.substring (value1.indexOf ("-")+1, value1.lastIndexOf ("-"));
  year1 = value1.substring (value1.lastIndexOf ("-")+1, value1.length);

  month2 = value2.substring (0, value2.indexOf ("-"));
  date2 = value2.substring (value2.indexOf ("-")+1, value2.lastIndexOf ("-"));
  year2 = value2.substring (value2.lastIndexOf ("-")+1, value2.length);

  if (year1 > year2) return 1;
  else if (year1 < year2) return -1;
  else if (month1 > month2) return 1;
  else if (month1 < month2) return -1;
  else if (date1 > date2) return 1;
  else if (date1 < date2) return -1;
  else return 0;
}

   
// returns the number of days when comparing today, and a 
// submitted year, month and day
function daysBetween(yr, mo, dy) {
  
  // millisecond values
  var second = 1000; // a second
  var minute = second * 60; // a minute
  var hour = minute * 60; // an hour
  var day = hour * 24; // a day
  var week = day * 7; // a week

  var nDate = new Date(); // current date (local)
  var nTime = nDate.getTime(); // current time (UTC)
  var dTime = Date.UTC(yr, mo - 1, dy); // specified time (UTC)
  var bTime = Math.abs(nTime - dTime)  // time difference
  
  // if submitted date is in the past, add minus sign
  if (nTime > dTime) {
    return "-" + Math.round(bTime / day);
  } else {
    return Math.round(bTime / day);
  }
}


//check for valid year
function validateDateNotNowOrFuture (mStr, dStr, yStr) {

  // get today in proper format
  var d = new Date();
  var mon = d.getMonth() + 1;
  mon = formatLeadingZero(mon.toString());
  var day = d.getDate();
  day = formatLeadingZero(day.toString());
  var year = d.getFullYear();
  var today = mon + day + year;
  
  // passed in date
  var enteredDate = mStr + "/" +  dStr + "/" + yStr;
  var enteredDate = strip("-./_\n\r\t\\",enteredDate);
  
  // if not an int, toss
  if (isInteger(enteredDate)== false) {
    return false;
  }
  
  // if date entered is today or sometime in the future, return false
  if ( (compareDates(today, enteredDate) == 0) ||  
       (compareDates(today, enteredDate) == -1) ) { 
     return false;
  } 
  return true
}  


// better integer check 
function isInteger(str) {
  var isInt = true;
  inputStr = str.toString(); // in case not a string already
  for (var i = 0; i < str.length; i++) {
    var oneChar = str.charAt(i);
    if (oneChar < "0" || oneChar > "9") {
      isInt = false;
      i = str.length; // break out of loop when bad char found
    }
  } 
  return isInt;
}

// check for Leap Year
function isLeapYear(yr) {
  // classic leap year calculation - if the year is:
  // evenly divisible by 4 and not evenly divisible by 100
  // or evenly divisible by 400, then it is a leap year, otherwise not

  if ( ((yr % 4 == 0) && (yr % 100 != 0)) || (yr % 400 == 0) ) {
     return true;
  } 
  else { 
    return false;
  }
} 

//check for valid inquiry Date (3 years in past, any future date)
function validateInquiryDate(str) {
  
  // if not an int, toss
  if (isInteger(str)== false) {
    return false;
  }
  // if an int, check if date is not older than 3 years
  if (isInteger(str)== true) {
    var dt = new Date();
    var yr = dt.getFullYear(); 
    if (str < (yr - 3)) {
      return false;
    }
  }
  else { 
    return true; 
  }
}


// check if state abbreviation is a valid state
  var STATES = new Array("AL","AK","AS","AZ","AR","CA","CO","CT",
    "DE","DC","FM","FL","GA","GU","HI","ID","IL","IN","IA","KS",
    "KY","LA","ME","MH","MD","MA","MI","MN","MS","MO","MT","NE",
    "NV","NH","NJ","NM","NY","NC","ND","MP","OH","OK","OR","PW",
    "PA","PR","RI","SC","SD","TN","TX","UT","VT","VI","VA","WA",
    "WV","WI","WY","AE","AA","AE","AE","AE","AP");
   
  function validateStateAbbreviation(str) {  
    var st = str.toUpperCase();
    for (var i = 0; i < STATES.length; i++)
      if (STATES[i] == st) return true;
    return false;
  }


// check for valid Claim Number
function validateClaimNumber(str) {
  // check if integers
  if(isInteger(str)== false) {
    return false;
  } 
  // check if 11 numbers
  if(isInteger(str)== true) {
    if(str.length != 11) {
      return false;
    }
  }
}


// check for valid Claim Number
function validateRiderNumber(str) {
  // should be limited to 
  if(str.length > 6) {
    return false;
  }
}

//============= End Validation Rules ========================



//=============Begin Formatting functions ===================
    
// format day or month with leading zero if single digit
function formatLeadingZero(str) {
 if(str.length == 1 && str > 0 && str < 10) {
  str = 0 + str;
  return str;
 } else {
  return str;
 }
}

function formatPhone(str){
 str = strip("*() -./_\n\r\t\\",str);
 if(str.length==10)
  return reformat(str,"(",3,") ",3,"-",4);
 if(str.length==7)
  return reformat(str,"",3,"-",4);
}
function formatSSN(str){
 str = strip(" -.\n\r\t",str);
 // no dashes for IBM
 //return reformat(str,"",3,"-",2,"-",4);
 //return reformat(str,"",3,"-",2,"-",4);
 return str;
}
function formatZip(str){
 str = strip("- \n\r\t",str);
 if(str.length==5)
  return str;
 if(str.length==9)
  return reformat(str,"",5,"-",4);
}
function formatCC(str,type){
 str = strip("-./_\n\r\t\\",str);
 switch(type){
  case "1": 
   return reformat(str,"",4,"-",4,"-",4,"-",4);
   break;
  case "2": 
   return reformat(str,"",4,"-",4,"-",4,"-",4);
   break;
  case "3": 
   return reformat(str,"",4,"-",4,"-",4,"-",4);
   break;
  case "4":
   return reformat(str,"",4,"-",6,"-",5);
 }
}


function formatDate(str,style){
 var dateVar = new Date(str);
 var year = dateVar.getFullYear();
 if(year<10)
  year += 2000;
 if(year<100)
  year += 1900;
 switch(style){
  case "MM/DD/YY":
   return (dateVar.getMonth() + 1) + "/" + dateVar.getDate() + "/" + year;
   break;
  case "DD/MM/YY":
   return dateVar.getDate() + "/" + (dateVar.getMonth() + 1) + "/" + year;
   break;
  case "Month Day, Year":
   return getMonthName(dateVar) + " " + dateVar.getDate() + ", " + year;
   break;
  case "Day, Month Day, Year":
   return getDayName(dateVar) + ", " + getMonthName(dateVar) + " " + dateVar.getDate() + ", " + year;
   break;
  default:
   return (dateVar.getMonth() + 1) + "/" + dateVar.getDate() + "/" + year;
   break;
 }
}

// format 2 digit year
function formatYear(str) {
  str = strip("-./_\n\r\t\\",str);
  if (isInteger(str) == false) {
    return false;
  }
  if(str.length == 2) {
    if(str < 50 ) {
      str = "20" + str;
      return str;
    } 
    if(str >= 50 ) {
      str = "19" + str;
      return str;
    }  
  }
  else {
    return str;
  }
}
	function setReferralConfirmationFieldValues(searchAction, summaryAction)  
	{
		if (notEmpty(document.forms['ReferralConfirmationForm'].orderingProviderId.value))
		{
			document.forms['ReferralConfirmationForm'].providerID.value = document.forms['ReferralConfirmationForm'].orderingProviderId.value;
			document.forms['ReferralConfirmationForm'].action = summaryAction; 
		}
		else
		{
			document.forms[0].action = searchAction; 
		}
		return true;
	}

function validateReferralConfirmationForm(form) {
		if (notEmpty(form.orderingProviderId.value) == false) {
			alert("Please enter Ordering Provider ID.");
			formIn.orderingProviderId.focus();
			return false;  
		}
		return true;

}

function validatePatientForm(form) {
alert("in patient feedback validation java script.");
            if (notEmpty(form.providerBirthMonth.value) != false ||
                notEmpty(form.providerBirthDay.value) != false ||
                notEmpty(form.providerBirthYear.value) != false) {
                if (notEmpty(form.providerBirthMonth.value) == false ||
                    notEmpty(form.providerBirthDay.value) == false ||
                    notEmpty(form.providerBirthYear.value) == false) {
                    alert("Please enter all three date fields.");
                    if (notEmpty(form.providerBirthMonth.value) == false) {
                        form.providerBirthMonth.focus();
                        return false;
                    }
                    if (notEmpty(form.providerBirthDay.value) == false) {
                        form.providerBirthDay.focus();
                        return false;
                    }
                    if (notEmpty(form.providerBirthYear.value) == false) {
                        form.providerBirthYear.focus();
                        return false;
                    }
                }
            }
            if (notEmpty(form.providerBirthMonth.value) != false) {
                if (validateMonthFormat(form.providerBirthMonth.value) == false) {
                    alert("Please enter the MONTH of provider birth Date in proper format, between \"01 and 12\".");
                    form.providerBirthMonth.focus();
					return false;
                }
                form.providerBirthMonth.value = formatLeadingZero(form.providerBirthMonth.value);
            }
            if (notEmpty(form.providerBirthYear.value) != false) {
                if (validateYearFormat(form.providerBirthYear.value) == false) {
                    alert("Please enter the Year of provider birth Date in proper format \"CCYY\" and the century must be \"19\" or \"20\".");
                    form.providerBirthYear.focus();
					return false;
                }
                form.providerBirthYear.value = formatLeadingZero(form.providerBirthYear.value);
            }
            if (notEmpty(form.providerBirthDay.value) != false) {
                if (validateDayFormat(form.providerBirthMonth.value, form.providerBirthDay.value, form.providerBirthYear.value) == false) {
                    alert("Please enter the DAY of provider birth in proper format, between \"01 and 31\", depending on the month.");
                    form.providerBirthDay.focus();
					return false;	
                }
                form.providerBirthDay.value = formatLeadingZero(form.providerBirthDay.value);
            }
   
   return true;
}

function validateBenefitForm(form) {
            if (notEmpty(form.asOfDateMonth.value) != false ||
                notEmpty(form.asOfDateDay.value) != false ||
                notEmpty(form.asOfDateYear.value) != false) {
                if (notEmpty(form.asOfDateMonth.value) == false ||
                    notEmpty(form.asOfDateDay.value) == false ||
                    notEmpty(form.asOfDateYear.value) == false) {
                    alert("Please enter all three date fields.");
                    if (notEmpty(form.asOfDateMonth.value) == false) {
                        form.asOfDateMonth.focus();
                        return false;
                    }
                    if (notEmpty(form.asOfDateDay.value) == false) {
                        form.asOfDateDay.focus();
                        return false;
                    }
                    if (notEmpty(form.asOfDateYear.value) == false) {
                        form.asOfDateYear.focus();
                        return false;
                    }
                }
            }
            if (notEmpty(form.asOfDateMonth.value) != false) {
                if (validateMonthFormat(form.asOfDateMonth.value) == false) {
                    alert("Please enter the MONTH of As of Date in proper format, between \"01 and 12\".");
                    form.asOfDateMonth.focus();
					return false;
                }
                form.asOfDateMonth.value = formatLeadingZero(form.asOfDateMonth.value);
            }
            if (notEmpty(form.asOfDateYear.value) != false) {
                if (validateYearFormat(form.asOfDateYear.value) == false) {
                    alert("Please enter the Year of As of Date in proper format \"CCYY\" and the century must be \"19\" or \"20\".");
                    form.asOfDateYear.focus();
					return false;
                }
                form.asOfDateYear.value = formatLeadingZero(form.asOfDateYear.value);
            }
            if (notEmpty(form.asOfDateDay.value) != false) {
                if (validateDayFormat(form.asOfDateMonth.value, form.asOfDateDay.value, form.asOfDateYear.value) == false) {
                    alert("Please enter the DAY of As of Date in proper format, between \"01 and 31\", depending on the month.");
                    form.asOfDateDay.focus();
					return false;	
                }
                form.asOfDateDay.value = formatLeadingZero(form.asOfDateDay.value);
            }
   
   return true;
}




function validateMemberSearchform(form) {
    form.memberId.value = formatSSN(form.memberId.value);
    if (notEmpty(form.memberId.value) == false) {
        if (notEmpty(form.memberNameLast.value) == false) {
            alert("Either the \"Member ID\" by itself, OR \"Last Name\" AND \"First Name\" OR \"Last Name\" AND \"Birth Date\" are required.");
            form.memberId.focus();
            return false;
            
        } else {
            if ((notEmpty(form.memberNameFirst.value) == false) &&
                (notEmpty(form.memberBirthMonth.value) == false ||
                notEmpty(form.memberBirthDay.value) == false ||
                notEmpty(form.memberBirthYear.value) == false)) 
                {
	                alert("When \"Last Name\" is filled, \"First Name\" AND/OR all \"Birth Date\" fields are also required.");
	                
	                form.memberNameFirst.focus();
					return false;
	                if (notEmpty(form.memberBirthMonth.value) != false ||
	                    notEmpty(form.memberBirthDay.value) != false ||
	                    notEmpty(form.memberBirthYear.value) != false) {
	                    
	                    if (notEmpty(form.memberBirthMonth.value) == false) {
	                        form.memberBirthMonth.focus();
	                        return false;
	                    }
	                    if (notEmpty(form.memberBirthDay.value) == false) {
	                        form.memberBirthDay.focus();
	                        return false;
	                    }
	                    if (notEmpty(form.memberBirthYear.value) == false) {
	                        form.memberBirthYear.focus();
	                        return false;
	                    }
	                }
	                form.memberNameFirst.focus();
					return false;
	            }
            if (notEmpty(form.memberBirthMonth.value) != false ||
                notEmpty(form.memberBirthDay.value) != false ||
                notEmpty(form.memberBirthYear.value) != false) {
                if (notEmpty(form.memberBirthMonth.value) == false ||
                    notEmpty(form.memberBirthDay.value) == false ||
                    notEmpty(form.memberBirthYear.value) == false) {
                    alert("Please enter all three date fields.");
                    if (notEmpty(form.memberBirthMonth.value) == false) {
                        form.memberBirthMonth.focus();
                        return false;
                    }
                    if (notEmpty(form.memberBirthDay.value) == false) {
                        form.memberBirthDay.focus();
                        return false;
                    }
                    if (notEmpty(form.memberBirthYear.value) == false) {
                        form.memberBirthYear.focus();
                        return false;
                    }
                }
            }
            if (notEmpty(form.memberBirthMonth.value) != false) {
                if (validateMonthFormat(form.memberBirthMonth.value) == false) {
                    alert("Please enter the MONTH of birth in proper format, between \"01 and 12\".");
                    form.memberBirthMonth.focus();
					return false;
                }
                form.memberBirthMonth.value = formatLeadingZero(form.memberBirthMonth.value);
            }
            if (notEmpty(form.memberBirthYear.value) != false) {
                if (validateYearFormat(form.memberBirthYear.value) == false) {
                    alert("Please enter the Year of birth in proper format \"CCYY\" and the century must be \"19\" or \"20\".");
                    form.memberBirthYear.focus();
					return false;
                }
                form.memberBirthYear.value = formatLeadingZero(form.memberBirthYear.value);
            }
            if (notEmpty(form.memberBirthDay.value) != false) {
                if (validateDayFormat(form.memberBirthMonth.value, form.memberBirthDay.value, form.memberBirthYear.value) == false) {
                    alert("Please enter the DAY of birth in proper format, between \"01 and 31\", depending on the month.");
                    form.memberBirthDay.focus();
					return false;	
                }
                form.memberBirthDay.value = formatLeadingZero(form.memberBirthDay.value);
            }
            if (notEmpty(form.memberBirthMonth.value) == true ||
                notEmpty(form.memberBirthDay.value) == true ||
                notEmpty(form.memberBirthYear.value) == true) {
                birthDateObj = new Date(form.memberBirthYear.value, form.memberBirthMonth.value - 1, form.memberBirthDay.value);
                today = new Date;
                currentYear = today.getFullYear();
                currentMonth = today.getMonth();
                currentDay = today.getDate();
                currentDate = new Date(currentYear, currentMonth, currentDay);
                if (birthDateObj >= currentDate) {
                    alert("\"Birth Date\" cannot be today or in the future.");
                    form.memberBirthMonth.focus();
					return false;
                }
            }
        }
        if ((form.utSearch.checked == false)
        && (form.waSearch.checked == false)
        && (form.idSearch.checked == false)
        && (form.orSearch.checked == false))
        {
        	alert("Atleast one affiliate must be selected");
        	return false;
        }
    } else {
        if (validateSSN(form.memberId.value) == false) {
            alert("The \"Member ID\" entered is not in a valid format or is greater than 9 digits.");
            form.memberId.focus();
			return false;
        }
        if ((form.utSearch.checked == false)
        && (form.waSearch.checked == false)
        && (form.idSearch.checked == false)
        && (form.orSearch.checked == false))
        {
        	alert("Atleast one affiliate must be selected");
        	return false;
        }
    }
   
   return true;
}

function isUtahChecked() {
	alert("In UtahChecked");
	alert(form.utSearch.checked);
    return form.utSearch.checked;
}

