var DateOK;
var myFieldName;
var myMonthName;
var d=new Date();
var monthname=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");

/* Here's the list of tokens we support:
   m (or M) : month number, one or two digits.
   mm (or MM) : month number, strictly two digits (i.e. April is 04).
   d (or D) : day number, one or two digits.
   dd (or DD) : day number, strictly two digits.
   y (or Y) : year, two or four digits.
   yy (or YY) : year, strictly two digits.
   yyyy (or YYYY) : year, strictly four digits.
   mon : abbreviated month name (April is apr, Apr, APR, etc.)
   Mon : abbreviated month name, mixed-case (i.e. April is Apr only).
   MON : abbreviated month name, all upper-case (i.e. April is APR only).
   mon_strict : abbreviated month name, all lower-case (i.e. April is apr 
         only).
   month : full month name (April is april, April, APRIL, etc.)
   Month : full month name, mixed-case (i.e. April only).
   MONTH: full month name, all upper-case (i.e. APRIL only).
   month_strict : full month name, all lower-case (i.e. april only).
   h (or H) : hour, one or two digits.
   hh (or HH) : hour, strictly two digits.
   min (or MIN): minutes, one or two digits.
   mins (or MINS) : minutes, strictly two digits.
   s (or S) : seconds, one or two digits.
   ss (or SS) : seconds, strictly two digits.
   ampm (or AMPM) : am/pm setting.  Valid values to match this token are
         am, pm, AM, PM, a.m., p.m., A.M., P.M.
*/
// Be careful with this pattern.  Longer tokens should be placed before shorter
// tokens to disambiguate them.  For example, parsing "mon_strict" should 
// result in one token "mon_strict" and not two tokens "mon" and a literal
// "_strict".

var tokPat=new RegExp("^month_strict|month|Month|MONTH|yyyy|YYYY|mins|MINS|mon_strict|ampm|AMPM|mon|Mon|MON|min|MIN|dd|DD|mm|MM|yy|YY|hh|HH|ss|SS|m|M|d|D|y|Y|h|H|s|S");

// lowerMonArr is used to map months to their numeric values.

var lowerMonArr={jan:1, feb:2, mar:3, apr:4, may:5, jun:6, jul:7, aug:8, sep:9, oct:10, nov:11, dec:12}

// monPatArr contains regular expressions used for matching abbreviated months
// in a date string.

var monPatArr=new Array();
monPatArr['mon_strict']=new RegExp("jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec");
monPatArr['Mon']=new RegExp("Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec");
monPatArr['MON']=new RegExp("JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC");
monPatArr['mon']=new RegExp("jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec",'i');

// monthPatArr contains regular expressions used for matching full months
// in a date string.

var monthPatArr=new Array();
monthPatArr['month']=new RegExp("january|february|march|april|may|june|july|august|september|october|november|december",'i');
monthPatArr['Month']=new RegExp("January|February|March|April|May|June|July|August|September|October|November|December");
monthPatArr['MONTH']=new RegExp("JANUARY|FEBRUARY|MARCH|APRIL|MAY|JUNE|JULY|AUGUST|SEPTEMBER|OCTOBER|NOVEMBER|DECEMBER");
monthPatArr['month_strict']=new RegExp("january|february|march|april|may|june|july|august|september|october|november|december");

// cutoffYear is the cut-off for assigning "19" or "20" as century.  Any
// two-digit year >= cutoffYear will get a century of "19", and everything
// else gets a century of "20".

var cutoffYear=50;

// FormatToken is a datatype we use for storing extracted tokens from the
// format string.

function FormatToken (token, type) {
this.token=token;
this.type=type;
}

function parseFormatString (formatStr) {
var tokArr=new Array;
var tokInd=0;
var strInd=0;
var foundTok=0;
    
while (strInd < formatStr.length) {
if (formatStr.charAt(strInd)=="%" &&
(matchArray=formatStr.substr(strInd+1).match(tokPat)) != null) {
strInd+=matchArray[0].length+1;
tokArr[tokInd++]=new FormatToken(matchArray[0],"symbolic");
} else {

// No token matched current position, so current character should 
// be saved as a required literal.

if (tokInd>0 && tokArr[tokInd-1].type=="literal") {

// Literal tokens can be combined.Just add to the last token.

tokArr[tokInd-1].token+=formatStr.charAt(strInd++);
}
else {
tokArr[tokInd++]=new FormatToken(formatStr.charAt(strInd++), "literal");
      }
   }
}
return tokArr;
}

/* buildDate does all the real work.It takes a date string and format string,
 tries to match the two up, and returns a Date object (with the supplied date
 string value).If a date string doesn't contain all the fields that a Date
 object contains (for example, a date string with just the month), all
 unprovided fields are defaulted to those characteristics of the current
 date. Time fields that aren't provided default to 0.Thus, a date string
 like "3/30/2000" in "%mm/%dd/%yyyy" format results in a Date object for that
 date at midnight.formatStr is a free-form string that indicates special
 tokens via the % character.Here are some examples that will return a Date
 object:

 buildDate('3/30/2000','%mm/%dd/%y') // March 30, 2000
 buildDate('March 30, 2000','%Mon %d, %y') // Same as above.
 buildDate('Here is the date: 30-3-00','Here is the date: %dd-%m-%yy')

 If the format string does not match the string provided, an error message
 (i.e. String object) is returned.Thus, to see if buildDate succeeded, the
 caller can use the "typeof" command on the return value.For example,
 here's the dateCheck function, which returns true if a given date is
 valid,and false otherwise (and reports an error in the false case):

 function dateCheck(dateStr,formatStr) {
 var myObj=buildDate(dateStr,formatStr);
 if (typeof myObj=="object") {
 // We got a Date object, so good.
 return true;
 } else {
 // We got an error string.
 alert(myObj);
 return false;
 }
 }

*/

