//Secondary Custom Code
function DataAwareSignature()
{

   //Show the checkboxes
    CSForm.getField("CSTM_ADOPT_BY_VOTE_FLAG").setHidden(false);
		CSForm.getField("CSTM_ADOPT_BY_UNANIM_FLAG").setHidden(false);

  //Adoption By Vote of Governing Members
   var CSTM_ADOPT_BY_VOTE_FLAG = this.getField("CSTM_ADOPT_BY_VOTE_FLAG");
   CSTM_ADOPT_BY_VOTE_FLAG.readonly = true; 
   var TEAWEB_SIG_GM1_1_TXT = this.getField("TEAWEB_SIG_GM1_1_TXT");
   var GM1_NAME = this.getField("GM1_NAME");
   var IMM_UNL_GM1_CSTM_POSITION = this.getField("IMM_UNL_GM1_CSTM_POSITION");
   GM1_NAME.readonly = true;
   IMM_UNL_GM1_CSTM_POSITION.readonly = true;
   TEAWEB_SIG_GM1_1_TXT.value = "0";

//Adoption By Unanimus Written Consent of Governing Members
   var CSTM_ADOPT_BY_UNANIM_FLAG = this.getField("CSTM_ADOPT_BY_UNANIM_FLAG");
   CSTM_ADOPT_BY_UNANIM_FLAG.readonly = true;
   var TEAWEB_SIG_GM2_1_TXT = this.getField("TEAWEB_SIG_GM2_1_TXT");
   var GM2_NAME = this.getField("GM2_NAME");
   var IMM_UNL_GM2_CSTM_POSITION = this.getField("IMM_UNL_GM2_CSTM_POSITION");
   GM2_NAME.readonly = true;
   IMM_UNL_GM2_CSTM_POSITION.readonly = true;
   TEAWEB_SIG_GM2_1_TXT.value = "0";
   var TEAWEB_SIG_GM3_1_TXT = this.getField("TEAWEB_SIG_GM3_1_TXT");
   var GM3_NAME = this.getField("GM3_NAME");
   var IMM_UNL_GM3_CSTM_POSITION = this.getField("IMM_UNL_GM3_CSTM_POSITION");
   GM3_NAME.readonly = true;
   IMM_UNL_GM3_CSTM_POSITION.readonly = true;
   TEAWEB_SIG_GM3_1_TXT.value = "0";
   var TEAWEB_SIG_GM4_1_TXT = this.getField("TEAWEB_SIG_GM4_1_TXT");
   var GM4_NAME = this.getField("GM4_NAME");
   var IMM_UNL_GM4_CSTM_POSITION = this.getField("IMM_UNL_GM4_CSTM_POSITION");
   GM4_NAME.readonly = true;
   IMM_UNL_GM4_CSTM_POSITION.readonly = true;
   TEAWEB_SIG_GM4_1_TXT.value = "0";
   var TEAWEB_SIG_GM5_1_TXT = this.getField("TEAWEB_SIG_GM5_1_TXT");
   var GM5_NAME = this.getField("GM5_NAME");
   var IMM_UNL_GM5_CSTM_POSITION = this.getField("IMM_UNL_GM5_CSTM_POSITION");
   GM5_NAME.readonly = true;
   IMM_UNL_GM5_CSTM_POSITION.readonly = true;
   TEAWEB_SIG_GM5_1_TXT.value = "0";
   var TEAWEB_SIG_GM6_1_TXT = this.getField("TEAWEB_SIG_GM6_1_TXT");
   var GM6_NAME = this.getField("GM6_NAME");
   var IMM_UNL_GM6_CSTM_POSITION = this.getField("IMM_UNL_GM6_CSTM_POSITION");
   GM6_NAME.readonly = true;
   IMM_UNL_GM6_CSTM_POSITION.readonly = true;
   TEAWEB_SIG_GM6_1_TXT.value = "0";

  //Red Group
   var CSTM_C_CORP_FLAG = this.getField("CSTM_C_CORP_FLAG");   
   var CSTM_S_CORP_FLAG = this.getField("CSTM_S_CORP_FLAG");  
   var CSTM_SOLE_PROP_FLAG = this.getField("CSTM_SOLE_PROP_FLAG");
   var CSTM_LLC_FLAG = this.getField("CSTM_LLC_FLAG");
   var CSTM_PART_FLAG = this.getField("CSTM_PART_FLAG");
   var CSTM_UNICORP_ORG_FLAG = this.getField("CSTM_UNICORP_ORG_FLAG");
   var CSTM_ASSOC_CLUB_FLAG = this.getField("CSTM_ASSOC_CLUB_FLAG");
   //Purple Group
   var CSTM_LLC_C_CORP_FLAG = this.getField("CSTM_LLC_C_CORP_FLAG");
   var CSTM_LLC_S_CORP_FLAG = this.getField("CSTM_LLC_S_CORP_FLAG");
   var CSTM_LLC_PART_FLAG = this.getField("CSTM_LLC_PART_FLAG");
  //Gree Group
   var CSTM_PART_GEN_FLAG = this.getField("CSTM_PART_GEN_FLAG");
   var CSTM_PART_LTD_FLAG = this.getField("CSTM_PART_LTD_FLAG");
   var CSTM_PART_LTD_LIAB_FLAG = this.getField("CSTM_PART_LTD_LIAB_FLAG");
   
   //When LLC or Partnership flags are unchecked then its associated flags are unchecked as well
   if (CSTM_LLC_FLAG.value == "0"){
	   CSTM_LLC_C_CORP_FLAG.value = "0";
	   CSTM_LLC_S_CORP_FLAG.value = "0";
	   CSTM_LLC_PART_FLAG.value = "0";
   }
   if (CSTM_PART_FLAG.value == "0"){
	   CSTM_PART_GEN_FLAG.value = "0";
	   CSTM_PART_LTD_FLAG.value = "0";
	   CSTM_PART_LTD_LIAB_FLAG.value = "0";
   }


  if (CSTM_C_CORP_FLAG.value == "1" || CSTM_S_CORP_FLAG.value == "1")
  {
  this.getField("CSTM_ADOPT_BY_VOTE_FLAG").readonly=false;
  this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").readonly=false;
  }

  if (CSTM_UNICORP_ORG_FLAG.value == "1" || CSTM_ASSOC_CLUB_FLAG.value == "1")
  {
  this.getField("CSTM_ADOPT_BY_VOTE_FLAG").readonly=false;
  this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").readonly=true;
  }

  if (CSTM_SOLE_PROP_FLAG.value == "1" || CSTM_LLC_FLAG.value == "1" && (CSTM_LLC_C_CORP_FLAG.value == "1" || CSTM_LLC_S_CORP_FLAG.value == "1" ||CSTM_LLC_PART_FLAG.value == "1") || CSTM_PART_FLAG.value == "1" && (CSTM_PART_GEN_FLAG.value == "1"  || CSTM_PART_LTD_FLAG.value == "1" || CSTM_PART_LTD_LIAB_FLAG.value == "1") )
  {
  this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").readonly=false;
  this.getField("CSTM_ADOPT_BY_VOTE_FLAG").readonly=true;
  }

  if (CSTM_ADOPT_BY_VOTE_FLAG.value == "1")
  {
   TEAWEB_SIG_GM1_1_TXT.value = "1";
   GM1_NAME.readonly = false;
   IMM_UNL_GM1_CSTM_POSITION.readonly = false;
  }
  
  if (CSTM_ADOPT_BY_UNANIM_FLAG.value == "1")
  {
  //and following parties should NOT be available for "Sole Proprietorship" and "LLC Type Sole Proprietorship"
   TEAWEB_SIG_GM2_1_TXT.value = "1";
   GM2_NAME.readonly = false;
   IMM_UNL_GM2_CSTM_POSITION.readonly = false;
  //and following parties should NOT be available for "Sole Proprietorship" and "LLC Type Sole Proprietorship"
  if (CSTM_C_CORP_FLAG.value == "1" || CSTM_S_CORP_FLAG.value == "1" || CSTM_LLC_C_CORP_FLAG.value == "1" || CSTM_LLC_S_CORP_FLAG.value == "1" || CSTM_LLC_PART_FLAG.value == "1" || CSTM_PART_GEN_FLAG.value == "1"  || CSTM_PART_LTD_FLAG.value == "1" || CSTM_PART_LTD_LIAB_FLAG.value == "1" || CSTM_UNICORP_ORG_FLAG.value == "1")
  {
   TEAWEB_SIG_GM3_1_TXT.value = "1";
   GM3_NAME.readonly = false;
   IMM_UNL_GM3_CSTM_POSITION.readonly = false;

   TEAWEB_SIG_GM4_1_TXT.value = "1";
   GM4_NAME.readonly = false;
   IMM_UNL_GM4_CSTM_POSITION.readonly = false;

   TEAWEB_SIG_GM5_1_TXT.value = "1";
   GM5_NAME.readonly = false;
   IMM_UNL_GM5_CSTM_POSITION.readonly = false;

   TEAWEB_SIG_GM6_1_TXT.value = "1";
   GM6_NAME.readonly = false;
   IMM_UNL_GM6_CSTM_POSITION.readonly = false;
  } }

}

function CSTM_ADOPT_BY_VOTE_FLAG_PDFMouseExit()
{
	
DataAwareSignature();
}
function CSTM_ADOPT_BY_UNANIM_FLAG_PDFMouseExit()
{
DataAwareSignature();
}

function CSTM_AUTH_PER_FOR_BORROW_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_AUTH_PER_FOR_SHR_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_PART_GEN_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_PART_LTD_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_PART_LTD_LIAB_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_LLC_PART_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_LLC_S_CORP_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_LLC_C_CORP_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_C_CORP_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_S_CORP_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_SOLE_PROP_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_LLC_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_PART_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_UNICORP_ORG_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}

function CSTM_ASSOC_CLUB_FLAG_PDFBlur()
{
DataAwareSignature();
//If a Type of Entity checkbox is changed then the Adoption checkboxes will be reset
this.getField("CSTM_ADOPT_BY_VOTE_FLAG").value = "0";
this.getField("CSTM_ADOPT_BY_UNANIM_FLAG").value = "0";
}