MAX_ADDITIONAL_PARTNERS = 10;
MAX_ADDITIONAL_TERMS = 7;

function divdisplay() {
   displayHintDiv();
   withdrawalChange();
   involuntaryChange();
   remainingChange();
   buyoutChange();
   displayAdditional();
   guardianChange();
   displayDate();
}

function withdrawalChange() {
   setVisDisp("involuntaryDiv", getFormObject("partwithdrawal", "withdrawalType")[1].checked);
}

function involuntaryChange() {
   if (getFormObject("partwithdrawal", "involuntaryReason").value == "operation of law against the Withdrawing Partner")
      setVisDisp("lawExample", true);
   else
      setVisDisp("lawExample", false);
   
   if (getFormObject("partwithdrawal", "involuntaryReason").value == "other") {
      setVisDisp("otherReasonDiv", true);
      //setVisDisp("otherReasonDiv2", true);
   }
   else {
      setVisDisp("otherReasonDiv", false);
      //setVisDisp("otherReasonDiv2", false);
   }
}

function remainingChange() {
   numToDisplay = getFormObject("partwithdrawal", "numRemaining").value;
   for (counter = 1; counter<=MAX_ADDITIONAL_PARTNERS; counter++) {
      if (counter == numToDisplay)
         borderCSS = "none";
      else
         borderCSS = "thin solid #DDD";
      if (counter <= numToDisplay)
         shouldDisplay = true;
      else
         shouldDisplay = false;
      getObject("remainingPartner" + counter).style.borderBottom = borderCSS;
      setVisDisp("remainingPartner" + counter, shouldDisplay);
   }
}

function buyoutChange() {
   if (getFormObject("partwithdrawal", "buyoutPeriodRequired")[0].checked) {
      setVisDisp("buyoutPeriodDiv", true);
   }
   else {
      setVisDisp("buyoutPeriodDiv", false);
   }
}

function displayAdditional() {
   numOfExtraClauses = getFormObject(contractFormName, "numOfExtraClauses").value;
   for (counter=1; counter<=MAX_ADDITIONAL_TERMS; counter++) {
      if (counter <= numOfExtraClauses)
         shouldDisplay = true;
      else
         shouldDisplay = false;

      setVisDisp("AdditionalDiv" + counter, shouldDisplay);
   }
}

function guardianChange() {
   if ( (getFormObject("partwithdrawal", "partnerType").value != "corporation") && (!getFormObject("partwithdrawal", "withdrawalType")[1].checked) ) {
      shouldDisplayQuestion = true;
      if (getFormObject("partwithdrawal", "guardian")[0].checked)
          shouldAskForName = true;
      else
         shouldAskForName = false;
   }
   else {
      shouldDisplayQuestion = false;
      shouldAskForName = false;
   }
   
   setVisDisp("guardianQuestionDiv1", shouldDisplayQuestion);
   setVisDisp("guardianQuestionDiv2", shouldDisplayQuestion); // Should we ask if a guardian will sign?
   setVisDisp("guardianDiv1", shouldAskForName); // Should we prompt for a guardian name?
}

function displayDate() {
   //setVisDisp('dateDiv', getFormObject(contractFormName, 'executionDate').value == 'specific');
   setVisInline('partnershipSpecifyDiv',getObject('partnershipChoice').value=='specified');
   setVisInline('withdrawalSpecifyDiv',getObject('withdrawalChoice').value=='specified'); 
}

function displayHintDiv() {
      setVisDisp('hintDiv', getFormObject(contractFormName, 'hintDisplay').checked == true);
}