function buildDate(dateStr,formatStr) {
// parse the format string first.
var tokArr=parseFormatString(formatStr);
var strInd=0;
var tokInd=0;
var intMonth;
var intDay;
var intYear;
var intHour;
var intMin;
var intSec;
var ampm="";
var strOffset;

// Create a date object with the current date so that if the user only
// gives a month or day string, we can still return a valid date.

var curdate=new Date();
intMonth=curdate.getMonth()+1;
intDay=curdate.getDate();
intYear=curdate.getFullYear();

// Default time to midnight, so that if given just date info, we return
// a Date object for that date at midnight.

intHour=0;
intMin=0;
intSec=0;

// Walk across dateStr, matching the parsed formatStr until we find a 
// mismatch or succeed.

while (strInd < dateStr.length && tokInd < tokArr.length) {

// Start with the easy case of matching a literal.

if (tokArr[tokInd].type=="literal") {
if (dateStr.indexOf(tokArr[tokInd].token,strInd)==strInd) {

// The current position in the string does match the format 
// pattern.

strInd+=tokArr[tokInd++].token.length;
continue;
}
else {

// ACK! There was a mismatch; return error.

return "\"" + dateStr + "\" does not conform to the expected format: " + formatStr;
   }
}

// If we get here, we're matching to a symbolic token.
switch (tokArr[tokInd].token) {
case 'm':
case 'M':
case 'd':
case 'D':
case 'h':
case 'H':
case 'min':
case 'MIN':
case 's':
case 'S':

// Extract one or two characters from the date-time string and if 
// it's a number, save it as the month, day, hour, or minute, as
// appropriate.

curChar=dateStr.charAt(strInd);
nextChar=dateStr.charAt(strInd+1);
matchArr=dateStr.substr(strInd).match(/^\d{1,2}/);
if (matchArr==null) {

// First character isn't a number; there's a mismatch between
// the pattern and date string, so return error.

switch (tokArr[tokInd].token.toLowerCase()) {
case 'd': var unit="day"; break;
case 'm': var unit="month"; break;
case 'h': var unit="hour"; break;
case 'min': var unit="minute"; break;
case 's': var unit="second"; break;
}
return "Bad " + unit + " \"" + curChar + "\" or \"" + curChar +
nextChar + "\".";
}
strOffset=matchArr[0].length;
switch (tokArr[tokInd].token.toLowerCase()) {
case 'd': intDay=parseInt(matchArr[0],10); break;
case 'm': intMonth=parseInt(matchArr[0],10); break;
case 'h': intHour=parseInt(matchArr[0],10); break;
case 'min': intMin=parseInt(matchArr[0],10); break;
case 's': intSec=parseInt(matchArr[0],10); break;
}
break;
case 'mm':
case 'MM':
case 'dd':
case 'DD':
case 'hh':
case 'HH':
case 'mins':
case 'MINS':
case 'ss':
case 'SS':

// Extract two characters from the date string and if it's a 
// number, save it as the month, day, or hour, as appropriate.

strOffset=2;
matchArr=dateStr.substr(strInd).match(/^\d{2}/);
if (matchArr==null) {

// The two characters aren't a number; there's a mismatch 
// between the pattern and date string, so return an error
// message.

switch (tokArr[tokInd].token.toLowerCase()) {
case 'dd': var unit="day"; break;
case 'mm': var unit="month"; break;
case 'hh': var unit="hour"; break;
case 'mins': var unit="minute"; break;
case 'ss': var unit="second"; break;
}
return "Bad " + unit + " \"" + dateStr.substr(strInd,2) + 
"\".";
}
switch (tokArr[tokInd].token.toLowerCase()) {
case 'dd': intDay=parseInt(matchArr[0],10); break;
case 'mm': intMonth=parseInt(matchArr[0],10); break;
case 'hh': intHour=parseInt(matchArr[0],10); break;
case 'mins': intMin=parseInt(matchArr[0],10); break;
case 'ss': intSec=parseInt(matchArr[0],10); break;
}
break;
case 'y':
case 'Y':

// Extract two or four characters from the date string and if it's
// a number, save it as the year.Convert two-digit years to four
// digit years by assigning a century of '19' if the year is >= 
// cutoffYear, and '20' otherwise.

if (dateStr.substr(strInd,4).search(/\d{4}/) != -1) {

// Four digit year.

intYear=parseInt(dateStr.substr(strInd,4),10);
strOffset=4;
}
else {
if (dateStr.substr(strInd,2).search(/\d{2}/) != -1) {

// Two digit year.

intYear=parseInt(dateStr.substr(strInd,2),10);
if (intYear>=cutoffYear) {
intYear+=1900;
}
else {
intYear+=2000;
}
strOffset=2;
}
else {

// Bad year; return error.

return "Bad year \"" + dateStr.substr(strInd,2) + 
"\". Must be two or four digits.";
   }
}
break;
case 'yy':
case 'YY':

// Extract two characters from the date string and if it's a 
// number, save it as the year.Convert two-digit years to four 
// digit years by assigning a century of '19' if the year is >= 
// cutoffYear, and '20' otherwise.

if (dateStr.substr(strInd,2).search(/\d{2}/) != -1) {

// Two digit year.

intYear=parseInt(dateStr.substr(strInd,2),10);
if (intYear>=cutoffYear) {
intYear+=1900;
}
else {
intYear+=2000;
}
strOffset=2;
} else {
// Bad year; return error
return "Bad year \"" + dateStr.substr(strInd,2) + 
"\". Must be two digits.";
}
break;
case 'yyyy':
case 'YYYY':

// Extract four characters from the date string and if it's a 
// number, save it as the year.

if (dateStr.substr(strInd,4).search(/\d{4}/) != -1) {

// Four digit year.

intYear=parseInt(dateStr.substr(strInd,4),10);
strOffset=4;
}
else {

// Bad year; return error.

return "Bad year \"" + dateStr.substr(strInd,4) + 
"\". Must be four digits.";
}
break;
case 'mon':
case 'Mon':
case 'MON':
case 'mon_strict':

// Extract three characters from dateStr and parse them as 
// lower-case, mixed-case, or upper-case abbreviated months,
// as appropriate.

monPat=monPatArr[tokArr[tokInd].token];
if (dateStr.substr(strInd,3).search(monPat) != -1) {
intMonth=lowerMonArr[dateStr.substr(strInd,3).toLowerCase()];
}
else {

// Bad month, return error.

switch (tokArr[tokInd].token) {
case 'mon_strict': caseStat="lower-case"; break;
case 'Mon': caseStat="mixed-case"; break;
case 'MON': caseStat="upper-case"; break;
case 'mon': caseStat="between Jan and Dec"; break;
}
return "Bad month \"" + dateStr.substr(strInd,3) + 
"\". Must be " + caseStat + ".";
}
strOffset=3;
break;
case 'month':
case 'Month':
case 'MONTH':
case 'month_strict':

// Extract a full month name at strInd from dateStr if possible.

monPat=monthPatArr[tokArr[tokInd].token];
matchArray=dateStr.substr(strInd).match(monPat);
if (matchArray==null) {

// Bad month, return error.

return "Can't find a month beginning at \"" +
dateStr.substr(strInd) + "\".";
}

// It's a good month.

intMonth=lowerMonArr[matchArray[0].substr(0,3).toLowerCase()];
strOffset=matchArray[0].length;
break;
case 'ampm':
case 'AMPM':
matchArr=dateStr.substr(strInd).match(/^(am|pm|AM|PM|a\.m\.|p\.m\.|A\.M\.|P\.M\.)/);
if (matchArr==null) {

// There's no am/pm in the string.Return error msg.

return "Missing am/pm designation.";
}

// Store am/pm value for later (as just am or pm, to make things
// easier later).

if (matchArr[0].substr(0,1).toLowerCase() == "a") {

// This is am.

ampm = "am";
}
else {
ampm = "pm";
}
strOffset = matchArr[0].length;
break;
}
strInd += strOffset;
tokInd++;
}
if (tokInd != tokArr.length || strInd != dateStr.length) {

/* We got through the whole date string or format string, but there's 
 more data in the other, so there's a mismatch. */

return "\"" + dateStr + "\" is either missing desired information or has more information than the expected format: " + formatStr;
}

// Make sure all components are in the right ranges.

if (intMonth < 1 || intMonth > 12) {
return "Month must be between 1 and 12.";
}
if (intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11){
	if (intDay < 1 || intDay > 30) {
		return myFieldName + " Invalid Date - The Day field must be between 01 and 30.";
	}
}
if (intMonth != 2 && intMonth != 4 && intMonth != 6 && intMonth != 9 && intMonth != 11){
	if (intDay < 1 || intDay > 31) {
		return myFieldName + " Invalid Date - The Day field must be between 01 and 31.";
	}
}
var isleap=(intYear%4==0 && (intYear%100!=0 || intYear%400==0));
if (intMonth == 2){
	if ((intDay < 1 && !isleap) || (intDay > 28 && !isleap)) {
		return myFieldName + " Invalid Date - The Day field must be between 01 and 28.";
	}
	if ((intDay < 1 && isleap) || (intDay > 29 && isleap)) {
		return myFieldName + " Invalid Date - The Day field must be between 01 and 29.";
	}
}
// Make sure user doesn't put 31 for a month that only has 30 days

if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && intDay == 31) {
if (intMonth == 4){
	myMonthName = 'April';
}
if (intMonth == 6){
	myMonthName = 'June';
}
if (intMonth == 9){
	myMonthName = 'September';
}
if (intMonth == 11){
	myMonthName = 'November';
}
return myFieldName + " Invalid Date - "+myMonthName+" does not have 31 days!";
}

