// JavaScript Document
function valueLength(e)
{
	//alert(element.value.length);
	if(e.value.length >=1)
	{
		return true;
	}
	else 
	{
		return false;
	}
}

function hasValue(name)
{
	return valueLength(document.getElementById(name));
}

function hasListBoxValue(name)
{
//  alert(name+' '+document.getElementById(name).value);
  return ( valueLength(document.getElementById(name)) && (document.getElementById(name).value!='PleaseSelect')  );
}

function isApplicant2Present()
{
  if(hasValue("CAT_Custom_31616")==true) // Son's Given Name
    {return true;}
  if(hasValue("CAT_Custom_40875")==true) // Son's Last Name
    {return true;}
  if(hasListBoxValue("CAT_Custom_31617")==true) // class of entry
    {return true;}
  if(hasListBoxValue("CAT_Custom_31618")==true)  // year of entry
    {return true;}
  return false;
}



function isApplicant3Present()
{
  if(hasValue("CAT_Custom_40876")==true) // Son's Last Name
    {return true;}
  if(hasValue("CAT_Custom_31619")==true) // Son's Given Name
    {return true;}
  if(hasListBoxValue("CAT_Custom_31620")==true) // Class of Entry
    {return true;}
  if(hasListBoxValue("CAT_Custom_31622")==true) // Year of Entry
    {return true;}
  return false;
}

function checkApplicants()
{



var errorMessage = "";
//alert(document.getElementById("CAT_Custom_31616").value.length);

if(isApplicant2Present() == true)
{
  // Added by Fortix
  if ( (hasValue("CAT_Custom_31616")==false) || (hasListBoxValue("CAT_Custom_31617")==false) || (hasListBoxValue("CAT_Custom_31618")==false) || (hasValue("CAT_Custom_40875")==false) )
  {
    errorMessage += "- Applicant 2 must be complete\n";
  }
  // Commented by Fortix
  /*
  if (document.getElementById("CAT_Custom_31616").value.length == 0)
  {
    errorMessage += "- Applicant 2 must be complete\n";
  }
  */
}
if(isApplicant3Present() == true)
{
  // Added by Fortix
  if ( (hasListBoxValue("CAT_Custom_31620")==false) || (hasListBoxValue("CAT_Custom_31622")==false) || (hasValue("CAT_Custom_40876")==false) || (hasValue("CAT_Custom_31619")==false) )
  {
    errorMessage += "- Applicant 3 must be complete\n";
  }
  // Commented by Fortix
  /*
  if (document.getElementById("CAT_Custom_31619").value.length == 0)
  {
    errorMessage += "- Applicant 3 must be complete\n";
  }
  */
}
//alert(errorMessage);
  return errorMessage;
}