// Check for February date validity (including leap years) 

if (intMonth == 2) {

// figure out if "year" is a leap year; don't forget that
// century years are only leap years if divisible by 400

if (intDay > 29 || (intDay == 29 && !isleap)) {
return myFieldName + " Invalid Date - February " + intYear + " does not have " + intDay + 
" days!";
   }
}

// Check that if am/pm is not provided, hours are between 0 and 23.

if (ampm == "") {
if (intHour < 0 || intHour > 23) {
return "Hour must be between 0 and 23 for military time.";
   }
}
else {

// non-military time, so make sure it's between 1 and 12.

if (intHour < 1|| intHour > 12) {
return "Hour must be between 1 and 12 for standard time.";
   }
}

// If user specified amor pm, convert intHour to military.

if (ampm=="am" && intHour==12) {
intHour=0;
}
if (ampm=="pm" && intHour < 12) {
intHour += 12;
}
if (intMin < 0 || intMin > 59) {
return "Minute must be between 0 and 59.";
}
if (intSec < 0 || intSec > 59) {
return "Second must be between 0 and 59.";
}
return new Date(intYear,intMonth-1,intDay,intHour,intMin,intSec);
}
function dateCheck(dateStr,formatStr) {
var myObj = buildDate(dateStr,formatStr);
if (typeof myObj == "object") {

// We got a Date object, so good.

return true;
}
else {

// We got an error string.

alert(myObj);
DateOK = "No";
//alert(DateOK);
return false;
   }
}

function validForm(theForm){

var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
var valid2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
var valid3 = "0123456789";
var valid4 = "MF";
var valid5 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
var valid6 = "-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
var valid7 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$?.' ";
var valid8 = "-ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$?.' ";
var valid9 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789$?.' ";
var valid10 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
var invalid1 = "~";
var ok = "yes";
var temp;
var tempprev;
var now = new Date;
var mytempMonth;

var month = now.getMonth();
var day = now.getDate();

var year = now.getFullYear();
var today = new Date(year,month,day);

var myDate;
var myMonth;
var myDay;

var year110 = year - 110;
var month110 = now.getMonth();
var day110 = now.getDate();
var now110 = new Date(year110,month110,day110);

//Passport Number - fPassportNumber
  if (document.DS156.fPassportNumber.value.length > 0){
    while(''+document.DS156.fPassportNumber.value.charAt(0)==' ')document.DS156.fPassportNumber.value=document.DS156.fPassportNumber.value.substring(1,document.DS156.fPassportNumber.value.length);	
	while(''+document.DS156.fPassportNumber.value.charAt(document.DS156.fPassportNumber.value.length-1)==' ')document.DS156.fPassportNumber.value=document.DS156.fPassportNumber.value.substring(0,document.DS156.fPassportNumber.value.length-1); 	
	for (var i=0; i<document.DS156.fPassportNumber.value.length; i++) {
  	temp = "" + document.DS156.fPassportNumber.value.substring(i, i+1);
  	if (valid.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 1) Invalid Entry - The Passport Number field can only contain alphanumeric characters with no spaces or commas.");
   	document.DS156.fPassportNumber.focus();
	return (false);	
  	}
  }

//Passport Issued City - fPassportPlacea
  if (document.DS156.fPassportPlacea.value.length > 0){
  	for (var i=0; i<document.DS156.fPassportPlacea.value.length; i++) {
  	temp = "" + document.DS156.fPassportPlacea.value.substring(i, i+1);
  	if (valid9.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 2) Invalid Entry - The City field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, and space.");
   	document.DS156.fPassportPlacea.focus();
	return (false);	
  	}
  } 
  
//Passport Issued Country - fPassportPlaceb

//Passport Issued State - fPassportPlacec
  if (document.DS156.fPassportPlacec.value.length > 0){
  	for (var i=0; i<document.DS156.fPassportPlacec.value.length; i++) {
  	temp = "" + document.DS156.fPassportPlacec.value.substring(i, i+1);
  	if (valid9.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 2) Invalid Entry - The State/Province field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, and space.");
   	document.DS156.fPassportPlacec.focus();
	return (false);	
  	}
  } 

//Issuing Country - fIssuingCountry

//Passport Issuance Day - fPassportIssue_day, fPassportIssue_month, and fPassportIssue_year  
mytempMonth = document.DS156.fPassportIssue_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fPassportIssue_day.value != "" || mytempMonth != "" || document.DS156.fPassportIssue_year.value != ""){
  if (document.DS156.fPassportIssue_day.value.length > 0){
  	for (var i=0; i<document.DS156.fPassportIssue_day.value.length; i++) {
  	temp = "" + document.DS156.fPassportIssue_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 4) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fPassportIssue_day.focus();
	return (false);	
  	}
  } 
  if (document.DS156.fPassportIssue_year.value.length > 0){
  	for (var i=0; i<document.DS156.fPassportIssue_year.value.length; i++) {
  	temp = "" + document.DS156.fPassportIssue_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 4) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fPassportIssue_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fPassportIssue_day.value == ""){
    alert("(Item 4) Invalid Date - The Day field cannot be blank when the Month or Year fields contain information.");
    document.DS156.fPassportIssue_day.focus();
    return (false);
}
if (mytempMonth == ""){
    alert("(Item 4) Invalid Date - The Month field cannot be blank when the Day or Year fields contain information.");
    document.DS156.fPassportIssue_month.focus();
    return (false);
}
if (document.DS156.fPassportIssue_year.value == ""){
    alert("(Item 4) Invalid Date - The Year field cannot be blank when the Day or Month fields contain information.");
    document.DS156.fPassportIssue_year.focus();
    return (false);
}
if (document.DS156.fPassportIssue_year.value.length < 4){
    alert("(Item 4) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fPassportIssue_year.focus();
    return (false);
}
if (document.DS156.fPassportIssue_year.value.substring(0, 1) == "0"){
    alert("(Item 4) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fPassportIssue_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 4)';
dateCheck(document.DS156.fPassportIssue_day.value + document.DS156.fPassportIssue_month.value + document.DS156.fPassportIssue_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fPassportIssue_day.focus();
	return false;
}
if (document.DS156.fPassportIssue_month.value == "JAN"){
myMonth = 0
}

if (document.DS156.fPassportIssue_month.value == "FEB"){
myMonth = 1
}

if (document.DS156.fPassportIssue_month.value == "MAR"){
myMonth = 2
}

if (document.DS156.fPassportIssue_month.value == "APR"){
myMonth = 3
}

if (document.DS156.fPassportIssue_month.value == "MAY"){
myMonth = 4
}

if (document.DS156.fPassportIssue_month.value == "JUN"){
myMonth = 5
}

if (document.DS156.fPassportIssue_month.value == "JUL"){
myMonth = 6
}

if (document.DS156.fPassportIssue_month.value == "AUG"){
myMonth = 7
}

if (document.DS156.fPassportIssue_month.value == "SEP"){
myMonth = 8
}

if (document.DS156.fPassportIssue_month.value == "OCT"){
myMonth = 9
}

if (document.DS156.fPassportIssue_month.value == "NOV"){
myMonth = 10
}

if (document.DS156.fPassportIssue_month.value == "DEC"){
myMonth = 11
}
myDate = new Date(document.DS156.fPassportIssue_year.value,myMonth,document.DS156.fPassportIssue_day.value);
if (myDate.getTime() > today.getTime()){
	alert("(Item 4) Invalid Date - The Issuance Date field cannot be later than today.");
   	document.DS156.fPassportIssue_day.focus();
	return false;
}
}

//Passport Expiration Date - fPassportExpire_day, fPassportExpire_month, and fPassportExpire_year  
mytempMonth = document.DS156.fPassportExpire_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fPassportExpire_day.value != "" || mytempMonth != "" || document.DS156.fPassportExpire_year.value != ""){
  if (document.DS156.fPassportExpire_day.value.length > 0){
  	for (var i=0; i<document.DS156.fPassportExpire_day.value.length; i++) {
  	temp = "" + document.DS156.fPassportExpire_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 5) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fPassportExpire_day.focus();
	return (false);	
  	}
  } 
  if (document.DS156.fPassportExpire_year.value.length > 0){
  	for (var i=0; i<document.DS156.fPassportExpire_year.value.length; i++) {
  	temp = "" + document.DS156.fPassportExpire_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 5) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fPassportExpire_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fPassportExpire_day.value == ""){
    alert("(Item 5) Invalid Date - The Day field cannot be blank when the Month or Year fields contain information.");
    document.DS156.fPassportExpire_day.focus();
    return (false);
}
if (mytempMonth == ""){
    alert("(Item 5) Invalid Date - The Month field cannot be blank when the Day or Year fields contain information.");
    document.DS156.fPassportExpire_month.focus();
    return (false);
}
if (document.DS156.fPassportExpire_year.value == ""){
    alert("(Item 5) Invalid Date - The Year field cannot be blank when the Day or Month fields contain information.");
    document.DS156.fPassportExpire_year.focus();
    return (false);
}
if (document.DS156.fPassportExpire_year.value.length < 4){
    alert("(Item 5) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fPassportExpire_year.focus();
    return (false);
}
if (document.DS156.fPassportExpire_year.value.substring(0, 1) == "0"){
    alert("(Item 5) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fPassportExpire_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 5)';
dateCheck(document.DS156.fPassportExpire_day.value + document.DS156.fPassportExpire_month.value + document.DS156.fPassportExpire_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fPassportExpire_day.focus();
	return false;
}
if (document.DS156.fPassportExpire_month.value == "JAN"){
myMonth = 0
}

if (document.DS156.fPassportExpire_month.value == "FEB"){
myMonth = 1
}

if (document.DS156.fPassportExpire_month.value == "MAR"){
myMonth = 2
}

if (document.DS156.fPassportExpire_month.value == "APR"){
myMonth = 3
}

if (document.DS156.fPassportExpire_month.value == "MAY"){
myMonth = 4
}

if (document.DS156.fPassportExpire_month.value == "JUN"){
myMonth = 5
}

if (document.DS156.fPassportExpire_month.value == "JUL"){
myMonth = 6
}

if (document.DS156.fPassportExpire_month.value == "AUG"){
myMonth = 7
}

if (document.DS156.fPassportExpire_month.value == "SEP"){
myMonth = 8
}

if (document.DS156.fPassportExpire_month.value == "OCT"){
myMonth = 9
}

if (document.DS156.fPassportExpire_month.value == "NOV"){
myMonth = 10
}

if (document.DS156.fPassportExpire_month.value == "DEC"){
myMonth = 11
}
myDate = new Date(document.DS156.fPassportExpire_year.value,myMonth,document.DS156.fPassportExpire_day.value);
 //if (myDate.getTime() < today.getTime()){
	//alert("(Item 5) Invalid Date - The Expiration Date field cannot be earlier than today.");
  	//document.DS156.fPassportExpire_day.focus();
	//return false;
//}
}
//Surname - fSurname
  if (document.DS156.fSurname.value.length > 0){
  	while(''+document.DS156.fSurname.value.charAt(0)==' ')document.DS156.fSurname.value=document.DS156.fSurname.value.substring(1,document.DS156.fSurname.value.length);	
	while(''+document.DS156.fSurname.value.charAt(document.DS156.fSurname.value.length-1)==' ')document.DS156.fSurname.value=document.DS156.fSurname.value.substring(0,document.DS156.fSurname.value.length-1);
	for (var i=0; i<document.DS156.fSurname.value.length; i++) {
  	tempprev = temp
	temp = "" + document.DS156.fSurname.value.substring(i, i+1);
  	if (valid10.indexOf(temp) == "-1") ok = "no";
		if (temp == " "){
			if(temp == tempprev) ok = "no";
		}
  	}
	if (ok == "no") {
  	alert("(Item 6) Invalid Entry - The Surnames field can only contain characters A-Z and have no more than one space between names. No accents, symbols, or special characters are allowed.");
   	document.DS156.fSurname.focus();
	return (false);	
  	}
  }  

//Given Name - fGivenName  
  if (document.DS156.fGivenName.value.length > 0){
  	while(''+document.DS156.fGivenName.value.charAt(0)==' ')document.DS156.fGivenName.value=document.DS156.fGivenName.value.substring(1,document.DS156.fGivenName.value.length);	
	while(''+document.DS156.fGivenName.value.charAt(document.DS156.fGivenName.value.length-1)==' ')document.DS156.fGivenName.value=document.DS156.fGivenName.value.substring(0,document.DS156.fGivenName.value.length-1);
	for (var i=0; i<document.DS156.fGivenName.value.length; i++) {
  	tempprev = temp  	
	temp = "" + document.DS156.fGivenName.value.substring(i, i+1);
  	if (valid10.indexOf(temp) == "-1") ok = "no";
		if (temp == " "){
			if(temp == tempprev) ok = "no";
		}
	}
	if (ok == "no") {
  	alert("(Item 7) Invalid Entry - The First and Middle Names field can only contain characters A-Z and have no more than one space between names. No accents, symbols, or special characters are allowed.");
    document.DS156.fGivenName.focus();
	return (false);	
  	}
  } 

//Other Surname - fOtherSurname
  if (document.DS156.fOtherSurname.value.length > 0){
  	while(''+document.DS156.fOtherSurname.value.charAt(0)==' ')document.DS156.fOtherSurname.value=document.DS156.fOtherSurname.value.substring(1,document.DS156.fOtherSurname.value.length);	
	while(''+document.DS156.fOtherSurname.value.charAt(document.DS156.fOtherSurname.value.length-1)==' ')document.DS156.fOtherSurname.value=document.DS156.fOtherSurname.value.substring(0,document.DS156.fOtherSurname.value.length-1);  	
	for (var i=0; i<document.DS156.fOtherSurname.value.length; i++) {
  	tempprev = temp
  	temp = "" + document.DS156.fOtherSurname.value.substring(i, i+1);
  	if (valid10.indexOf(temp) == "-1") ok = "no";
		if (temp == " "){
			if(temp == tempprev) ok = "no";
		}
	}
	if (ok == "no") {
  	alert("(Item 8) Invalid Entry - The Other Surnames Used field can only contain characters A-Z and have no more than one space between names. No accents, symbols, or special characters are allowed.");
   	document.DS156.fOtherSurname.focus();
	return (false);	
  	}
  }  

//Other Given Name - fOtherGiven  
  if (document.DS156.fOtherGiven.value.length > 0){
  	while(''+document.DS156.fOtherGiven.value.charAt(0)==' ')document.DS156.fOtherGiven.value=document.DS156.fOtherGiven.value.substring(1,document.DS156.fOtherGiven.value.length);	
	while(''+document.DS156.fOtherGiven.value.charAt(document.DS156.fOtherGiven.value.length-1)==' ')document.DS156.fOtherGiven.value=document.DS156.fOtherGiven.value.substring(0,document.DS156.fOtherGiven.value.length-1); 	
	for (var i=0; i<document.DS156.fOtherGiven.value.length; i++) {
  	tempprev=temp	
	temp = "" + document.DS156.fOtherGiven.value.substring(i, i+1);
  	if (valid10.indexOf(temp) == "-1") ok = "no";
		if (temp == " "){
			if(temp == tempprev) ok = "no";
		}
	}
	if (ok == "no") {
  	alert("(Item 9) Invalid Entry - The Other First and Middles Names Used field can only contain characters A-Z and have no more than one space between names. No accents, symbols, or special characters are allowed.");
    document.DS156.fOtherGiven.focus();
	return (false);	
  	}
  } 

//Date of Birth - fDOB_day, fDOB_month, and fDOB_year  
mytempMonth = document.DS156.fDOB_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fDOB_day.value != "" || mytempMonth != "" || document.DS156.fDOB_year.value != ""){
if (document.DS156.fDOB_day.value != ""){
  if (document.DS156.fDOB_day.value.length > 0){
  	for (var i=0; i<document.DS156.fDOB_day.value.length; i++) {
  	temp = "" + document.DS156.fDOB_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 10) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fDOB_day.focus();
	return (false);	
  	}
  }
if (mytempMonth == ""){
    alert("(Item 10) Invalid Date - The Month field cannot be blank when the Day field contains information.");
    document.DS156.fDOB_month.focus();
    return (false);
}
}
  if (document.DS156.fDOB_year.value.length > 0){
  	for (var i=0; i<document.DS156.fDOB_year.value.length; i++) {
  	temp = "" + document.DS156.fDOB_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 10) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fDOB_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fDOB_year.value == ""){
    alert("(Item 10) Invalid Date - The Year field cannot be blank when the Month and/or Day fields contain information.");
    document.DS156.fDOB_year.focus();
    return (false);
}
if (document.DS156.fDOB_year.value.length < 4){
    alert("(Item 10) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fDOB_year.focus();
    return (false);
}
if (document.DS156.fDOB_year.value.substring(0, 1) == "0"){
    alert("(Item 10) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fDOB_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 10)';
if (document.DS156.fDOB_day.value != ""){
dateCheck(document.DS156.fDOB_day.value + document.DS156.fDOB_month.value + document.DS156.fDOB_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fDOB_day.focus();
	return false;
}
}
if (document.DS156.fDOB_month.value == "JAN"){
myMonth = 0
}

if (document.DS156.fDOB_month.value == "FEB"){
myMonth = 1
}

if (document.DS156.fDOB_month.value == "MAR"){
myMonth = 2
}

if (document.DS156.fDOB_month.value == "APR"){
myMonth = 3
}

if (document.DS156.fDOB_month.value == "MAY"){
myMonth = 4
}

if (document.DS156.fDOB_month.value == "JUN"){
myMonth = 5
}

if (document.DS156.fDOB_month.value == "JUL"){
myMonth = 6
}

if (document.DS156.fDOB_month.value == "AUG"){
myMonth = 7
}

if (document.DS156.fDOB_month.value == "SEP"){
myMonth = 8
}

if (document.DS156.fDOB_month.value == "OCT"){
myMonth = 9
}

if (document.DS156.fDOB_month.value == "NOV"){
myMonth = 10
}

if (document.DS156.fDOB_month.value == "DEC"){
myMonth = 11
}
if (document.DS156.fDOB_month.value == ""){
myMonth = 1
}
myDay = document.DS156.fDOB_day.value;
if (document.DS156.fDOB_day.value == ""){
myDay = 1
}
myDate = new Date(document.DS156.fDOB_year.value,myMonth,myDay);
if (myDate.getTime() > now.getTime()){
	alert("(Item 10) Invalid Date - The Date of Birth cannot be later than today.");
   	document.DS156.fDOB_day.focus();
	return false;
}
myDay = document.DS156.fDOB_day.value;
if (document.DS156.fDOB_month.value == "" || document.DS156.fDOB_month.value == " "){
myMonth = 1
myDay = 1
}
if (document.DS156.fDOB_day.value == "" && document.DS156.fDOB_month.value != " "){
myDay = 1
}
myDate = new Date(document.DS156.fDOB_year.value,myMonth,myDay);
if (myDate.getTime() < now110.getTime()){
	//alert("(Item 10) Invalid Date - The Date of Birth cannot be earlier than (" + day110 + "-" + monthname[d.getMonth()] + "-" + year110 + ").");
	if (day110 < 10){
		alert("(Item 10) Invalid Date - The Date of Birth cannot be earlier than (0" + day110 + "-" + monthname[d.getMonth(month110)] + "-" + year110 + ").");
    }
	if (day110 > 9){
		alert("(Item 10) Invalid Date - The Date of Birth cannot be earlier than (" + day110 + "-" + monthname[d.getMonth(month110)] + "-" + year110 + ").");
    }		
	document.DS156.fDOB_day.focus();
	return false;
}
}

//Place of Birth City - fPOBb
  if (document.DS156.fPOBb.value.length > 0){
  	for (var i=0; i<document.DS156.fPOBb.value.length; i++) {
  	temp = "" + document.DS156.fPOBb.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 11) Invalid Entry - The City field can only contain the following characters: A-Z, 0-9, $, ?, period, hyphen, apostrophe, and space.");
   	document.DS156.fPOBb.focus();
	return (false);	
  	}
  }

//Place of Birth Country - fPOBa
  
//Place of Birth State - fPOBc
  if (document.DS156.fPOBc.value.length > 0){
  	for (var i=0; i<document.DS156.fPOBc.value.length; i++) {
  	temp = "" + document.DS156.fPOBc.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 11) Invalid Entry - The State/Province field can only contain the following characters: A-Z, 0-9, $, ?, period, hyphen, apostrophe, and space.");
   	document.DS156.fPOBc.focus();
	return (false);	
  	}
  }

//Nationality - fNationality

//Gender - fGender

//National ID - fNatID
  if (document.DS156.fNatID.value.length > 0){
  	while(''+document.DS156.fNatID.value.charAt(0)==' ')document.DS156.fNatID.value=document.DS156.fNatID.value.substring(1,document.DS156.fNatID.value.length);	
	while(''+document.DS156.fNatID.value.charAt(document.DS156.fNatID.value.length-1)==' ')document.DS156.fNatID.value=document.DS156.fNatID.value.substring(0,document.DS156.fNatID.value.length-1); 	
	for (var i=0; i<document.DS156.fNatID.value.length; i++) {
  	temp = "" + document.DS156.fNatID.value.substring(i, i+1);
  	if (valid.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 14) Invalid Entry - The National Identification Number field can only contain alphanumeric characters with no spaces or commas.");
   	document.DS156.fNatID.focus();
	return (false);	
  	}
  }  

//Home Address Line 1 - fHomeAddressa
  if (document.DS156.fHomeAddressa.value.length > 0){
  	for (var i=0; i<document.DS156.fHomeAddressa.value.length; i++) {
  	temp = "" + document.DS156.fHomeAddressa.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 15) Invalid Entry - The Street Address Line 1 field can only contain the following characters: A-Z, 0-9, $, ?, period, hyphen, apostrophe, and space.");
   	document.DS156.fHomeAddressa.focus();
	return (false);	
  	}
  }

//Home Address Line 2 - fHomeAddressb
  if (document.DS156.fHomeAddressb.value.length > 0){
  	for (var i=0; i<document.DS156.fHomeAddressb.value.length; i++) {
  	temp = "" + document.DS156.fHomeAddressb.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 15) Invalid Entry - The Street Address Line 2 field can only contain the following characters: A-Z, 0-9, $, ?, period, hyphen, apostrophe, and space.");
   	document.DS156.fHomeAddressb.focus();
	return (false);	
  	}
  }

//Home Address City - fHomeAddressc
  if (document.DS156.fHomeAddressc.value.length > 0){
  	for (var i=0; i<document.DS156.fHomeAddressc.value.length; i++) {
  	temp = "" + document.DS156.fHomeAddressc.value.substring(i, i+1);
  	if (valid9.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 15) Invalid Entry - The City field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, and space.");
   	document.DS156.fHomeAddressc.focus();
	return (false);	
  	}
  }

//Home Address State - fHomeAddressd
  if (document.DS156.fHomeAddressd.value.length > 0){
  	for (var i=0; i<document.DS156.fHomeAddressd.value.length; i++) {
  	temp = "" + document.DS156.fHomeAddressd.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 15) Invalid Entry - The State/Province field can only contain the following characters: A-Z, 0-9, $, ?, period, hyphen, apostrophe, and space.");
   	document.DS156.fHomeAddressd.focus();
	return (false);	
  	}
  }
//Home Address postal code - fHomeAddressf 
  if (document.DS156.fHomeAddressf.value.length > 0){
  	for (var i=0; i<document.DS156.fHomeAddressf.value.length; i++) {
  	temp = "" + document.DS156.fHomeAddressf.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 15) Invalid Entry - The Postal Code field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fHomeAddressf.focus();
	return (false);	
  	}
  }  

//Home Address Country - fHomeAddresse

//Telephone (Home) - fPhoneHome
  if (document.DS156.fPhoneHome.value.length > 0){
  	for (var i=0; i<document.DS156.fPhoneHome.value.length; i++) {
  	temp = "" + document.DS156.fPhoneHome.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 16) Invalid Entry - The Home Telephone Number field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fPhoneHome.focus();
	return (false);	
  	}
  }
  
//Telephone (Work) - fPhoneWork
  if (document.DS156.fPhoneWork.value.length > 0){
  	for (var i=0; i<document.DS156.fPhoneWork.value.length; i++) {
  	temp = "" + document.DS156.fPhoneWork.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 16) Invalid Entry - The Business Phone Number field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fPhoneWork.focus();
	return (false);	
  	}
  }
  
//Telephone (Other) - fPhoneOther
  if (document.DS156.fPhoneOther.value.length > 0){
  	for (var i=0; i<document.DS156.fPhoneOther.value.length; i++) {
  	temp = "" + document.DS156.fPhoneOther.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 16) Invalid Entry - The Mobile/Cell Number field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fPhoneOther.focus();
	return (false);	
  	}
  }
  
//Fax Number - fPhoneOther4
  if (document.DS156.fPhoneOther4.value.length > 0){
  	for (var i=0; i<document.DS156.fPhoneOther4.value.length; i++) {
  	temp = "" + document.DS156.fPhoneOther4.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 16) Invalid Entry - The Fax Number field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fPhoneOther4.focus();
	return (false);	
  	}
  }   

//Business Fax - fPhoneOther3
  if (document.DS156.fPhoneOther3.value.length > 0){
  	for (var i=0; i<document.DS156.fPhoneOther3.value.length; i++) {
  	temp = "" + document.DS156.fPhoneOther3.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 16) Invalid Entry - The Business Fax Number field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fPhoneOther3.focus();
	return (false);	
  	}
  }
  
//Pager - fPhoneOther2
  if (document.DS156.fPhoneOther2.value.length > 0){
  	for (var i=0; i<document.DS156.fPhoneOther2.value.length; i++) {
  	temp = "" + document.DS156.fPhoneOther2.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 16) Invalid Entry - The Pager Number field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fPhoneOther2.focus();
	return (false);	
  	}
  }
 
//Spouse DOB - fSpouseDOB_day, fSpouseDOB_month, and fSpouseDOB_year  
mytempMonth = document.DS156.fSpouseDOB_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fSpouseDOB_day.value != "" || mytempMonth != "" || document.DS156.fSpouseDOB_year.value != ""){
if (document.DS156.fSpouseDOB_day.value != ""){
  if (document.DS156.fSpouseDOB_day.value.length > 0){
  	for (var i=0; i<document.DS156.fSpouseDOB_day.value.length; i++) {
  	temp = "" + document.DS156.fSpouseDOB_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 19) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fSpouseDOB_day.focus();
	return (false);	
  	}
  }
if (mytempMonth == ""){
    alert("(Item 19) Invalid Date - The Month field cannot be blank when the Day field contains information.");
    document.DS156.fSpouseDOB_month.focus();
    return (false);
}
}
  if (document.DS156.fSpouseDOB_year.value.length > 0){
  	for (var i=0; i<document.DS156.fSpouseDOB_year.value.length; i++) {
  	temp = "" + document.DS156.fSpouseDOB_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 19) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fSpouseDOB_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fSpouseDOB_year.value == ""){
    alert("(Item 19) Invalid Date - The Year field cannot be blank when the Month and/or Day fields contain information.");
    document.DS156.fSpouseDOB_year.focus();
    return (false);
}
if (document.DS156.fSpouseDOB_year.value.length < 4){
    alert("(Item 19) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fSpouseDOB_year.focus();
    return (false);
}
if (document.DS156.fSpouseDOB_year.value.substring(0, 1) == "0"){
    alert("(Item 19) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fSpouseDOB_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 19)';
if (document.DS156.fSpouseDOB_day.value != ""){
dateCheck(document.DS156.fSpouseDOB_day.value + document.DS156.fSpouseDOB_month.value + document.DS156.fSpouseDOB_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fSpouseDOB_day.focus();
	return false;
}
}
if (document.DS156.fSpouseDOB_month.value == "JAN"){
myMonth = 0
}

if (document.DS156.fSpouseDOB_month.value == "FEB"){
myMonth = 1
}

if (document.DS156.fSpouseDOB_month.value == "MAR"){
myMonth = 2
}

if (document.DS156.fSpouseDOB_month.value == "APR"){
myMonth = 3
}

if (document.DS156.fSpouseDOB_month.value == "MAY"){
myMonth = 4
}

if (document.DS156.fSpouseDOB_month.value == "JUN"){
myMonth = 5
}

if (document.DS156.fSpouseDOB_month.value == "JUL"){
myMonth = 6
}

if (document.DS156.fSpouseDOB_month.value == "AUG"){
myMonth = 7
}

if (document.DS156.fSpouseDOB_month.value == "SEP"){
myMonth = 8
}

if (document.DS156.fSpouseDOB_month.value == "OCT"){
myMonth = 9
}

if (document.DS156.fSpouseDOB_month.value == "NOV"){
myMonth = 10
}

if (document.DS156.fSpouseDOB_month.value == "DEC"){
myMonth = 11
}
if (document.DS156.fSpouseDOB_month.value == ""){
myMonth = 1
}
myDay = document.DS156.fSpouseDOB_day.value;
if (document.DS156.fSpouseDOB_day.value == ""){
myDay = 1
}
myDate = new Date(document.DS156.fSpouseDOB_year.value,myMonth,myDay);
if (myDate.getTime() > now.getTime()){
	alert("(Item 19) Invalid Date - The Spouse's DOB cannot be later than today.");
   	document.DS156.fSpouseDOB_day.focus();
	return false;
}
if (document.DS156.fSpouseDOB_month.value == ""){
myMonth = 1
}
myDay = document.DS156.fSpouseDOB_day.value;
if (document.DS156.fSpouseDOB_day.value == ""){
myDay = 1
}
myDate = new Date(document.DS156.fSpouseDOB_year.value,myMonth,myDay);
if (myDate.getTime() < now110.getTime()){
	//alert("(Item 19) Invalid Date - The Spouse's DOB cannot be older than 110 years from today.");
   	if (day110 < 10){
		alert("(Item 19) Invalid Date - The Spouse's DOB cannot be earlier than (0" + day110 + "-" + monthname[d.getMonth(month110)] + "-" + year110 + ").");
    }
	if (day110 > 9){
		alert("(Item 19) Invalid Date - The Spouse's DOB cannot be earlier than (" + day110 + "-" + monthname[d.getMonth(month110)] + "-" + year110 + ").");
    }	
	document.DS156.fSpouseDOB_day.focus();
	return false;
}
}
//Employer - fEmployer
  if (document.DS156.fEmployer.value.length > 0){
  	for (var i=0; i<document.DS156.fEmployer.value.length; i++) {
  	temp = "" + document.DS156.fEmployer.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 20) Invalid Entry - The Name field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fEmployer.focus();
	return (false);	
  	}
  }

//Occupation - fOccupation
  if (document.DS156.fOccupation.value.length > 0){
  	for (var i=0; i<document.DS156.fOccupation.value.length; i++) {
  	temp = "" + document.DS156.fOccupation.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 21) Invalid Entry - The Present Occupation field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fOccupation.focus();
	return (false);	
  	}
  }

//Arrival Date - fArrivalDate_day, fArrivalDate_month, and fArrivalDate_year  
mytempMonth = document.DS156.fArrivalDate_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fArrivalDate_day.value != "" || mytempMonth != "" || document.DS156.fArrivalDate_year.value != ""){
  if (document.DS156.fArrivalDate_day.value.length > 0){
  	for (var i=0; i<document.DS156.fArrivalDate_day.value.length; i++) {
  	temp = "" + document.DS156.fArrivalDate_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 22) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fArrivalDate_day.focus();
	return (false);	
  	}
  } 
  if (document.DS156.fArrivalDate_year.value.length > 0){
  	for (var i=0; i<document.DS156.fArrivalDate_year.value.length; i++) {
  	temp = "" + document.DS156.fArrivalDate_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 22) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fArrivalDate_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fArrivalDate_day.value == ""){
    alert("(Item 22) Invalid Date - The Day field cannot be blank when the Month or Year fields contain information.");
    document.DS156.fArrivalDate_day.focus();
    return (false);
}
if (mytempMonth == ""){
    alert("(Item 22) Invalid Date - The Month field cannot be blank when the Day or Year fields contain information.");
    document.DS156.fArrivalDate_month.focus();
    return (false);
}
if (document.DS156.fArrivalDate_year.value == ""){
    alert("(Item 22) Invalid Date - The Year field cannot be blank when the Day or Month fields contain information.");
    document.DS156.fArrivalDate_year.focus();
    return (false);
}
if (document.DS156.fArrivalDate_year.value.length < 4){
    alert("(Item 22) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fArrivalDate_year.focus();
    return (false);
}
if (document.DS156.fArrivalDate_year.value.substring(0, 1) == "0"){
    alert("(Item 22) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fArrivalDate_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 22)';
dateCheck(document.DS156.fArrivalDate_day.value + document.DS156.fArrivalDate_month.value + document.DS156.fArrivalDate_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fArrivalDate_day.focus();
	return false;
}
if (document.DS156.fArrivalDate_month.value == "JAN"){
myMonth = 0
}

if (document.DS156.fArrivalDate_month.value == "FEB"){
myMonth = 1
}

if (document.DS156.fArrivalDate_month.value == "MAR"){
myMonth = 2
}

if (document.DS156.fArrivalDate_month.value == "APR"){
myMonth = 3
}

if (document.DS156.fArrivalDate_month.value == "MAY"){
myMonth = 4
}

if (document.DS156.fArrivalDate_month.value == "JUN"){
myMonth = 5
}

if (document.DS156.fArrivalDate_month.value == "JUL"){
myMonth = 6
}

if (document.DS156.fArrivalDate_month.value == "AUG"){
myMonth = 7
}

if (document.DS156.fArrivalDate_month.value == "SEP"){
myMonth = 8
}

if (document.DS156.fArrivalDate_month.value == "OCT"){
myMonth = 9
}

if (document.DS156.fArrivalDate_month.value == "NOV"){
myMonth = 10
}

if (document.DS156.fArrivalDate_month.value == "DEC"){
myMonth = 11
}
myDate = new Date(document.DS156.fArrivalDate_year.value,myMonth,document.DS156.fArrivalDate_day.value);
if (myDate.getTime() < now.getTime()){
	alert("(Item 22) Invalid Date - This date cannot be today or earlier than today's date.");
	document.DS156.fArrivalDate_day.focus();
	return false;
    
}
}

//Email Address - fEmail
  if (document.DS156.fEmail.value.length > 0){
  	for (var i=0; i<document.DS156.fEmail.value.length; i++) {
  		temp = "" + document.DS156.fEmail.value.substring(i, i+1);
  		if (invalid1.indexOf(temp) != "-1") {
  			alert("(Item 23) Invalid Entry - The E-Mail Address field can only contain the following characters: A-Z, 0-9, and all special characters except the tilde (~).");
   			document.DS156.fEmail.focus();
			return (false);	
  		}	
	}
  }

//US Contact - fUSContactName
  if (document.DS156.fUSContactName.value.length > 0){
  	for (var i=0; i<document.DS156.fUSContactName.value.length; i++) {
  	temp = "" + document.DS156.fUSContactName.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 25) Invalid Entry - The Name field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fUSContactName.focus();
	return (false);	
  	}
  }         

//US Contact Home Phone - fUSContactHomePhone
  if (document.DS156.fUSContactHomePhone.value.length > 0){
  	for (var i=0; i<document.DS156.fUSContactHomePhone.value.length; i++) {
  	temp = "" + document.DS156.fUSContactHomePhone.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 25) Invalid Entry - The Home Phone field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fUSContactHomePhone.focus();
	return (false);	
  	}
  } 

//US Contact Work Phone - fUSContactWorkPhone
  if (document.DS156.fUSContactWorkPhone.value.length > 0){
  	for (var i=0; i<document.DS156.fUSContactWorkPhone.value.length; i++) {
  	temp = "" + document.DS156.fUSContactWorkPhone.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 25) Invalid Entry - The Business Phone field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fUSContactWorkPhone.focus();
	return (false);	
  	}
  }

//US Contact Cell Phone - fUSContactCellphone
  if (document.DS156.fUSContactCellphone.value.length > 0){
  	for (var i=0; i<document.DS156.fUSContactCellphone.value.length; i++) {
  	temp = "" + document.DS156.fUSContactCellphone.value.substring(i, i+1);
  	if (valid8.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 25) Invalid Entry - The Cell Phone field can only contain the following characters: A-Z, 0-9, $, ?, period, apostrophe, hyphen, and space.");
   	document.DS156.fUSContactCellphone.focus();
	return (false);	
  	}
  }

//Have you ever been in the US? - fwhenbeeninus_day, fwhenbeeninus_month, and fwhenbeeninus_year  
mytempMonth = document.DS156.fwhenbeeninus_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fwhenbeeninus_day.value != "" || mytempMonth != "" || document.DS156.fwhenbeeninus_year.value != ""){
  if (document.DS156.fwhenbeeninus_day.value.length > 0){
  	for (var i=0; i<document.DS156.fwhenbeeninus_day.value.length; i++) {
  	temp = "" + document.DS156.fwhenbeeninus_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 29) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fwhenbeeninus_day.focus();
	return (false);	
  	}
  } 
  if (document.DS156.fwhenbeeninus_year.value.length > 0){
  	for (var i=0; i<document.DS156.fwhenbeeninus_year.value.length; i++) {
  	temp = "" + document.DS156.fwhenbeeninus_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 29) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fwhenbeeninus_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fwhenbeeninus_day.value == ""){
    alert("(Item 29) Invalid Date - The Day field cannot be blank when the Month or Year fields contain information.");
    document.DS156.fwhenbeeninus_day.focus();
    return (false);
}
if (mytempMonth == ""){
    alert("(Item 29) Invalid Date - The Month field cannot be blank when the Day or Year fields contain information.");
    document.DS156.fwhenbeeninus_month.focus();
    return (false);
}
if (document.DS156.fwhenbeeninus_year.value == ""){
    alert("(Item 29) Invalid Date - The Year field cannot be blank when the Day or Month fields contain information.");
    document.DS156.fwhenbeeninus_year.focus();
    return (false);
}
if (document.DS156.fwhenbeeninus_year.value.length < 4){
    alert("(Item 29) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fwhenbeeninus_year.focus();
    return (false);
}
if (document.DS156.fwhenbeeninus_year.value.substring(0, 1) == "0"){
    alert("(Item 29) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fwhenbeeninus_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 29)';
dateCheck(document.DS156.fwhenbeeninus_day.value + document.DS156.fwhenbeeninus_month.value + document.DS156.fwhenbeeninus_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fwhenbeeninus_day.focus();
	return false;
}
}

//Previous Visa Date - fPrevVisaDate_day, fPrevVisaDate_month, and fPrevVisaDate_year  
mytempMonth = document.DS156.fPrevVisaDate_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fPrevVisaDate_day.value != "" || mytempMonth != "" || document.DS156.fPrevVisaDate_year.value != ""){
  if (document.DS156.fPrevVisaDate_day.value.length > 0){
  	for (var i=0; i<document.DS156.fPrevVisaDate_day.value.length; i++) {
  	temp = "" + document.DS156.fPrevVisaDate_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 30) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fPrevVisaDate_day.focus();
	return (false);	
  	}
  } 
  if (document.DS156.fPrevVisaDate_year.value.length > 0){
  	for (var i=0; i<document.DS156.fPrevVisaDate_year.value.length; i++) {
  	temp = "" + document.DS156.fPrevVisaDate_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 30) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fPrevVisaDate_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fPrevVisaDate_day.value == ""){
    alert("(Item 30) Invalid Date - The Day field cannot be blank when the Month or Year fields contain information.");
    document.DS156.fPrevVisaDate_day.focus();
    return (false);
}
if (mytempMonth == ""){
    alert("(Item 30) Invalid Date - The Month field cannot be blank when the Day or Year fields contain information.");
    document.DS156.fPrevVisaDate_month.focus();
    return (false);
}
if (document.DS156.fPrevVisaDate_year.value == ""){
    alert("(Item 30) Invalid Date - The Year field cannot be blank when the Day or Month fields contain information.");
    document.DS156.fPrevVisaDate_year.focus();
    return (false);
}
if (document.DS156.fPrevVisaDate_year.value.length < 4){
    alert("(Item 30) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fPrevVisaDate_year.focus();
    return (false);
}
if (document.DS156.fPrevVisaDate_year.value.substring(0, 1) == "0"){
    alert("(Item 30) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fPrevVisaDate_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 30)';
dateCheck(document.DS156.fPrevVisaDate_day.value + document.DS156.fPrevVisaDate_month.value + document.DS156.fPrevVisaDate_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fPrevVisaDate_day.focus();
	return false;
}
if (document.DS156.fPrevVisaDate_month.value == "JAN"){
myMonth = 0
}

if (document.DS156.fPrevVisaDate_month.value == "FEB"){
myMonth = 1
}

if (document.DS156.fPrevVisaDate_month.value == "MAR"){
myMonth = 2
}

if (document.DS156.fPrevVisaDate_month.value == "APR"){
myMonth = 3
}

if (document.DS156.fPrevVisaDate_month.value == "MAY"){
myMonth = 4
}

if (document.DS156.fPrevVisaDate_month.value == "JUN"){
myMonth = 5
}

if (document.DS156.fPrevVisaDate_month.value == "JUL"){
myMonth = 6
}

if (document.DS156.fPrevVisaDate_month.value == "AUG"){
myMonth = 7
}

if (document.DS156.fPrevVisaDate_month.value == "SEP"){
myMonth = 8
}

if (document.DS156.fPrevVisaDate_month.value == "OCT"){
myMonth = 9
}

if (document.DS156.fPrevVisaDate_month.value == "NOV"){
myMonth = 10
}

if (document.DS156.fPrevVisaDate_month.value == "DEC"){
myMonth = 11
}
myDate = new Date(document.DS156.fPrevVisaDate_year.value,myMonth,document.DS156.fPrevVisaDate_day.value);
if (myDate.getTime() >= today.getTime()){
	alert("(Item 30) Invalid Date - This date can not be today, or greater than today or less than this date 110 years ago: " + d.getDate() + "-" + monthname[d.getMonth()] + "-" + d.getFullYear());	
   	document.DS156.fPrevVisaDate_day.focus();	
	return false;
}
if (myDate.getTime() < now110.getTime()){
	alert("(Item 30) Invalid Date - This date can not be today, or greater than today or less than this date 110 years ago: " + d.getDate() + "-" + monthname[d.getMonth()] + "-" + d.getFullYear());
   	document.DS156.fPrevVisaDate_day.focus();
	return false;
}
}

//Have you ever been denied a visa? - fwhenvisadenial_day, fwhenvisadenial_month, and fwhenvisadenial_year  
mytempMonth = document.DS156.fwhenvisadenial_month.value
if (mytempMonth == " "){
	mytempMonth = "";
}
if (document.DS156.fwhenvisadenial_day.value != "" || mytempMonth != "" || document.DS156.fwhenvisadenial_year.value != ""){
  if (document.DS156.fwhenvisadenial_day.value.length > 0){
  	for (var i=0; i<document.DS156.fwhenvisadenial_day.value.length; i++) {
  	temp = "" + document.DS156.fwhenvisadenial_day.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 31) Invalid Entry - The Day field must be between 01 and 31.");
   	document.DS156.fwhenvisadenial_day.focus();
	return (false);	
  	}
  } 
  if (document.DS156.fwhenvisadenial_year.value.length > 0){
  	for (var i=0; i<document.DS156.fwhenvisadenial_year.value.length; i++) {
  	temp = "" + document.DS156.fwhenvisadenial_year.value.substring(i, i+1);
  	if (valid3.indexOf(temp) == "-1") ok = "no";
  	}
  	if (ok == "no") {
  	alert("(Item 31) Invalid Entry - The Year field can only contain numbers.");
   	document.DS156.fwhenvisadenial_year.focus();
	return (false);	
  	}
  } 
if (document.DS156.fwhenvisadenial_day.value == ""){
    alert("(Item 31) Invalid Date - The Day field cannot be blank when the Month or Year fields contain information.");
    document.DS156.fwhenvisadenial_day.focus();
    return (false);
}
if (mytempMonth == ""){
    alert("(Item 31) Invalid Date - The Month field cannot be blank when the Day or Year fields contain information.");
    document.DS156.fwhenvisadenial_month.focus();
    return (false);
}
if (document.DS156.fwhenvisadenial_year.value == ""){
    alert("(Item 31) Invalid Date - The Year field cannot be blank when the Day or Month fields contain information.");
    document.DS156.fwhenvisadenial_year.focus();
    return (false);
}
if (document.DS156.fwhenvisadenial_year.value.length < 4){
    alert("(Item 31) Invalid Date - The Year field must be 4 digits.");
    document.DS156.fwhenvisadenial_year.focus();
    return (false);
}
if (document.DS156.fwhenvisadenial_year.value.substring(0, 1) == "0"){
    alert("(Item 31) Invalid Date - The Year field cannot start with a zero.");
    document.DS156.fwhenvisadenial_year.focus();
    return (false);
}
DateOK="Yes";
myFieldName = '(Item 31)';
dateCheck(document.DS156.fwhenvisadenial_day.value + document.DS156.fwhenvisadenial_month.value + document.DS156.fwhenvisadenial_year.value,'%d%MON%yyyy'); 
if (DateOK == "No"){
   	document.DS156.fwhenvisadenial_day.focus();
	return false;
}
}

return (true);

}

