function setRegionCookie() {
   if(dbcountry == 'US') {
      // Set the cookie
      var dbregion = getFormObject('reslease', 'contractJuris').value;
      var date = new Date();
      date.setTime(date.getTime()+(365*24*60*60*1000));
      document.cookie = 'L='+dbcountry+(dbregion!='sel'?dbregion:'')+'; expires='+date.toGMTString()+'; path=/';

      // Set the title
//      document.title = regionNames[dbregion]+' Rental/Lease Agreement (Residential) Form from LawDepot.com';

      // Set the names in the page
      var elems = getElementsByClassName('dbregion_replace');
      for(var i = 0; i < elems.length; i++) {
         elems[i].innerHTML = regionNames[dbregion];
      }
   }
}

function getElementsByClassName(classname, node) {
   if(!node) node = document.getElementsByTagName("body")[0];
   var a = [];
   var re = new RegExp('\\b' + classname + '\\b');
   var els = node.getElementsByTagName("*");
   for(var i=0,j=els.length; i<j; i++)
      if(re.test(els[i].className))a.push(els[i]);
   return a;
}

function setAgreementType(str) {
   if(dbcountry != 'AU') {
   var premisesType = getFormObject("reslease","premisesType");
   for(var i=0;i<premisesType.length;i++)
      if(premisesType[i].value==str) premisesType.selectedIndex = i;
   }
   divdisplay();
}

function copyTenantName(txtObj,txtBoxNum) {
   if (dbcountry == "AU" && getFormObject('reslease','contractJuris').value == "VIC") {
      switch (txtBoxNum){
        case 1:
         getFormObject("reslease","share1").value = txtObj.value;
         break;
        case 2:
         getFormObject("reslease","share2").value = txtObj.value;
         break;
        case 3:
         getFormObject("reslease","share3").value = txtObj.value;
         break;
        case 4:
         getFormObject("reslease","share4").value = txtObj.value;
         break;
        case 5:
         getFormObject("reslease","share5").value = txtObj.value;
         break;
        case 6:
         getFormObject("reslease","share6").value = txtObj.value;
         break;

      }
   }
}

function check3yearsNSW(){
   warning = "";
   if(dbcountry =="AU" && getFormObject("reslease", "contractJuris").value=="NSW"){
         // Check if it is over three years.
   var start11 = Date.parse(getFormObject("reslease", "startMonth").value+" "+getFormObject("reslease", "startDay").value+", "+getFormObject("reslease", "startYear").value);
   var end11 = Date.parse(getFormObject("reslease", "termEndMonth").value+" "+getFormObject("reslease", "termEndDay").value+", "+getFormObject("reslease", "termEndYear").value);
   if((end11-start11)/(1000*60*60*24*365) > 3)
        warning = "Note: This tenancy agreement is for terms of 3 years or less.";

      getObject("termWarningAU").innerHTML = warning;
      setVisDisp("termWarningAU", true);
   } else {
      setVisDisp("termWarningAU", false);
   }
}

function setProvinceDepositHelp(){
   if(dbcountry == 'CA'){
      var helpArr = new Array(12);
      helpArr['BC'] = "Residential Tenancy Act, S.B.C. 2002, c. 78: Landlord can require security deposit, and may require a pet damage deposit if allowing the tenant to keep a pet on the premises (the landlord may make conditions for size, type, number, etc of pets).  Neither deposit may exceed 1/2 the monthly rent each.";
      helpArr['AB'] = "Residential Tenancies Act, S.A. 2004, c. R-17.1: no increase may be made to a security deposit.  No deduction may be made from the security deposit unless an inspection report has been properly made.  Deposit may not exceed (in the case of weekly periodic tenancy) one week's rent OR (in the case of monthly tenancy) one month's rent.";
      helpArr['SK'] = "Residential Tenancies Act, R.S.S. 1978, c. R-22: Security deposit may not exceed 1 month's rent (or 1 week's rent, if tenancy is week-to-week), 50% of which is due at the beginning of the tenancy (or within 30 days of demand letter), and the balance of which is due two months after beginning the tenancy (or 60 days after the aforementioned demand letter).  Landlord may not vacate tenant nor refuse to renew lease for non-compliance with increase in security deposit.  Deposit must be returned within 7 business days of termination of tenancy.  Landlord must apply to Rentalsman to keep all or part of deposit.";
      helpArr['MB'] = "Residential Tenancies Act, C.C.S.M. c. R119: Security deposit not to exceed equivalent of 1/2 of one month's rent.";
      helpArr['ON'] = "Residential Tenancies Act, 2006, S.O. 2006, c. 17: \"Security deposit\" relating to property damage is not allowed.  Landlord may request a \"rent deposit,\" which can only be used in the last month prior to the end of the tenancy as rent.  The deposit may not exceed one month's rent, or if the rental period is less than one month, the deposit may not exceed the rent owed in one rental period.  The amount may be increased if rent increases.  \"Security deposits\" paid before are now considered \"rent deposits.\"  Landlords must apply to the Landlord and Tenancy Board for compensation for damage caused by the tenant.";
      helpArr['NB'] = "Residential Tenancies Act, S.N.B. 1975, c. R-10.2: Security deposit not to exceed (in the case of weekly periodic tenancy) one week's rent OR (in the case of monthly tenancy) one month's rent.  No other deposit charge is allowed.  Landlord must deliver the deposit to a rentalsman.";
      helpArr['NS'] = "Residential Tenancies Act, R.S.N.S. 1989, c. 401: Security deposit may not exceed one half of one month's rent.  No other form of payment may be taken by the landlord other than rent and security deposit.  The deposit must be returned upon termination unless the landlord makes application to the Director of Residential Tenancies.";
      helpArr['PE'] = "Rental of Residential Property Act, R.S.P.E.I. 1988, c. R-13.1: Security deposit may not exceed (in the case of weekly periodic tenancy) one week's rent OR (in the case of monthly tenancy) one month's rent.";
      helpArr['NF'] = "Residential Tenancies Act, 2000, S.N.L. 2000, c. R-14.1: Security deposits may not exceed 2 weeks rent (if a weekly tenancy), or the equivalent of 3/4 of the first month's rent (if a monthly or 6-12 month term).  No tenancies may be created that exceed 12 months in length.";
      helpArr['YT'] = "Landlord and Tenant Act, R.S.Y. 2002, c. 131: Security deposit may not exceed the amount payable for the first month's rent.  The deposit shall be applied to the last period/month's rent, excepting deductions made for damage to the premises.";
      helpArr['NT'] = "Residential Tenancies Act, R.S.N.W.T. 1988, c. R-5: No deposit other than a security deposit is allowed.  Security deposit may not exceed one week's rent (in the case of weekly tenancy), or the equivalent of one month's rent (in the case of any other term of tenancy).  50% of deposit is due at the beginning of the tenancy, the other 50% is due within three months of the beginning of the tenancy.";
      helpArr['NU'] = "Residential Tenancies Act, R.S.N.W.T. 1988, c. R-5 (Still original legislation from NWT): No deposit other than a security deposit is allowed.  Security deposit may not exceed one week's rent (in the case of weekly tenancy), or the equivalent of one month's rent (in the case of any other term of tenancy).  50% of deposit is due at the beginning of the tenancy, the other 50% is due within three months of the beginning of the tenancy.";
      helpArr['sel'] = ' ';

      var gl=getFormObject('reslease','contractJuris').value;
      if(helpArr[gl])
         getObject('depositExpProv').innerHTML = helpArr[gl];

      setVisInline('ontRentDiv1', gl!='ON');
      setVisInline('ontRentDiv2', gl=='ON');
      setVisInline('ontRentDiv3', gl!='ON');
   }
}

var pglTO='';
function setTermOptions(setIndex, govLaw) {
   if(dbcountry == 'CA'){
      var index = getFormObject('reslease','termType').selectedIndex;
      var gl=getFormObject('reslease','contractJuris').value;
      if(govLaw && gl=='sel') gl=govLaw;
      if(gl == 'NF'){
         getFormObject('reslease','termType').options.length = 6;
         getFormObject('reslease','termType').options[0] = new Option('Fixed End Date', 'fixedDate');
         getFormObject('reslease','termType').options[1] = new Option('Fixed Number of Weeks', 'week');
         getFormObject('reslease','termType').options[2] = new Option('Fixed Number of Months', 'month');
         getFormObject('reslease','termType').options[3] = new Option('Weekly with Automatic Renewal', 'weekly');
         getFormObject('reslease','termType').options[4] = new Option('Monthly with Automatic Renewal', 'monthly');
         getFormObject('reslease','termType').options[5] = new Option('Yearly with Automatic Renewal', 'yearly');
         getFormObject('reslease','termType').options[6] = null;
         if(index < 3) ;
         else index--;
      }
      else{
         getFormObject('reslease','termType').options.length = 7;
         getFormObject('reslease','termType').options[0] = new Option('Fixed End Date', 'fixedDate');
         getFormObject('reslease','termType').options[1] = new Option('Fixed Number of Weeks', 'week');
         getFormObject('reslease','termType').options[2] = new Option('Fixed Number of Months', 'month');
         getFormObject('reslease','termType').options[3] = new Option('Fixed Number of Years', 'year');
         getFormObject('reslease','termType').options[4] = new Option('Weekly with Automatic Renewal', 'weekly');
         getFormObject('reslease','termType').options[5] = new Option('Monthly with Automatic Renewal', 'monthly');
         getFormObject('reslease','termType').options[6] = new Option('Yearly with Automatic Renewal', 'yearly');
         if(pglTO == 'NF'){
            if(index < 3) ;
            else index++;
         }
      }
      pglTO=gl;
      if(setIndex)
         getFormObject('reslease','termType').selectedIndex = index;
   }
}

function setPetOptions() {
   // If in Ontario, remove "no" as a "Pets allowed" option
   var index = getObject('petsAllowed').selectedIndex;
   if(getFormObject('reslease','country').value == "Canada" && getFormObject('reslease','contractJuris').value == "ON") {
      getObject('petsAllowed').length = 3;
      getObject('petsAllowed').options[0] = new Option("Yes","yes");
      getObject('petsAllowed').options[1] = new Option("Only with Landlord's Prior Written Consent","consent");
      getObject('petsAllowed').options[2] = new Option("Do Not Specify","dns");
      getObject('petsAllowed').options[3] = null;
      if(index == 0 || index == 1) ; // Do nothing
      else if(index == 2) index = 2; // "No" is no longer a valid action, so change from "No" to "Do not specify"
      else index = 2; // "Do Not Specify" changed positions, so change the selectedIndex
   } else {
      getObject('petsAllowed').length = 4;
      getObject('petsAllowed').options[0] = new Option("Yes","yes");
      getObject('petsAllowed').options[1] = new Option("Only with Landlord's Prior Written Consent","consent");
      getObject('petsAllowed').options[2] = new Option("No","no");
      getObject('petsAllowed').options[3] = new Option("Do Not Specify","dns");
      if(index == 0 || index == 1) ; // Do nothing
      else if(index == 2) index = 3;
      else if(index == 3) ; // Do nothing
   }
   getObject('petsAllowed').selectedIndex = index;
}

function setAssignOptions() {
   if(getFormObject('reslease','country').value == "Canada") {
      getObject('assignLease').options[2] = null;
   }
}

function setDamageRent() {
   var damage='Security/Damage';
   if(getFormObject('reslease','contractJuris').value == 'ON' && dbcountry=='CA'){
      damage='Rent';
   }
   getObject('securityDamageRent1').innerHTML=damage;
   getObject('securityDamageRent2').innerHTML=damage;
}

function setDefaultTenantSameAddr()
{
   getFormObject('reslease','tenantSameAddr')[0].checked = getFormObject('reslease','tenantNumber').value>1;
}

// functions to help display div based on select choices
function divdisplay() {
   dateLoad("agreementDate");
   setDays("start");
   setDays("termEnd");
   actNameLink(); // Provide info for state/prov specific legal act names and links
   if(dbcountry == 'CA'){
      setProvinceDepositHelp();
      setVisDisp('termTypeExpNF', getFormObject('reslease','contractJuris').value=='NF');

   }

   if(dbcountry != 'AU')
   { // controls for non-australia countries
      setDays("possession");
   setDamageRent();
   purchaseOption();
   }

   if(dbcountry =='AU' && getFormObject('reslease','contractJuris').value == "QLD") {
      setVisDisp('hateQLDAUonly',true);
      setVisDisp('landlordForall',false);
   } else {
      setVisDisp('hateQLDAUonly',false);
      setVisDisp('landlordForall',true);
   }

   setVisDisp('petsAllowedQues', !(dbcountry == 'CA' && getFormObject('reslease','contractJuris').value == 'ON'));
   setVisDisp('ontarioDepEx', (dbcountry == 'CA' && getFormObject('reslease','contractJuris').value == 'ON'));
   setVisDisp('nonOntLatePaymentDiv', !(dbcountry == 'CA' && getFormObject('reslease','contractJuris').value == 'ON'));
   setVisInline('ONRentIncreaseDiv', (dbcountry == 'CA' && getFormObject('reslease','contractJuris').value == 'ON'));
   setVisDisp('tenantSSNDiv', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv1', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv2', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv3', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv4', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv5', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv6', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('tenantSSNDiv7', (dbcountry == 'US' || dbcountry=='CA'));
   setVisDisp('attachPhotoDiv', (dbcountry == 'US' || dbcountry=='CA'));
   //var USPetDepositBool = false; //(dbcountry == 'US' && (getFormObject('reslease', 'petsAllowed').value == 'yes' || getFormObject('reslease', 'petsAllowed').value == 'consent'));
   //setVisDisp('USPetDepositDiv', USPetDepositBool);
   //setVisDisp('USPetDepositAmtDiv', USPetDepositBool && getFormObject('reslease', 'USPetDeposit')[0].checked);
   setVisDisp('lostKeysDiv', (dbcountry=='US' || dbcountry=='CA') && getFormObject("reslease","deposit")[0].checked);
   setVisDisp('USUtilitiesDiv', (dbcountry=='US' || dbcountry=='CA') && getFormObject("reslease","utilities")[0].checked);
   setVisDisp('utilOtherDiv', !getFormObject('reslease', 'utilOther')[2].checked);
   setVisDisp('sectionMediation', (dbcountry=='US' || dbcountry=='CA'));
   setVisDisp('mediationPaidByDiv', getFormObject('reslease', 'mediation').value != 'dns');
   setVisDisp('tenantSameAddrDiv', (dbcountry=='US' || dbcountry=='CA') && getFormObject('reslease','tenantNumber').value != '1');
   setVisDisp('propertyManagerDiv', dbcountry=='US' || dbcountry=='CA');
   setVisDisp('propertyManagerDiv2', (dbcountry=='US' || dbcountry=='CA') && getFormObject('reslease', 'propertyManager')[0].checked);



   for(var i = 1; i<8; i++){
   setVisDisp('party2PhoneFaxTable'+i, (dbcountry=='US' || dbcountry=='CA') && getFormObject('reslease','tenantSameAddr')[1].checked);
   setVisDisp('noticeAddressDiv'+i, (dbcountry=='US' || dbcountry=='CA') && getFormObject('reslease', 'tenantSameAddr')[1].checked);
   }

   setAssignOptions();

   if(getFormObject('reslease','country').value == "USA") {
      setVisDisp('leadpaint',getObject('after1978').value == 'no');

      setVisDisp('leadHazardA',getObject('leadHazard').value == 'yes');
      setVisDisp('leadHazardB',getObject('leadHazard').value == 'yes');
      setVisDisp('leadHazardC',getObject('leadHazard').value == 'yes');

      setVisDisp('leadHazardReportA',getObject('leadHazardReport').value == 'yes');
      setVisDisp('leadHazardReportB',getObject('leadHazardReport').value == 'yes');
      setVisDisp('leadHazardReportC',getObject('leadHazardReport').value == 'yes');

      setVisDisp('landlordAgentA',getObject('landlordAgent').value == 'yes');
   }

   if(dbcountry == "AU") { // Australia specific controls
      stateCode = getFormObject('reslease','contractJuris').value;

      //control for FAQ icon in ACT,NSW and NT
      if (stateCode=="ACT" || stateCode=="NSW" || stateCode=="NT") {
         setVisDisp("addTermFAQAU",true);
         setVisDisp("ACTaddTermFAQcontent",stateCode=="ACT");
         setVisDisp("NSWaddTermFAQcontent",stateCode=="NSW");
         setVisDisp("NTaddTermFAQcontent",stateCode=="NT");
         //document.all.addTermFAQLink.href=
         getObject("addTermFAQLink").href="/contracts/reslease/faq/?region="+stateCode+"#addClauses";
      } else {
         setVisDisp("addTermFAQAU",false);
      }

      //NSW control
      check3yearsNSW();
      if(getFormObject('reslease','contractJuris').value == "NSW") {
         setVisDisp("NSW_Note",true);
         setVisDisp("weeklyRentNSW",true);
         setVisDisp("notNSW_AU",false);
         setVisDisp("over300MenuNSW",true);
         tType = getFormObject("reslease", "rentPaymentNSW");
         if(getFormObject("reslease","over300No").checked) {
            tType.options[0].value = "monthly";
            tType.options[0].text = "Month";
            tType.options[1].value = "annual";
            tType.options[1].text = "Year";
         } else {
            tType.options[0].value = "weekly";
            tType.options[0].text = "Week";
            tType.options[1].value = "fortnight";
            tType.options[1].text = "Fortnight";
         }
         setVisDisp("notFixQuestion_NSW",false);
         setVisDisp("DurationTenancyNSW",true);
      } else {
         setVisDisp("NSW_Note",false);
         setVisDisp("weeklyRentNSW",false);
         setVisDisp("notNSW_AU",true);
         setVisDisp("over300MenuNSW",false);
         setVisDisp("notFixQuestion_NSW",true);
         setVisDisp("DurationTenancyNSW",false);
      }
      // QLD specific controls
      if(getFormObject('reslease','contractJuris').value == "QLD") {
         getObject('party1AddressExpPostCode').innerHTML="";
         setVisDisp('party1PostcodeDiv',true);
         setVisDisp('faqQueenslandAgent',true);
         setVisDisp('party2PostCodeTable',true);
         getObject('party2AddressExpPostCode').innerHTML="";
         setVisDisp('signingPersonDiv',true);
         setVisDisp('isAgentAUDiv',false);
         setVisDisp('landlordAgentDiv',true);
         setVisDisp('petsDiv',true);
         if(getFormObject("reslease","pets").value == "yes") {
            setVisDisp('differentPetTypesAmountDiv',true);
            if(getFormObject("reslease","differentPetTypesAmount").value == "2")
               setVisDisp('petType2Div',true);
            else
               setVisDisp('petType2Div',false);
         }
         else{
            setVisDisp('differentPetTypesAmountDiv',false);
            setVisDisp('petType2Div',false);
         }
         setVisDisp('agentFaxDiv',true);
         getObject('agentAddressExpPostCode').innerHTML="";
         setVisDisp('agentPostcodeDiv',true);

         //controls for Property
         setVisDisp('premisesPostcodeAUDiv',true);
         setVisDisp('premisesPostcodeAUDiv2',true);
         getObject('premisesAddressAUExp').innerHTML="(e.g. Suite #, Building Name, Street, City, State/Territory)";
         setVisDisp('bylawsAUDiv',true);
         if(getFormObject("reslease","bylawsAUYes").checked == true)
            setVisDisp('bylawCopiesGivenAUDiv',true);
         else
            setVisDisp('bylawCopiesGivenAUDiv',false);

         setVisDisp('electricalRepairsAUDiv',true);
         if(getFormObject("reslease","electricalRepairsAUYes").checked == true)
            setVisDisp('electricalRepairsNameAUDiv',true);
         else
            setVisDisp('electricalRepairsNameAUDiv',false);

         setVisDisp('plumbingRepairsAUDiv',true);
         if(getFormObject("reslease","plumbingRepairsAUYes").checked == true)
            setVisDisp('plumbingRepairsNameAUDiv',true);
         else
            setVisDisp('plumbingRepairsNameAUDiv',false);

         setVisDisp('otherRepairsAUDiv',true);
         if(getFormObject("reslease","otherRepairsAUYes").checked == true)
            setVisDisp('otherRepairsNameAUDiv',true);
         else
            setVisDisp('otherRepairsNameAUDiv',false);

         // controls for Utilities and Other Costs
         setVisDisp('utilitiesDivQLD_AU',true);

         if(getFormObject("reslease","portionElectricty").checked == true)
            setVisDisp('portionElectrictyTbl',true);
         else
            setVisDisp('portionElectrictyTbl',false);
         if(getFormObject("reslease","portionGas").checked == true)
            setVisDisp('portionGasTbl',true);
         else
            setVisDisp('portionGasTbl',false);
         if(getFormObject("reslease","portionTelephone").checked == true)
            setVisDisp('portionTelephoneTbl',true);
         else
            setVisDisp('portionTelephoneTbl',false);
         if(getFormObject("reslease","portionOther").checked == true)
            setVisDisp('portionOtherTbl',true);
         else
            setVisDisp('portionOtherTbl',false);
         setVisDisp('portionElectrExp', getFormObject("reslease","electrExpYes").checked);
         setVisDisp('portionGasExp', getFormObject("reslease","gasExpYes").checked);
         setVisDisp('portionTeleExp', getFormObject("reslease","telephoneExpYes").checked);
         setVisDisp('portionOtherExp', getFormObject("reslease","otherExpYes").checked);
      }// End of == QLD
      else {
         setVisDisp('party2PostCodeTable',false);
         getObject('party1AddressExpPostCode').innerHTML="&nbsp;Postcode";
         setVisDisp('party1PostcodeDiv',false);
         setVisDisp('isAgentAUDiv',true);
         setVisDisp('faqQueenslandAgent',false);
         // Is the landlord represented by an agent?
         if (getFormObject("reslease","landlordAgent")[1].checked == true) {
            setVisDisp('landlordAgentDiv',false);
         }
         else {
            setVisDisp('landlordAgentDiv',true);
         }
         getObject('party2AddressExpPostCode').innerHTML="&nbsp;Postcode";
         setVisDisp('signingPersonDiv',false);
         setVisDisp('petsDiv',false);
         setVisDisp('differentPetTypesAmountDiv',false);
         setVisDisp('petType2Div',false);
         setVisDisp('agentFaxDiv',false);
         getObject('agentAddressExpPostCode').innerHTML="&nbsp;Postcode";
         setVisDisp('agentPostcodeDiv',false);
         setVisDisp('premisesPostcodeAUDiv',false);
         setVisDisp('premisesPostcodeAUDiv2',false);
         getObject('premisesAddressAUExp').innerHTML="(e.g. Suite #, Building Name, Street, City, State/Territory Postcode)";
         setVisDisp('bylawsAUDiv',false);
         setVisDisp('electricalRepairsAUDiv',false);
         setVisDisp('plumbingRepairsAUDiv',false);
         setVisDisp('otherRepairsAUDiv',false);
         setVisDisp('utilitiesDivQLD_AU',false);
      } // End of != QLD

      //control Phone and fax textbox for Landlord and tenant in Australia
      if(getFormObject('reslease','contractJuris').value == "ACT" || getFormObject('reslease','contractJuris').value == "NSW" || getFormObject('reslease','contractJuris').value == "VIC") {
         setVisDisp('party1PhoneDiv',false);
         setVisDisp('party1FaxDiv',false);
         setVisDisp('party2PhoneFaxTable',false);
      } else {
         setVisDisp('party1PhoneDiv',true);
         setVisDisp('party1FaxDiv',true);
         setVisDisp('party2PhoneFaxTable',true);
      }

      // VIC, QLD specific controls
      if(getFormObject('reslease','contractJuris').value == "VIC" || getFormObject('reslease','contractJuris').value == "QLD") {
         setVisDisp('agentPhoneDiv',true);
      } else {
         setVisDisp('agentPhoneDiv',false);
      }

      // ACT specific controls
      if(getFormObject('reslease','contractJuris').value == "ACT" ) {
         setVisDisp('serviceOfDocDiv',true);
         if(getFormObject("reslease","landlordEmail")[0].checked == true)
            setVisDisp('landlordEmailTbl',true);
         else
            setVisDisp('landlordEmailTbl',false);

         if(getFormObject("reslease","isLandlordOtherAddress")[0].checked == true)
            setVisDisp('landlordOtherAddressTbl',true);
         else
            setVisDisp('landlordOtherAddressTbl',false);

         if(getFormObject("reslease","contactNominee")[0].checked == true)
            setVisDisp('contactNomineeTbl',true);
         else
            setVisDisp('contactNomineeTbl',false);

         if(getFormObject("reslease","tenantEmail")[0].checked == true)
            setVisDisp('tenantEmailTbl',true);
         else
            setVisDisp('tenantEmailTbl',false);

         if(getFormObject("reslease","isTenantOtherAddress")[0].checked == true)
            setVisDisp('tenantOtherAddressTbl',true);
         else
            setVisDisp('tenantOtherAddressTbl',false);
      }
      else {
         setVisDisp('serviceOfDocDiv',false);
      }// End of ACT specific controls
      //NT SA TAS WA NSW premises,pets,parking control,smoking
      if(stateCode == "ACT"  || stateCode == "VIC" || stateCode == "QLD") {
            setVisDisp('FDPDiv4AU',false);
            setVisDisp('furtherDescDiv4AU',false);
            setVisDisp('smokingAllowed4AU',false);
            setVisDisp('petsAllowed4AU',false);

            setVisDisp('ParkingDiv4AU',false);
            setVisDisp('parkingFurtherDiv4AU',false);
            setVisDisp('parkingRentDiv4AU',false);
         } else if (getFormObject('reslease','contractJuris').value == "NSW") {
               setVisDisp('FDPDiv4AU',false);
            setVisDisp('furtherDescDiv4AU',false);
            setVisDisp('smokingAllowed4AU',false);
            setVisDisp('petsAllowed4AU',false);
            setVisDisp('ParkingDiv4AU',true);
            if (getFormObject("reslease","parking").value == "describe")
               setVisDisp('parkingFurtherDiv4AU',true);
            else
               setVisDisp('parkingFurtherDiv4AU',false);
            setVisDisp('parkingRentDiv4AU',false);
         } else {
               setVisDisp('FDPDiv4AU',true);
               setVisDisp('smokingAllowed4AU',true);
               if (getFormObject("reslease","premisesDesc").value == "specify")
               setVisDisp('furtherDescDiv4AU',true);
             else
               setVisDisp('furtherDescDiv4AU',false);

            setVisDisp('petsAllowed4AU',true);

            setVisDisp('ParkingDiv4AU',true);
            if (getFormObject("reslease","parking").value == "describe") {
               setVisDisp('parkingFurtherDiv4AU',true);
               setVisDisp('parkingRentDiv4AU',true);
            } else if (getFormObject("reslease","parking").value == "yes") {
               setVisDisp('parkingFurtherDiv4AU',false);
               setVisDisp('parkingRentDiv4AU',true);
            } else {
               setVisDisp('parkingFurtherDiv4AU',false);
               setVisDisp('parkingRentDiv4AU',false);
            }
          }
          //NT,SA,TAS,WA special control April 26, added
          if(stateCode == "NT"  || stateCode == "SA" || stateCode == "TAS" || stateCode == "WA") {
            setVisDisp('sectionLandlordRepair',true);
            setVisDisp('improvementDiv',getFormObject("reslease","improvements").value == "specify");
            setVisDisp('incentivesDiv',getFormObject("reslease","incentives").value == "specify");
         //Tenant improvement not for NT,SA
         setVisDisp('sectionTenantRepair',stateCode == 'WA' || stateCode == 'TAS');
         setVisDisp('improvementTenantDiv',getFormObject("reslease","improvementsTenant").value == "other" && (stateCode == 'WA' || stateCode == 'TAS'));

         //termination not for SA
         setVisDisp('sectionTermination',stateCode != 'SA');
         setVisDisp('terminationNoticeDiv',getFormObject("reslease","termination").value == "specify" && stateCode != 'SA');
         //utilities
         setVisDisp('sectionUOCost',true);
         setVisDisp('utilitiesDiv',getFormObject("reslease","utilities")[0].checked);
         //Condo should turn off
         setVisDisp("condoDiv", false);
         //Mantenance
         setVisDisp('sectionMaintenance',true);
         setVisDisp('maintenanceDiv',getFormObject("reslease","maintenance")[0].checked);
         setVisDisp('otherMaintenanceDiv',getFormObject("reslease","otherMaintenance")[0].checked);

         //Insurance not for SA
         setVisDisp('sectionInsurance',stateCode != 'SA');
         setVisDisp('insuranceProofDiv',stateCode != 'SA' && (document.forms.reslease.tenantContents[0].checked || document.forms.reslease.landlordContents[0].checked || document.forms.reslease.premises[0].checked  || document.forms.reslease.occupiers[0].checked));
         //Miscellancous not for SA
         if (stateCode != 'SA') {
            setVisDisp('sectionTax',true);

            if (getFormObject("reslease","taxes")[0].checked) {
               setVisDisp('taxesDiv',true);
               setVisDisp('taxesTenantDescDiv',getFormObject("reslease","taxesTenant")[0].checked);

               setVisDisp('taxesGovtDescDiv',getFormObject("reslease","taxesGovt")[0].checked);
            } else {
               setVisDisp('taxesDiv',false);
            }
            setVisDisp('sectionMiscellaneous',true);
            setVisDisp('Misc1stAU',stateCode=='TAS');
            setVisDisp('noticeToEnterAmtDiv',stateCode=='TAS' && getFormObject("reslease","noticeToEnter").value == "specify");
            setVisDisp('Misc3rdAU',stateCode != 'NT');
         } else {
            setVisDisp('sectionTax',false);
            setVisDisp('sectionMiscellaneous',false);
         }
         setVisDisp('renewalDiv',false);
         setVisDisp('attorneyFeesAlternateDiv',false);
         setVisDisp('attorneyFeesHawaiiDiv',false);
          }
          else {
            //turn off the section in ACT,QLD,NSW,VIC
            setVisDisp('sectionTax',false);
            setVisDisp('sectionLandlordRepair',false);
            setVisDisp('sectionTenantRepair',false);
            setVisDisp('sectionTermination',false);
            setVisDisp('sectionUOCost',false);
            setVisDisp('sectionMaintenance',false);
            setVisDisp('sectionInsurance',false);
            setVisDisp('sectionMiscellaneous',false);
          }
      // NSW specific controls
      setVisDisp('furnishingsAUDiv',stateCode == "NSW");
      setVisDisp('storageRoomDivNSW',stateCode =="NSW");
      setVisDisp('storageRoomNumDivNSW',stateCode == "NSW" && getFormObject("reslease", "storageRMYes").checked);
      setVisDisp('repairPersonNSW',stateCode=="NSW");
      setVisDisp('repairTradePersonNSW',stateCode == "NSW" && getFormObject("reslease", "whoRepairsNSWYes").checked);
      setVisDisp('conditionReportNSWSection',stateCode == "NSW");
      setVisDisp('ConRepNSWinput',stateCode == "NSW" && getFormObject("reslease", "conditionReportNSWYes").checked);
      setVisDisp('waterPayNSWSection',stateCode == "NSW");

      // QLD, VIC specific controls
      if(getFormObject('reslease','contractJuris').value == "QLD" || getFormObject('reslease','contractJuris').value == "VIC"  ) {
         setVisDisp('inclusionsAUDiv',true);
         if(getFormObject('reslease','contractJuris').value == "QLD") {
            setVisDisp('AU_VIC',true);
         }
         else {
            setVisDisp('AU_VIC',false);
         }

         if(getFormObject("reslease","createListAUNo").checked == true) {
            setVisDisp('numberItemsAUDiv',false);
            setVisDisp('itemDescriptionAU1Div',false);
            setVisDisp('itemDescriptionAU25Div',false);
            setVisDisp('itemDescriptionAU610Div',false);
            setVisDisp('itemDescriptionAU1115Div',false);
         }
         else {
            setVisDisp('numberItemsAUDiv',true);
            setVisDisp('itemDescriptionAU1Div',true);
            if(getFormObject("reslease","numberItemsAU").value == "1") {
               setVisDisp('itemDescriptionAU25Div',false);
               setVisDisp('itemDescriptionAU610Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "2") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',false);
               setVisDisp('itemDescriptionAU4Div',false);
               setVisDisp('itemDescriptionAU5Div',false);
               setVisDisp('itemDescriptionAU610Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "3") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',false);
               setVisDisp('itemDescriptionAU5Div',false);
               setVisDisp('itemDescriptionAU610Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "4") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',false);
               setVisDisp('itemDescriptionAU610Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "5") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "6") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',false);
               setVisDisp('itemDescriptionAU8Div',false);
               setVisDisp('itemDescriptionAU9Div',false);
               setVisDisp('itemDescriptionAU10Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "7") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',false);
               setVisDisp('itemDescriptionAU9Div',false);
               setVisDisp('itemDescriptionAU10Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "8") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',false);
               setVisDisp('itemDescriptionAU10Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "9") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',false);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "10") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',true);
               setVisDisp('itemDescriptionAU1115Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "11") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',true);
               setVisDisp('itemDescriptionAU1115Div',true);
               setVisDisp('itemDescriptionAU11Div',true);
               setVisDisp('itemDescriptionAU12Div',false);
               setVisDisp('itemDescriptionAU13Div',false);
               setVisDisp('itemDescriptionAU14Div',false);
               setVisDisp('itemDescriptionAU15Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "12") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',true);
               setVisDisp('itemDescriptionAU1115Div',true);
               setVisDisp('itemDescriptionAU11Div',true);
               setVisDisp('itemDescriptionAU12Div',true);
               setVisDisp('itemDescriptionAU13Div',false);
               setVisDisp('itemDescriptionAU14Div',false);
               setVisDisp('itemDescriptionAU15Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "13") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',true);
               setVisDisp('itemDescriptionAU1115Div',true);
               setVisDisp('itemDescriptionAU11Div',true);
               setVisDisp('itemDescriptionAU12Div',true);
               setVisDisp('itemDescriptionAU13Div',true);
               setVisDisp('itemDescriptionAU14Div',false);
               setVisDisp('itemDescriptionAU15Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "14") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',true);
               setVisDisp('itemDescriptionAU1115Div',true);
               setVisDisp('itemDescriptionAU11Div',true);
               setVisDisp('itemDescriptionAU12Div',true);
               setVisDisp('itemDescriptionAU13Div',true);
               setVisDisp('itemDescriptionAU14Div',true);
               setVisDisp('itemDescriptionAU15Div',false);
            }
            else if(getFormObject("reslease","numberItemsAU").value == "15") {
               setVisDisp('itemDescriptionAU25Div',true);
               setVisDisp('itemDescriptionAU2Div',true);
               setVisDisp('itemDescriptionAU3Div',true);
               setVisDisp('itemDescriptionAU4Div',true);
               setVisDisp('itemDescriptionAU5Div',true);
               setVisDisp('itemDescriptionAU610Div',true);
               setVisDisp('itemDescriptionAU6Div',true);
               setVisDisp('itemDescriptionAU7Div',true);
               setVisDisp('itemDescriptionAU8Div',true);
               setVisDisp('itemDescriptionAU9Div',true);
               setVisDisp('itemDescriptionAU10Div',true);
               setVisDisp('itemDescriptionAU1115Div',true);
               setVisDisp('itemDescriptionAU11Div',true);
               setVisDisp('itemDescriptionAU12Div',true);
               setVisDisp('itemDescriptionAU13Div',true);
               setVisDisp('itemDescriptionAU14Div',true);
               setVisDisp('itemDescriptionAU15Div',true);
            }
         }
      }
      else {
         setVisDisp('inclusionsAUDiv',false);
         setVisDisp('AU_VIC',false);

      }// End of QLD, VIC specific controls

      // SA, WA specific controls
      if(getFormObject('reslease','contractJuris').value == "SA" || getFormObject('reslease','contractJuris').value == "WA"  ) {
         setVisDisp('reservedPremisesAUDiv',true);
         if(getFormObject("reslease","reservedPremisesAUNo").checked == true)
            setVisDisp('resPremisesDesAUDiv',false);
         else
            setVisDisp('resPremisesDesAUDiv',true);
      }
      else
         setVisDisp('reservedPremisesAUDiv',false);

      setVisDisp('party1TypeDiv',true);

      // VIC NSW specific controls (Signing Detail div)
      setVisDisp('executionCityDiv',stateCode == "VIC" || stateCode == "NSW");

      // ACT, NSW, NT, TAS specific controls
      if(getFormObject('reslease','contractJuris').value == "ACT" || getFormObject('reslease','contractJuris').value == "NSW" || getFormObject('reslease','contractJuris').value == "NT" || getFormObject('reslease','contractJuris').value == "TAS") {
         setVisDisp('isOtherOccupantsTbl',true);
         if(getFormObject("reslease","otherOccupants")[1].checked == true) {
            setVisDisp('numOtherOccupantsTbl',false);
            setVisDisp('firstOtherOccupantsDiv',false);
            setVisDisp('secondOtherOccupantsDiv',false);
            setVisDisp('thirdOtherOccupantsDiv',false);
            setVisDisp('fourthOtherOccupantsDiv',false);
            setVisDisp('fifthOtherOccupantsDiv',false);
         }
         else{
            setVisDisp('numOtherOccupantsTbl',true);
            if(getFormObject("reslease","numberOtherOccupants").value == "1") {
               setVisDisp('firstOtherOccupantsDiv',true);
               setVisDisp('secondOtherOccupantsDiv',false);
               setVisDisp('thirdOtherOccupantsDiv',false);
               setVisDisp('fourthOtherOccupantsDiv',false);
               setVisDisp('fifthOtherOccupantsDiv',false);
            }
            else if(getFormObject("reslease","numberOtherOccupants").value == "2") {
               setVisDisp('firstOtherOccupantsDiv',true);
               setVisDisp('secondOtherOccupantsDiv',true);
               setVisDisp('thirdOtherOccupantsDiv',false);
               setVisDisp('fourthOtherOccupantsDiv',false);
               setVisDisp('fifthOtherOccupantsDiv',false);
            }
            else if(getFormObject("reslease","numberOtherOccupants").value == "3") {
               setVisDisp('firstOtherOccupantsDiv',true);
               setVisDisp('secondOtherOccupantsDiv',true);
               setVisDisp('thirdOtherOccupantsDiv',true);
               setVisDisp('fourthOtherOccupantsDiv',false);
               setVisDisp('fifthOtherOccupantsDiv',false);
            }
            else if(getFormObject("reslease","numberOtherOccupants").value == "4") {
               setVisDisp('firstOtherOccupantsDiv',true);
               setVisDisp('secondOtherOccupantsDiv',true);
               setVisDisp('thirdOtherOccupantsDiv',true);
               setVisDisp('fourthOtherOccupantsDiv',true);
               setVisDisp('fifthOtherOccupantsDiv',false);
            }
            else if(getFormObject("reslease","numberOtherOccupants").value == "5") {
               setVisDisp('firstOtherOccupantsDiv',true);
               setVisDisp('secondOtherOccupantsDiv',true);
               setVisDisp('thirdOtherOccupantsDiv',true);
               setVisDisp('fourthOtherOccupantsDiv',true);
               setVisDisp('fifthOtherOccupantsDiv',true);
            }
         }

      } // End of == ACT, NSW, NT, TAS
      else {
         setVisDisp('isOtherOccupantsTbl',false);
         setVisDisp('numOtherOccupantsTbl',false);
         setVisDisp('firstOtherOccupantsDiv',false);
         setVisDisp('secondOtherOccupantsDiv',false);
         setVisDisp('thirdOtherOccupantsDiv',false);
         setVisDisp('fourthOtherOccupantsDiv',false);
         setVisDisp('fifthOtherOccupantsDiv',false);
      } // End of != ACT, NSW, NT, TAS

      // NSW, QLD specific controls
      if (getFormObject('reslease','contractJuris').value == "NSW" || getFormObject('reslease','contractJuris').value == "QLD" ){
         setVisDisp('numberOccupantsTextDiv',true);
      }
      else{
         setVisDisp('numberOccupantsTextDiv',false);
      }

      // ACN for Corp type landlord
         setVisDisp('party1ACNDiv',getFormObject("reslease","party1Corp").value == "true");

      //ACN for Corp type Tenant
      setVisDisp('party2ACNDiv',getFormObject("reslease","party2Corp").value == "true");

      //ACN for Agent Corp type
      setVisDisp('agentACNDiv',getFormObject("reslease","agentType").value == "true");

      // Term of Tenancy
      if (getFormObject("reslease","termTypeAU").value == "fixed" || stateCode == "NSW"){
         setVisDisp('termEndDateAUDiv',true);
      }
      else {
         setVisDisp('termEndDateAUDiv',false);
      }
   }

   if (getFormObject("reslease","hintDisplay").checked == true) {
      setVisDisp('hintDiv',true);
   } else {
      setVisDisp('hintDiv',false);
   }

   if (getFormObject("reslease","landlordNumber")[0].checked == true) {
      setVisDisp('firstLandlordDiv',false);
      setVisDisp('secondLandlordDiv',false);
      if(dbcountry == "AU") getObject('areIsLandlordAgent').innerHTML='Is the landlord represented by an agent?';
   } else {
      setVisDisp('firstLandlordDiv',true);
      setVisDisp('secondLandlordDiv',true);
      if(dbcountry == "AU") getObject('areIsLandlordAgent').innerHTML='Are the landlords represented by an agent?';
   }

   if (getFormObject("reslease","party2Corp").selectedIndex == "1") {
      setVisDisp('genderQuestion',false);
   } else {
      setVisDisp('genderQuestion',true);
   }

if (getFormObject("reslease","tenantNumber").value == "1") {
      setVisDisp('firstTenantTitle',false);
      setVisDisp('secondTenantDiv',false);
      setVisDisp('thirdTenantDiv',false);
      setVisDisp('fourthTenantDiv',false);
      setVisDisp('fifthTenantDiv',false);
      setVisDisp('sixthTenantDiv',false);
      setVisDisp('seventhTenantDiv',false);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "2") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',false);
      setVisDisp('fourthTenantDiv',false);
      setVisDisp('fifthTenantDiv',false);
      setVisDisp('sixthTenantDiv',false);
      setVisDisp('seventhTenantDiv',false);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "3") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',true);
      setVisDisp('fourthTenantDiv',false);
      setVisDisp('fifthTenantDiv',false);
      setVisDisp('sixthTenantDiv',false);
      setVisDisp('seventhTenantDiv',false);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "4") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',true);
      setVisDisp('fourthTenantDiv',true);
      setVisDisp('fifthTenantDiv',false);
      setVisDisp('sixthTenantDiv',false);
      setVisDisp('seventhTenantDiv',false);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "5") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',true);
      setVisDisp('fourthTenantDiv',true);
      setVisDisp('fifthTenantDiv',true);
      setVisDisp('sixthTenantDiv',false);
      setVisDisp('seventhTenantDiv',false);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "6") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',true);
      setVisDisp('fourthTenantDiv',true);
      setVisDisp('fifthTenantDiv',true);
      setVisDisp('sixthTenantDiv',true);
      setVisDisp('seventhTenantDiv',false);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "7") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',true);
      setVisDisp('fourthTenantDiv',true);
      setVisDisp('fifthTenantDiv',true);
      setVisDisp('sixthTenantDiv',true);
      setVisDisp('seventhTenantDiv',true);
      setVisDisp('eighthTenantDiv',false);
   } else if (getFormObject("reslease","tenantNumber").value == "8") {
      setVisDisp('firstTenantTitle',true);
      setVisDisp('secondTenantDiv',true);
      setVisDisp('thirdTenantDiv',true);
      setVisDisp('fourthTenantDiv',true);
      setVisDisp('fifthTenantDiv',true);
      setVisDisp('sixthTenantDiv',true);
      setVisDisp('seventhTenantDiv',true);
      setVisDisp('eighthTenantDiv',true);
   }

if(dbcountry != "AU") { // Non-Australia specific controls
   if (getFormObject("reslease","otherOccupantsGB").value == "list") {
      setVisDisp('occupantDiv',true);
   } else {
      setVisDisp('occupantDiv',false);
   }

   if (getFormObject("reslease","premisesDesc").value == "specify") {
      setVisDisp('furtherDescDiv',true);
   } else {
      setVisDisp('furtherDescDiv',false);
   }

   if (getFormObject("reslease","parking").value == "describe") {
      setVisDisp('parkingDiv',true);
      setVisDisp('parkingRentDiv',true);
   } else if (getFormObject("reslease","parking").value == "yes") {
      setVisDisp('parkingDiv',false);
      setVisDisp('parkingRentDiv',true);
   } else {
      setVisDisp('parkingDiv',false);
      setVisDisp('parkingRentDiv',false);
   }

   if (getFormObject("reslease","furnished").value == "describe" || getFormObject("reslease","furnished").value == "partially") {
      setVisDisp('furnishDescDiv',true);
   } else {
      setVisDisp('furnishDescDiv',false);
   }

   if (getFormObject('reslease','furnished').value == 'partially')
   getObject('partiallyFurnished').innerHTML = 'Partially&nbsp;';
   else
      getObject('partiallyFurnished').innerHTML = '';

} // End of Non-Australia specific controls

   if(getFormObject("reslease", "contractCountry").value=="GB"){
      currencySign = "&#163;";
   }
   else{
      currencySign = "$";
   }

if(dbcountry != "AU") { // Non-Australia specific controls
   if (getFormObject("reslease","termType").value == "fixedDate") {
      setVisDisp('termEndDateDiv',true);
      setVisDisp('termNumberDiv',false);
      setVisDisp('rentIncreaseDiv',false);
      setVisDisp('rentIncrease1Div',true);
      setVisDisp('renewalDiv',true);
      getObject('rentIncrease1Desc').innerHTML = "(e.g.&nbsp;First Year - "+currencySign+"1000.00, Second Year - "+currencySign+"1250.00, etc.)";
   } else if (getFormObject("reslease","termType").value == "week"){
      setVisDisp('termEndDateDiv',false);
      setVisDisp('termNumberDiv',true);
      setVisDisp('rentIncreaseDiv',false);
      setVisDisp('rentIncrease1Div',true);
      setVisDisp('renewalDiv',true);
      getObject('termNumberDesc').innerHTML = "Number of Weeks:";
      getObject('rentIncrease1Desc').innerHTML = "(e.g.&nbsp;Weeks 1-12 - "+currencySign+"100.00, Weeks 13-24 - "+currencySign+"125.00, etc.)";
   } else if (getFormObject("reslease","termType").value == "month"){
      setVisDisp('termEndDateDiv',false);
      setVisDisp('termNumberDiv',true);
      setVisDisp('rentIncreaseDiv',false);
      setVisDisp('rentIncrease1Div',true);
      setVisDisp('renewalDiv',true);
      getObject('termNumberDesc').innerHTML = "Number of Months:";
      getObject('rentIncrease1Desc').innerHTML = "(e.g.&nbsp;Months 1-6 - "+currencySign+"400.00, Months 6-12 - "+currencySign+"500.00, etc.)";
   } else if (getFormObject("reslease","termType").value == "year"){
      setVisDisp('termEndDateDiv',false);
      setVisDisp('termNumberDiv',true);
      setVisDisp('rentIncreaseDiv',false);
      setVisDisp('rentIncrease1Div',true);
      setVisDisp('renewalDiv',true);
      getObject('termNumberDesc').innerHTML = "Number of Years:";
      getObject('rentIncrease1Desc').innerHTML = "(e.g.&nbsp;First Year - "+currencySign+"1000.00, Second Year - "+currencySign+"1250.00, etc.)";

   } else if (getFormObject("reslease","termType").value == "fort"){
      setVisDisp('termEndDateDiv',false);
      setVisDisp('termNumberDiv',true);
      setVisDisp('rentIncreaseDiv',false);
      setVisDisp('rentIncrease1Div',true);
      setVisDisp('renewalDiv',true);
      getObject('termNumberDesc').innerHTML = "Number of Fortnights:";
      getObject('rentIncrease1Desc').innerHTML = "(e.g.&nbsp;Fortnights 1-6 - "+currencySign+"400.00, Fortnights 6-12 - "+currencySign+"500.00, etc.)";
   } else {
      setVisDisp('termEndDateDiv',false);
      setVisDisp('termNumberDiv',false);
      setVisDisp('rentIncreaseDiv',true);
      setVisDisp('rentIncrease1Div',false);
      setVisDisp('renewalDiv',false);
   }
   switch(getFormObject("reslease","rentPayment").value){
      case "weekly":
         getObject('rentAmountLabel').innerHTML = "Amount of Weekly Rent Payment:";
         getObject('paymentDayLabel').innerHTML = "Day of the Week for Payment:";
         getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;Monday, Tuesday)";
         break;
      case 'biweekly':
         getObject('rentAmountLabel').innerHTML = "Amount of Biweekly Rent Payment:";
    getObject('paymentDayLabel').innerHTML = "Day of the Week for Payment:";
    getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;Monday, Tuesday)";
         break;
      case "monthly":
         getObject('rentAmountLabel').innerHTML = "Amount of Monthly Rent Payment:";
         getObject('paymentDayLabel').innerHTML = "Day of the Month for Payment:";
         getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;first, tenth)";
         break;
      case "quarterly":
         getObject('rentAmountLabel').innerHTML = "Amount of Rent Payment Every 3 Months:";
         getObject('paymentDayLabel').innerHTML = "Day of the Month for Payment:";
         getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;first, tenth)";
         break;
      case "semiannual":
         getObject('rentAmountLabel').innerHTML = "Amount of Rent Payment Every 6 Months:";
         getObject('paymentDayLabel').innerHTML = "Day of the Month for Payment:";
         getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;first, tenth)";
         break;
      case "annual":
         getObject('rentAmountLabel').innerHTML = "Amount of Yearly Rent Payment:";
         getObject('paymentDayLabel').innerHTML = "Date for Yearly Payment:";
         getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;July 1st)";
         break;

      case "fortly":
         getObject('rentAmountLabel').innerHTML = "Amount of Fortnightly Rent Payment:";
         getObject('paymentDayLabel').innerHTML = "Day for Fortnightly Payment:";
         getObject('paymentDayExample').innerHTML = "(e.g.&nbsp;first Monday, last Friday)";
         break;
   }
 }// End of Non-Australia specific controls

if(getFormObject("reslease", "contractCountry").value=="AU") {// Australia specific controls
   stateCode= getFormObject('reslease','contractJuris').value;
   //control for Year (in N.S.W.) under Tenant Will Pay Rent Every
    if( getFormObject('reslease','contractJuris').value == "NSW")
      getObject('rentPaymentYearOpt').style.display='block';
    else // not working on IE6
      getObject('rentPaymentYearOpt').style.display='none';

   // set label for bond/security deposit
    if( getFormObject('reslease','contractJuris').value == "TAS") {
       getObject('bondTitle').innerHTML = "Security Deposit";
       getObject('txtBondSecurity').innerHTML = "Security Deposit Amount:";
    } else {
       getObject('bondTitle').innerHTML = "Bond";
       getObject('txtBondSecurity').innerHTML = "Bond Amount:";

   }

   // control for Tenant Will Pay Rent Every
   if ( stateCode == "NSW")
      temp = "rentPaymentNSW";
   else
      temp = "rentPayment";
   if( stateCode == "NSW" || stateCode == "QLD" || stateCode == "SA") {
      setVisDisp('dayofPayDiv',true);
    }
    else {
      setVisDisp('dayofPayDiv',false);
    }
    switch(getFormObject("reslease",temp).value){
         case "weekly":
       getObject('rentAmountLabel').innerHTML = "Amount of Weekly Rent:";
       getObject('paymentDayLabel').innerHTML = "Day of Payment:";
       if(getFormObject('reslease','contractJuris').value == "NSW")
         getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>The tenant must pay in advance on the _____________ of every week. <br>(e.g.&nbsp;Friday, or first day)";
       if(getFormObject('reslease','contractJuris').value == "QLD")
         getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>Rent must be paid on the _____________ of every week.<br>(e.g.&nbsp;Friday, or first day)";
       else // SA
         getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>Payment of rent will be made on the _____________ of each week.<br>(e.g.&nbsp;Friday, or first day)";
       break;
         case "fortnight":
       getObject('rentAmountLabel').innerHTML = (stateCode == "NSW")?"Amount of Fortnightly Rent:":"Amount of Rent Paid Each Fortnight:";
       getObject('paymentDayLabel').innerHTML = "Day of Payment:";
       getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>Rent must be paid on the _____________ of every fortnight.";
       break;
         case "monthly":
       getObject('rentAmountLabel').innerHTML = "Amount of Monthly Rent:";
       getObject('paymentDayLabel').innerHTML = "Day of Payment:";
       if(getFormObject('reslease','contractJuris').value == "NSW")
         getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>The tenant must pay in advance on the _____________ of every month. <br>(e.g.&nbsp;last day, or 21st)";
       if(getFormObject('reslease','contractJuris').value == "QLD")
         getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>Rent must be paid on the _____________ of every month.<br>(e.g.&nbsp;last day, or 21st)";
       else // SA
         getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>Payment of rent will be made on the _____________ of each month.<br>(e.g.&nbsp;last day, or 21st)";
       break;
         case "annual":
       getObject('rentAmountLabel').innerHTML = "Amount of Yearly Rent:";
       getObject('paymentDayLabel').innerHTML = "Day of Payment:";
       getObject('paymentDayExample').innerHTML = "Complete the following sentence: <br>The tenant must pay in advance on the _____________ of every year. <br>(e.g.&nbsp;1st of January)";
       break;
    }


   // control for Date of First Payment (if in  NSW., Victoria, Western Australia)
    if( getFormObject('reslease','contractJuris').value == "NSW" || getFormObject('reslease','contractJuris').value == "VIC" || getFormObject('reslease','contractJuris').value == "WA"  )
       setVisDisp('dateofFirstPayDiv',true);
    else
       setVisDisp('dateofFirstPayDiv',false);

   // control for Would you like to specify a method of payment? (in ACT, NSW, NT, Queensland, Tas.)
   if( getFormObject('reslease','contractJuris').value == "ACT" ||  getFormObject('reslease','contractJuris').value == "NT" ||  getFormObject('reslease','contractJuris').value == "TAS") {
      setVisDisp('specifyMethodDiv',true);
      if (getFormObject("reslease","specifyMethodYes").checked){
         setVisDisp('paymentMethodDiv',true);
      } else {
         setVisDisp('paymentMethodDiv',false);
      }
      setVisDisp('specifyMethodDivNSW',false);
   }
   else if (getFormObject('reslease','contractJuris').value == "NSW" ||  getFormObject('reslease','contractJuris').value == "QLD" ) {
      setVisDisp('specifyMethodDiv',false);
      setVisDisp('paymentMethodDiv',false);
      setVisDisp('specifyMethodDivNSW',true);
   }
   else {
      setVisDisp('specifyMethodDiv',false);
      setVisDisp('paymentMethodDiv',false);
      setVisDisp('specifyMethodDivNSW',false);
   }

   // control for Would you like to specify an account at which the rent can be deposited? (in N.S.W.)
   if (getFormObject('reslease','contractJuris').value == "NSW") {
      setVisDisp('specifyAccountDiv',true);
     if (getFormObject("reslease","specifyAccountYes").checked){
      setVisDisp('rentAccountDiv',true);
      } else {
         setVisDisp('rentAccountDiv',false);
      }
   }
   else {
      setVisDisp('specifyAccountDiv',false);
      setVisDisp('rentAccountDiv',false);
   }

   // control for Bond
    if (getFormObject('reslease','contractJuris').value == "VIC") {
      setVisDisp('bondDivNT',true);
      setVisDisp('bondYesDiv',false);
      setVisDisp('bondDiv',false);
      if (getFormObject("reslease","tenantNumber").value == "1") {
         setVisDisp('moreTenant',false);
         setVisDisp('tenant1fee',false);
         setVisDisp('tenant2fee',false);
         setVisDisp('tenant3fee',false);
         setVisDisp('tenant4fee',false);
         setVisDisp('tenant5fee',false);
         setVisDisp('tenant6fee',false);
         setVisDisp('tenant7fee',false);
         setVisDisp('tenant8fee',false);
      } else {
         setVisDisp('moreTenant',true);
         if (getFormObject("reslease","equalNo").checked) {
            if (getFormObject("reslease","tenantNumber").value == "2") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',false);
                     setVisDisp('tenant4fee',false);
                     setVisDisp('tenant5fee',false);
                     setVisDisp('tenant6fee',false);
                     setVisDisp('tenant7fee',false);
                     setVisDisp('tenant8fee',false);
                  } else if (getFormObject("reslease","tenantNumber").value == "3") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',true);
                     getFormObject("reslease","share3").value = getFormObject("reslease","party2Name2").value;
                     setVisDisp('tenant4fee',false);
                     setVisDisp('tenant5fee',false);
                     setVisDisp('tenant6fee',false);
                     setVisDisp('tenant7fee',false);
                     setVisDisp('tenant8fee',false);
                  } else if (getFormObject("reslease","tenantNumber").value == "4") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',true);
                     getFormObject("reslease","share3").value = getFormObject("reslease","party2Name2").value;
                     setVisDisp('tenant4fee',true);
                     getFormObject("reslease","share4").value = getFormObject("reslease","party2Name3").value;
                     setVisDisp('tenant5fee',false);
                     setVisDisp('tenant6fee',false);
                     setVisDisp('tenant7fee',false);
                     setVisDisp('tenant8fee',false);
                  } else if (getFormObject("reslease","tenantNumber").value == "5") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',true);
                     getFormObject("reslease","share3").value = getFormObject("reslease","party2Name2").value;
                     setVisDisp('tenant4fee',true);
                     getFormObject("reslease","share4").value = getFormObject("reslease","party2Name3").value;
                     setVisDisp('tenant5fee',true);
                     getFormObject("reslease","share5").value = getFormObject("reslease","party2Name4").value;
                     setVisDisp('tenant6fee',false);
                     setVisDisp('tenant7fee',false);
                     setVisDisp('tenant8fee',false);
                  } else if (getFormObject("reslease","tenantNumber").value == "6") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',true);
                     getFormObject("reslease","share3").value = getFormObject("reslease","party2Name2").value;
                     setVisDisp('tenant4fee',true);
                     getFormObject("reslease","share4").value = getFormObject("reslease","party2Name3").value;
                     setVisDisp('tenant5fee',true);
                     getFormObject("reslease","share5").value = getFormObject("reslease","party2Name4").value;
                     setVisDisp('tenant6fee',true);
                     getFormObject("reslease","share6").value = getFormObject("reslease","party2Name5").value;
                     setVisDisp('tenant7fee',false);
                     setVisDisp('tenant8fee',false);
                  } else if (getFormObject("reslease","tenantNumber").value == "7") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',true);
                     getFormObject("reslease","share3").value = getFormObject("reslease","party2Name2").value;
                     setVisDisp('tenant4fee',true);
                     getFormObject("reslease","share4").value = getFormObject("reslease","party2Name3").value;
                     setVisDisp('tenant5fee',true);
                     getFormObject("reslease","share5").value = getFormObject("reslease","party2Name4").value;
                     setVisDisp('tenant6fee',true);
                     getFormObject("reslease","share6").value = getFormObject("reslease","party2Name5").value;
                     setVisDisp('tenant7fee',true);
                     getFormObject("reslease","share7").value = getFormObject("reslease","party2Name6").value;
                     setVisDisp('tenant8fee',false);
                  } else if (getFormObject("reslease","tenantNumber").value == "8") {
                     setVisDisp('tenant1fee',true);
                     getFormObject("reslease","share1").value = getFormObject("reslease","party2Name").value;
                     setVisDisp('tenant2fee',true);
                     getFormObject("reslease","share2").value = getFormObject("reslease","party2Name1").value;
                     setVisDisp('tenant3fee',true);
                     getFormObject("reslease","share3").value = getFormObject("reslease","party2Name2").value;
                     setVisDisp('tenant4fee',true);
                     getFormObject("reslease","share4").value = getFormObject("reslease","party2Name3").value;
                     setVisDisp('tenant5fee',true);
                     getFormObject("reslease","share5").value = getFormObject("reslease","party2Name4").value;
                     setVisDisp('tenant6fee',true);
                     getFormObject("reslease","share6").value = getFormObject("reslease","party2Name5").value;
                     setVisDisp('tenant7fee',true);
                     getFormObject("reslease","share7").value = getFormObject("reslease","party2Name6").value;
                     setVisDisp('tenant8fee',true);
                     getFormObject("reslease","share8").value = getFormObject("reslease","party2Name7").value;
                  }
         } else if (getFormObject("reslease","equalYes").checked) {
            setVisDisp('tenant1fee',false);
            setVisDisp('tenant2fee',false);
            setVisDisp('tenant3fee',false);
            setVisDisp('tenant4fee',false);
            setVisDisp('tenant5fee',false);
            setVisDisp('tenant6fee',false);
            setVisDisp('tenant7fee',false);
            setVisDisp('tenant8fee',false);
         }
      }
      getObject('bondExpNT').innerHTML = "Note: In Victoria, when rent is $350.00/week or less, the maximum bond equals one month's rent.  The landlord can apply to the Victorian Civil and Administrative Tribunal (VCAT) if they want a higher bond.  Usually, higher bond will only be allowed if the tenancy agreement provides that the premises are the landlord's usual place of residence and the tenant is only occupying the premises until the landlord comes back or if the rent is more than $350.00/week.";
    }
    else {
       setVisDisp('bondDiv',true);
      setVisDisp('bondDivNT',false);
       if(getFormObject('reslease','contractJuris').value == "TAS")
         {getObject('bondLbl').innerHTML = "Security Deposit? ";}
       else
         {getObject('bondLbl').innerHTML = "Bond? ";}
       if (getFormObject("reslease","bondYes").checked){
         setVisDisp('bondYesDiv',true);
         if(getFormObject('reslease','contractJuris').value == "ACT"){
            getObject('bondExp').innerHTML = "Note: In the Australian Capital Territory the maximum bond that can be collected is up to four weeks rent (regardless of the weekly rental rate). A Bond Lodgment Form, signed by both the landlord/agent and the tenant, must be lodged by the landlord/agent with the Office within ten days (30 days for an agent). This form is available from the Office of Rental Bonds. If the landlord/agent fails to lodge the form, the landlord/agent could be fined up to $5000.  It is illegal for the landlord/agent to hold the bond without lodging the form.";
         }
         else if(getFormObject('reslease','contractJuris').value == "NSW"){
            getObject('bondExp').innerHTML = "Note: In New South Wales the maximum bond equals the equivalent of four weeks rent when the premises are unfurnished. If the premises are furnished then the maximum bond equals the equivalent of six weeks rent. For fully furnished premises with a rent exceeding $250.00 per week, the maximum bond is unlimited.";
         }
         else if (getFormObject('reslease','contractJuris').value == "NT") {
            getObject('bondExp').innerHTML = "Note: In the Northern Territory the maximum bond is four weeks rent regardless of the weekly rental rate.";
         }
         else if(getFormObject('reslease','contractJuris').value == "QLD"){
            getObject('bondExp').innerHTML = "Note: In Queensland the maximum bond equals no more than four weeks rent (or two weeks rent for moveable dwelling tenancies) if the weekly rent is $300 or less. There is no bond limit if the weekly rent is more than $300.";
         }
         else if(getFormObject('reslease','contractJuris').value == "SA"){
            getObject('bondExp').innerHTML = "Note: In South Australia the maximum bond equals four weeks rent if the rent is less than $250/week. If the rent exceeds $250/week the landlord/agent can ask for a bond equalling six weeks rent.  A receipt showing the date, the person's name, the amount and the address of the premises must be issued within 48 hours after the bond is paid. All security bonds must be paid to the Commissioner for Consumer Affairs using the Bond Lodgement form within seven days (or in the case of registered land agents, within 30 days) of receipt.";
         }
         else if(getFormObject('reslease','contractJuris').value == "TAS"){
            getObject('bondExp').innerHTML = "Note: In Tasmania the maximum amount security deposit equals four weeks rent.";
         }
         else if(getFormObject('reslease','contractJuris').value == "WA"){
            getObject('bondExp').innerHTML = "Note: In Western Australia the maximum bond equals four weeks rent, plus an extra $100 if pets are kept on the premises.  If the premises have been the owner's principal residence for the previous 3 months or if the weekly rent exceeds $500 then there is no limit on the amount of the bond.";
         }
       } else {
         setVisDisp('bondYesDiv',false);
       }
    }

    // control for Where should rent be paid? (in Queensland, Victoria, South Australia)
    if (getFormObject('reslease','contractJuris').value == "QLD" || getFormObject('reslease','contractJuris').value == "VIC" || getFormObject('reslease','contractJuris').value == "SA") {
      setVisDisp('rentAddressDiv',true);
    }
    else {
      setVisDisp('rentAddressDiv',false);
    }

}// End of Australia specific controls


if(getFormObject("reslease", "contractCountry").value!="AU") {// Non-Australia specific controls
   if (getFormObject("reslease","rentIncrease").value == "specify") {
      setVisDisp('rentIncreaseNoticeDiv',true);
   } else {
      setVisDisp('rentIncreaseNoticeDiv',false);
   }

   if (getFormObject("reslease","rentIncrease1").value == "yes") {
      setVisDisp('rentIncreaseNotice1Div',true);
   } else {
      setVisDisp('rentIncreaseNotice1Div',false);
   }

   if (getFormObject("reslease","lateCharge").value == "dns") {
      setVisDisp('lateChargeAmtDiv',false);
      setVisDisp('lateChargeAmt1Div',false);
   } else if (getFormObject("reslease","lateCharge").value == "other") {
      setVisDisp('lateChargeAmtDiv',false);
      setVisDisp('lateChargeAmt1Div',true);
   } else if (getFormObject("reslease","lateCharge").value == "percent") {
      setVisDisp('lateChargeAmtDiv',true);
      setVisDisp('lateChargeAmt1Div',false);
      getObject("lateChargeAmtDesc").innerHTML = "(e.g.&nbsp;5%)";
   } else if (getFormObject("reslease","lateCharge").value == "daily") {
      setVisDisp('lateChargeAmtDiv',true);
      setVisDisp('lateChargeAmt1Div',false);
      getObject("lateChargeAmtDesc").innerHTML = "(e.g.&nbsp;2.50)";
   } else if (getFormObject("reslease","lateCharge").value == "fixed") {
      setVisDisp('lateChargeAmtDiv',true);
      setVisDisp('lateChargeAmt1Div',false);
      getObject("lateChargeAmtDesc").innerHTML = "(e.g.&nbsp;15.00)";
   }

   if (getFormObject("reslease","taxes")[0].checked) {
      setVisDisp('taxesDiv',true);
	  
	  	if (getObject('payTaxTo').value == "landlord") {
			getFormObject("reslease","taxesTenant")[0].checked = true;
			getFormObject("reslease","taxesGovt")[1].checked = true;
		}
		else if (getObject('payTaxTo').value == "government") {
			getFormObject("reslease","taxesTenant")[1].checked = true;
			getFormObject("reslease","taxesGovt")[0].checked = true;
		}
		
		
      if (getFormObject("reslease","taxesTenant")[0].checked) {
         setVisDisp('taxesTenantDescDiv',true);
      } else {
         setVisDisp('taxesTenantDescDiv',false);
      }

      if (getFormObject("reslease","taxesGovt")[0].checked) {
         setVisDisp('taxesGovtDescDiv',true);
      } else {
         setVisDisp('taxesGovtDescDiv',false);
      }

   } else {
      setVisDisp('taxesDiv',false);
   }


   if (getFormObject("reslease","improvements").value == "specify") {
      setVisDisp('improvementDiv',true);
   } else {
      setVisDisp('improvementDiv',false);
   }

   if (getFormObject("reslease","incentives").value == "specify") {
      setVisDisp('incentivesDiv',true);
   } else {
      setVisDisp('incentivesDiv',false);
   }

   if (getFormObject("reslease","improvementsTenant").value == "other") {
      setVisDisp('improvementTenantDiv',true);
   } else {
      setVisDisp('improvementTenantDiv',false);
   }
   setVisDisp('utilitiesDiv',getFormObject("reslease","utilities")[0].checked && (getFormObject("reslease", "contractCountry").value!="US" && getFormObject("reslease", "contractCountry").value!="CA"));
} // End of Non-Australia specific controls





if(getFormObject("reslease", "contractCountry").value!="AU") {// Non-Australia specific controls
   if (getFormObject("reslease","maintenance")[0].checked == true) {
      setVisDisp('maintenanceDiv',true);
   } else {
      setVisDisp('maintenanceDiv',false);
   }


   if (getFormObject("reslease","otherMaintenance")[0].checked == true) {
      setVisDisp('otherMaintenanceDiv',true);
   } else {
      setVisDisp('otherMaintenanceDiv',false);
   }


   setVisDisp('terminationNoticeDiv',getFormObject("reslease","termination").value == "specify");

   setVisDisp('securityDepositDiv',getFormObject("reslease","deposit")[0].checked);

      setVisDisp('divPetDepositBC',getFormObject('reslease','contractJuris').value == 'BC' || (getFormObject("reslease", "contractCountry").value=='US' && (getFormObject('reslease', 'petsAllowed').value=='yes' || getFormObject('reslease', 'petsAllowed').value=='consent')));
      setVisDisp('petDepositDiv',getFormObject("reslease","petDeposit")[0].checked);

   //setVisDisp('securityDespositDiv2', getFormObject('reslease','petdeposit')[0].checked || getFormObject("reslease","deposit")[0].checked);

      setVisDisp('divReturnDeposit',getFormObject('reslease','contractJuris').value != 'ON');
      setVisDisp('returnDepositTimeDiv',getFormObject("reslease","returnDeposit").value == "specify");
      setVisDisp('returnPetDepositTimeDiv',getFormObject("reslease","returnPetDeposit").value == "specify");

   if ((document.forms.reslease.tenantContents[0].checked == true)||(document.forms.reslease.landlordContents[0].checked == true)||(document.forms.reslease.premises[0].checked == true)||(document.forms.reslease.occupiers[0].checked == true)) {
      setVisDisp('insuranceProofDiv',true);
   } else {
      setVisDisp('insuranceProofDiv',false);
   }

   if (getFormObject("reslease","noticeToEnter").value == "specify") {
      setVisDisp('noticeToEnterAmtDiv',true);
   } else {
      setVisDisp('noticeToEnterAmtDiv',false);
   }

   if (getFormObject("reslease","renewLease").value == "other") {
      setVisDisp('renewalDetailsDiv',true);
   } else {
      setVisDisp('renewalDetailsDiv',false);
   }

   if (getFormObject('reslease','contractJuris').value != 'ON'&&((getFormObject("reslease","termType").value == "fixedDate")||(getFormObject("reslease","termType").value == "month")||(getFormObject("reslease","termType").value == "year"))) {
      setVisDisp('rerentLevyDiv',true);
   } else {
      setVisDisp('rerentLevyDiv',false);
   }

   if (getFormObject("reslease","rerentLevy")[0].checked == true) {
      setVisDisp('rerentLevyAmtDiv',true);
   } else {
      setVisDisp('rerentLevyAmtDiv',false);
   }

   condoDisplay();
   seeRoommate();
   propertyTypeQuestions();
   setVisDisp('guarantorTable', getFormObject('reslease', 'guarantor')[0].checked);
   possessionDateChange();
 }//End of Non-Australia specific controls

   var numClauses = getFormObject("reslease","additionalClauses").value;
   for(var i = 1; i<=_MAX_ADDITIONAL_CLAUSES; i++){
      setVisDisp('additionalClause'+i+'Div',i<=numClauses);
   }

   // Some extra stuff to do for the UK
   if(getFormObject("reslease", "contractCountry").value=="GB"){
      setDays("holidayLetStart");
      setDays("holidayLetEnd");
      setDays("studentLetStart");
      setDays("studentLetEnd");
      //setControlledTenancy();
      //setControlledTenancyType();
      setVisDisp('party1CorpDiv', getFormObject('reslease', 'party1Corp').value);
      setVisDisp('party1Corp1Div', getFormObject('reslease', 'party1Corp1').value && getFormObject('reslease', 'landlordNumber')[1].checked);
      setVisDisp('party2CorpDiv', getFormObject('reslease', 'party2Corp').value);
      var numTenants = getFormObject('reslease', 'tenantNumber').value;
      for(var i=1; i<8; ++i){
         setVisDisp('party2Corp'+i+'Div', i<numTenants && getFormObject('reslease', 'party2Corp'+i).value);
      }
      setVisDisp('guarantorCorpDiv', getFormObject('reslease', 'guarantorCorp').value && getFormObject('reslease', 'guarantor')[0].checked);
      setVisDisp('HMOSpan', getFormObject('reslease', 'HMO')[0].checked);
      setVisDisp("utilitiesShareDescDiv", getFormObject("reslease", "utilitiesShare")[0].checked);
      setVisDisp("holidayLetDiv", getFormObject("reslease", "holidayLet")[0].checked);
      setVisDisp("studentLetDiv", getFormObject("reslease", "studentLet")[0].checked);
      setVisDisp('assignLeaseDiv', getFormObject("reslease", "assignLease").value=='consent');
      setVisDisp('assignLeaseSpecifyDiv', getFormObject("reslease", "assignLeaseConsent")[0].checked);
      setVisDisp('depositInterestDiv', getFormObject("reslease", "depositInterest")[0].checked);
      setVisDisp('ratesAmtDiv', getFormObject("reslease", "rates")[0].checked);
      setVisDisp('agentDiv', getFormObject("reslease", 'agent')[0].checked);
   }
   else if (getFormObject("reslease", "contractCountry").value!="AU"){
      setVisDisp('homeBusinessDescDiv', getObject('homeBusinessYes').checked);
   }
} // End of function divdisplay()

function setTermLengthExample(){
   if(getFormObject("reslease", "contractJuris").value=="ENG" || getFormObject("reslease", "contractJuris").value=="WAL"){
      switch(getFormObject("reslease", "termType").value){
         case "week":
            getObject("termNumberExample").innerHTML = "Enter a number between 1 and 156";
            break;
         case "month":
            getObject("termNumberExample").innerHTML = "Enter a number between 1 and 36";
            break;
         case "year":
            getObject("termNumberExample").innerHTML = "Enter a number between 1 and 3";
            break;

    case "fort":
            getObject("termNumberExample").innerHTML = "Enter a number between 1 and 78";
            break;
      }
   }
   else{
      switch(getFormObject("reslease", "termType").value){
         case "week":
         case "month":
            getObject("termNumberExample").innerHTML = "(e.g. 10)";
            break;
         case "year":
            getObject("termNumberExample").innerHTML = "(e.g. 3)";
            break;
         case "fort":
       getObject("termNumberExample").innerHTML = "(e.g. 10)";
            break;
      }
   }
}

function checkTermLength(){
   warning = "";
   if(getFormObject("reslease", "contractCountry").value=="GB"){
      if(getFormObject("reslease", "contractJuris").value=="ENG" || getFormObject("reslease", "contractJuris").value=="WAL"){
         // Check if it is over three years.
         switch(getFormObject("reslease", "termType").value){
            case "week":
               if(getFormObject("reslease", "termNumber").value>156){
                  warning = "If you wish to enter into a tenancy for more than 3 years please contact a local solicitor to obtain a deed of lease.";
               }
               break;
            case "fort":
               if(getFormObject("reslease", "termNumber").value>78){
                  warning = "If you wish to enter into a tenancy for more than 3 years please contact a local solicitor to obtain a deed of lease.";
               }
               break;
            case "month":
               if(getFormObject("reslease", "termNumber").value>36){
                  warning = "If you wish to enter into a tenancy for more than 3 years please contact a local solicitor to obtain a deed of lease.";
               }
               break;
            case "year":
               if(getFormObject("reslease", "termNumber").value>3){
                  warning = "If you wish to enter into a tenancy for more than 3 years please contact a local solicitor to obtain a deed of lease.";
               }
               break;
            case "fixedDate":
               var start = Date.parse(getFormObject("reslease", "startMonth").value+"/"+getFormObject("reslease", "startDay").value+"/"+getFormObject("reslease", "startYear").value);
               var end = Date.parse(getFormObject("reslease", "termEndMonth").value+"/"+getFormObject("reslease", "termEndDay").value+"/"+getFormObject("reslease", "termEndYear").value);
               if((end-start)/(1000*60*60*24*365) > 3){
                  warning = "If you wish to enter into a tenancy for more than 3 years please contact a local solicitor to obtain a deed of lease.";
               }
               break;
         }
      }
      if(getFormObject("reslease", "contractJuris").value=="SCT"){
         // Check if it is under six months.
         warnStr = "Note: Unless this short assured tenancy follows immediately after another short assured tenancy of the same house (with the same tenant), it must be for at least 6 months.";
         switch(getFormObject("reslease", "termType").value){
            case "week":
               if(getFormObject("reslease", "termNumber").value<26){
                  warning = warnStr;
               }
               break;
            case "month":
               if(getFormObject("reslease", "termNumber").value<6){
                  warning = warnStr;
               }
               break;
            case "fixedDate":
               var start = Date.parse(getFormObject("reslease", "startMonth").value+"/"+getFormObject("reslease", "startDay").value+"/"+getFormObject("reslease", "startYear").value);
               var end = Date.parse(getFormObject("reslease", "termEndMonth").value+"/"+getFormObject("reslease", "termEndDay").value+"/"+getFormObject("reslease", "termEndYear").value);
               if((end-start)/(1000*60*60*24) < 180){
                  warning = warnStr;
               }
               break;
         }
      }
   }
   getObject("termWarning").innerHTML = warning;
   setVisDisp("termWarning", warning!="");
}

function possessionDateChange() {
   if (getFormObject("reslease", "possessionBefore").value == "yes") {
      setVisDisp("possessionDateDiv", true);
   }
   else {
      setVisDisp("possessionDateDiv", false);
   }
}

function condoDisplay() {
if(getFormObject("reslease", "contractCountry").value!="AU") {//////////////////
   if (getFormObject("reslease", "premisesType").value == "condo")
      setVisDisp("condoDiv", true);
   else
      setVisDisp("condoDiv", false);
   if (getFormObject("reslease", "condoFees")[0].checked) {
      setVisDisp("condoFeesPayerSpan1", true);
      setVisDisp("condoFeesPayerSpan2", true);
      setVisDisp("condoFeesPayerSpan3", true);
      if (getFormObject("reslease", "condoFeesPayer")[1].checked) { // If Tenant will be paying the condo fees
         setVisDisp("condoFeesExtraSpan1", true);
         setVisDisp("condoFeesExtraSpan2", true);
         setVisDisp("condoFeesExtraSpan3", true);
      } else {
         setVisDisp("condoFeesExtraSpan1", false);
         setVisDisp("condoFeesExtraSpan2", false);
         setVisDisp("condoFeesExtraSpan3", false);
      }
   } else {
      setVisDisp("condoFeesPayerSpan1", false);
      setVisDisp("condoFeesPayerSpan2", false);
      setVisDisp("condoFeesPayerSpan3", false);
      setVisDisp("condoFeesExtraSpan1", false);
      setVisDisp("condoFeesExtraSpan2", false);
      setVisDisp("condoFeesExtraSpan3", false);
   }
}
} //function condoDisplay()

/**
 * This function will display a link to the relevant law for jurisdiction
 */
function actNameLink() {
   actNameAndLink = new Array();
   actNameAndLink["AL"] = new Array("Ala. Code §§ 35-9-1 to -100", "http://www.legislature.state.al.us/CodeofAlabama/1975/68120.htm");
   actNameAndLink["AK"] = new Array("Alaska Stat. §§ 34.03.010 to .380","http://www.touchngo.com/lglcntr/akstats/Statutes/Title34/Chapter03.htm");
   actNameAndLink["AZ"] = new Array("Ariz. Rev. Stat. Ann. §§ 12-1171 to -1183; §§ 33-1301 to -1381", "http://www.azleg.state.az.us/ArizonaRevisedStatutes.asp?Title=12", "http://www.azleg.state.az.us/ArizonaRevisedStatutes.asp?Title=33");
   actNameAndLink["AR"] = new Array("Ark. Code Title 18, Subtitle 2, Chapter 16-17","http://www.lexisnexis.com/hottopics/arcode/Default.asp");
   actNameAndLink["CA"] = new Array("Cal. [Civ.] Code §§ 1940-1954.1, 1961-1962.7, 1995.010-1995.340, and 1997.010-1997.270","http://www.leginfo.ca.gov/.html/civ_table_of_contents.html");
   actNameAndLink["CO"] = new Array("Colo. Rev. Stat. §§ 38-12-101 to -104, -301 to -302; and §§ 38-45-101 to -106","http://www.michie.com/colorado/lpext.dll?f=templates&fn=main-h.htm&cp=");
   actNameAndLink["CT"] = new Array("Conn. Gen. Stat. Ann. §§ 47a-1 to -74","http://www.cga.ct.gov/2009/PUB/title47a.htm");
   actNameAndLink["DE"] = new Array("Del. Code. Ann. tit. 25, §§ 5101-7013, excluding chapter 61","http://delcode.delaware.gov/title25/index.shtml");
   actNameAndLink["DC"] = new Array("D.C. Code Ann. §§ 42-3201 to -4097, -3501.01 to -3509.03","http://www.michie.com/dc/lpext.dll?f=templates&fn=main-h.htm&cp=dccode");
   actNameAndLink["FL"] = new Array("Fla. Stat. Ann. §§ 83.40-.66","http://archive.flsenate.gov/Statutes/index.cfm?App_mode=Display_Statute&URL=0000-0099/0083/0083ContentsIndex.html&StatuteYear=2010&Title=-%3E2010-%3EChapter%2083");
   actNameAndLink["GA"] = new Array("Ga. Code Ann. §§ 44-7-1 to -81","http://www.lexisnexis.com/hottopics/gacode/Default.asp");
   actNameAndLink["HI"] = new Array("Haw. Rev. Stat. §§ 521-1 to -78","http://www.capitol.hawaii.gov/hrscurrent/vol12_ch0501-0588/hrs0521/hrs_0521-0001.htm");
   actNameAndLink["ID"] = new Array("Idaho Code §§ 6-301 to -324 and §§ 55-201 to -313","http://www.legislature.idaho.gov/idstat/TOC/IDStatutesTOC.htm");
   actNameAndLink["IL"] = new Array("Ill. Comp. Stat. ch. 765 para. 705/0.01-740/5","http://www.ilga.gov/legislation/ilcs/ilcs2.asp?ChapterID=62");
   actNameAndLink["IN"] = new Array("Ind. Code Ann. §§ 32-31-1-1 to 32-31-8-6","http://www.in.gov/legislative/ic/code/title32/ar31/");
   actNameAndLink["IA"] = new Array("Iowa Code Ann. §§ 562A.1-.36","http://www.legis.state.ia.us/IACODE/2003/562A/");
   actNameAndLink["KS"] = new Array("Kan. Stat. Ann. §§ 58-2501 to -2573","http://kansasstatutes.lesterama.org/Chapter_58/Article_25/");
   actNameAndLink["KY"] = new Array("Ky. Rev. Stat. Ann. §§ 383.010-.715","http://www.lrc.state.ky.us/KRS/383-00/CHAPTER.HTM");
   actNameAndLink["LA"] = new Array("La. Rev. Stat. Ann. §§ 9:3221-3252; La. Civ. Code Ann. art. 2669-2729", "http://www.legis.state.la.us/lss/lss.asp?folder=83", "http://www.legis.state.la.us/lss/lss.asp?folder=67");
   actNameAndLink["ME"] = new Array("Me. Rev. Stat. Ann. tit. 14, §§ 6001-6046","http://janus.state.me.us/legis/statutes/14/title14ch709sec0.html");
   actNameAndLink["MD"] = new Array("Md. Real Prop. Code Ann., §§ 8-101 to -604","http://www.michie.com/maryland/lpext.dll?f=templates&fn=main-h.htm&cp=");
   actNameAndLink["MA"] = new Array("Mass. Gen. Laws Ann. ch. 186 §§ 1-21","http://www.mass.gov/legis/laws/mgl/gl-186-toc.htm");
   actNameAndLink["MI"] = new Array("Mich. Comp. Laws Ann. § 554.601-.640","http://www.michiganlegislature.org/mileg.asp?page=getObject&objName=mcl-chap554");
   actNameAndLink["MN"] = new Array("Minn. Stat. Ann. §§ 504B.001 to 504B.471","http://www.revisor.leg.state.mn.us/stats/504B/");
   actNameAndLink["MS"] = new Array("Miss. Code Ann. §§ 89-8-1 to -27","http://www.mscode.com/free/statutes/89/008/index.htm");
   actNameAndLink["MO"] = new Array("Mo. Ann. Stat. §§ 441.005 to .880; and §§ 535.010-.300","http://www.moga.mo.gov/STATUTES/C441.HTM", "http://www.moga.mo.gov/STATUTES/C535.HTM");
   actNameAndLink["MT"] = new Array("Mont. Code Ann. §§ 70-24-101 to -25-206","http://data.opi.mt.gov/bills/mca_toc/70.htm");
   actNameAndLink["NE"] = new Array("Neb. Rev. Stat. §§ 76-1401 to -1449","http://uniweb.legislature.ne.gov/laws/browse-chapters.php?chapter=76");
   actNameAndLink["NV"] = new Array("Nev. Rev. Stat. Ann. §§ 118A.010-.520","http://www.leg.state.nv.us/NRS/NRS-118A.html");
   actNameAndLink["NH"] = new Array("N.H. Rev. Stat. Ann. §§ 540:1 to 540:29; 540-A:1-540-A:8; 540-B:1-10","http://www.gencourt.state.nh.us/rsa/html/NHTOC/NHTOC-LV.htm");
   actNameAndLink["NJ"] = new Array("N.J. Stat. Ann. §§ 46:8-1 to-49","http://lis.njleg.state.nj.us/cgi-bin/om_isapi.dll?clientID=33431844&Depth=4&TD=WRAP&advquery=landlord&headingswithhits=on&infobase=statutes.nfo&rank=&record={66D}&softpage=Q_Frame_Pg42&wordsaroundhits=2&x=0&y=0&zz=");
   actNameAndLink["NM"] = new Array("N.M. Stat. Ann. §§ 47-8-1 to -51", "http://www.nmlegis.gov/lcs/statutes.aspx");
   // New York is covered below as a special case, so it doesn't need to be in this array
      //actNameAndLink["NY"] = new Array("N.Y. Real Property Law (\"RPL\") §§ 220-238; Real Property Actions and Proceedings Law (\"RPAPL\") §§ 701-853; Multiple Dwelling Law (\"MDL\") all; Multiple Residence Law (\"MRL\") all; General Obligation Law (\"GOL\") §§ 7-103-108","http://assembly.state.ny.us/leg/?cl=99");
   actNameAndLink["NC"] = new Array("N.C. Gen. Stat. §§ 42-1 to 42-14.2; 42-25-6 to 42-76","http://www.ncga.state.nc.us/gascripts/Statutes/StatutesTOC.pl?Chapter=0042");
   actNameAndLink["ND"] = new Array("N.D. Cent. Code §§ 47-16-01 to -41","http://www.legis.nd.gov/cencode/T47C16.pdf");
   actNameAndLink["OH"] = new Array("Ohio Rev. Code Ann. §§ 5321.01-.19","http://codes.ohio.gov/orc/5321");
   actNameAndLink["OK"] = new Array("Okla. Stat. Ann. tit. 41, §§ 1-136","http://webserver1.lsb.state.ok.us/OK_Statutes/CompleteTitles/os41.rtf");
   actNameAndLink["OR"] = new Array("Or. Rev. Stat. §§ 90.100-.450","http://www.leg.state.or.us/ors/090.html");
   actNameAndLink["PA"] = new Array("Pa. Stat. Ann. tit. 68, Chapter 8, §§ 250.101-.510-B","http://government.westlaw.com/linkedslice/default.asp?li={1F4D2D3D-4FA8-4F8A-AE76-D887EDC8DE95}&RS=GVT1.0&VR=2.0&SP=pac-1000");
   actNameAndLink["RI"] = new Array("R.I. Gen. Laws §§ 34-18-1 to -57","http://www.rilin.state.ri.us/Statutes/TITLE34/34-18/INDEX.HTM");
   actNameAndLink["SC"] = new Array("S.C. Code Ann. §§ 27-40-10 to -940","http://www.scstatehouse.gov/code/t27c040.htm");
   actNameAndLink["SD"] = new Array("S.D. Codified Laws Ann. §§ 43-32-1 to -29","http://legis.state.sd.us/statutes/DisplayStatute.aspx?Type=Statute&Statute=43-32");
   actNameAndLink["TN"] = new Array("Tenn. Code Ann. §§ 66-28-101 to -520","http://www.michie.com/tennessee/lpext.dll?f=templates&fn=main-h.htm&cp=tncode");
   actNameAndLink["TX"] = new Array("Tex. Prop. Code Ann. §§ 91.001-92.354","http://www.statutes.legis.state.tx.us/Docs/PR/pdf/PR.91.pdf", "http://www.statutes.legis.state.tx.us/Docs/PR/pdf/PR.92.pdf");
   actNameAndLink["UT"] = new Array("Utah Code Ann. §§ 57-17-1 to -5, -22-1 to -6","http://www.le.state.ut.us/~code/TITLE57/TITLE57.htm");
   actNameAndLink["VT"] = new Array("Vt. Stat Ann. tit. 9, §§ 4451-4468","http://www.leg.state.vt.us/statutes/sections.cfm?Title=09&Chapter=137");
   actNameAndLink["VA"] = new Array("Va. Code Ann. §§ 55-218.1 to -248.40","http://leg1.state.va.us/cgi-bin/legp504.exe?000+cod+TOC55000000013000000000000");
   actNameAndLink["WA"] = new Array("Wash. Rev. Code Ann. §§ 59.04.010-.900, .18.010-.911","http://search.leg.wa.gov/wslrcw/RCW%20%2059%20%20TITLE/RCW%20%2059%20.%2018%20%20CHAPTER/RCW%20%2059%20.%2018%20%20chapter.htm");
   actNameAndLink["WU"] = new Array("W. Va. Code §§ 37-6-1 to -30","http://www.legis.state.wv.us/WVCODE/Code.cfm?chap=37&art=6#06");
   actNameAndLink["WI"] = new Array("Wis. Stat. Ann. §§ 704.01-.45","http://folio.legis.state.wi.us/cgi-bin/om_isapi.dll?clientID=50140902&infobase=stats.nfo&j1=704.01&jump=704.01&softpage=Browse_Frame_Pg");
   actNameAndLink["WY"] = new Array("Wyo. Stat. §§ 1-21-1201 to -1211; 34-2-128 to -129", "http://michie.lexisnexis.com/wyoming/lpext.dll?f=templates&fn=main-h.htm");

   actNameAndLink["AB"] = new Array("the Residential Tenancies Act", "http://www.canlii.org/en/ab/laws/stat/sa-2004-c-r-17.1/latest/sa-2004-c-r-17.1.html");
   actNameAndLink["BC"] = new Array("the Residential Tenancy Act, Chapter 78 (SBC 2002)", "http://www.qp.gov.bc.ca/statreg/stat/R/02078_01.htm");
   actNameAndLink["SK"] = new Array("the Residential Tenancies Act, 2006, Ch. R-22.0001, S.S. 2006", "http://www.qp.gov.sk.ca/documents/english/Chapters/2006/R22-0001.pdf");
   actNameAndLink["MB"] = new Array("the Residential Tenancies Act, C.C.S.M. c. R119", "http://www.canlii.org/mb/laws/sta/r-119/index.html");
   actNameAndLink["ON"] = new Array("the Residential Tenancies Act, 2006, S.O. 2006, Chapter 17", "http://www.canlii.org/on/laws/sta/2006c.17/index.html");
   actNameAndLink["NB"] = new Array("the Residential Tenancies Act", "http://www.canlii.org/nb/laws/sta/r-10.2/index.html");
   actNameAndLink["NS"] = new Array("1989 Revised Statutes, ch. 401, Residential Tenancies Act", "http://nslegislature.ca/legc/statutes/resident.htm");
   actNameAndLink["PE"] = new Array("the Rental of Residential Property Act, ch. R-13.1", "http://www.canlii.org/pe/laws/sta/r-13.1/index.html");
   actNameAndLink["NF"] = new Array("SNL2000 Chapter R-14.1, Residential Tenancies Act, 2000", "http://www.canlii.org/nl/laws/sta/r-14.1/index.html");
   actNameAndLink["YT"] = new Array("the Landlord and Tenants Act, R.S.Y. 2002, Ch. 131", "http://www.gov.yk.ca/legislation/acts/late.pdf");
   actNameAndLink["NT"] = new Array("Residential Tenancies, R.S.N.W.T. 1988, c. R-5", "http://www.canlii.org/nt/laws/sta/r-5/20041110/whole.html");
   actNameAndLink["NU"] = new Array("the Residential Tenancies Act (Nunavut), R.S.N.W.T. 1988, c.R-5", "http://www.canlii.org/nu/laws/sta/r-5/20070904/whole.html");

   actNameAndLink["AU_ACT"] = new Array("the Residential Tenancies Act, 1997", "http://www.legislation.act.gov.au/a/1997-84/current/pdf/1997-84.pdf");
   actNameAndLink["AU_NSW"] = new Array("the Residential Tenancies Act, 1987", "http://www.legislation.nsw.gov.au/maintop/scanact/inforce/NONE/0");
   actNameAndLink["AU_NT"] = new Array("the Residential Tenancies Act", "http://notes.nt.gov.au/dcm/legislat/legislat.nsf/d989974724db65b1482561cf0017cbd2?OpenView");
   actNameAndLink["AU_QLD"] = new Array("the Residential Tenancies Act, 1994", "http://www.legislation.qld.gov.au/Acts_SLs/Acts_SL_R.htm");
   actNameAndLink["AU_SA"] = new Array("the Residential Tenancies Act, 1995", "http://www.legislation.sa.gov.au/LZ/C/A/RESIDENTIAL%20TENANCIES%20ACT%201995/CURRENT/1995.63.UN.PDF");
   actNameAndLink["AU_TAS"] = new Array("the Residential Tenancy Act, 1997", "http://www.thelaw.tas.gov.au/tocview/index.w3p;cond=;doc_id=82%2B%2B1997%2BAT%40EN%2B20061230050000;histon=;prompt=;rec=;term=");
   actNameAndLink["AU_VIC"] = new Array("the Residential Tenancies Act, 1997", "http://www.legislation.vic.gov.au/Domino/Web_Notes/LDMS/LTObject_Store/LTObjSt5.nsf/DDE300B846EED9C7CA257616000A3571/ECD74A4F9E870913CA25781C0015F8EA/$FILE/97-109aa055%20authorised.pdf");
   actNameAndLink["AU_WA"] = new Array("the Residential Tenancies Act, 1987", "http://www.slp.wa.gov.au/statutes/swans.nsf/5d62daee56e9e4b348256ebd0012c422/880066e78c7b25ec482565da0020d741/$FILE/Residential%20Tenancies%20Act%201987.PDF");


   spanString = "";

   jurisdictionCode = getFormObject("reslease", "contractJuris").value;

   if (jurisdictionCode == "NY")
   {
      setVisDisp("lawInfoSpan", true);
      spanString += "The relevant legislation for the tenancy created by this Agreement is "
            + "<a href=\"http://tenant.net/Other_Laws/RPL/rpltoc.html\" target=\"_blank\">N.Y. Real Property Law</a> (\"RPL\") §§ 220-238; "
            + "<a href=\"http://tenant.net/Other_Laws/RPAPL/rpapltoc.html\" target=\"_blank\">Real Property Actions and Proceedings Law</a> (\"RPAPL\") §§; "
            + "<a href=\"http://www.tenant.net/Other_Laws/MDL/mdltoc.html\" target=\"_blank\">Multiple Dwelling Law</a> (\"MDL\") all; "
            + "<a href=\"http://law.justia.com/newyork/codes/multiple-residence/index.html\" target=\"_blank\">Multiple Residence Law</a> (\"MRL\") all; "
            + "<a href=\"http://law.justia.com/newyork/codes/general-obligations/idx_gob0a7t1.html\" target=\"_blank\">General Obligation Law</a> (\"GOL\") §§ 7-103-108.";

   }
   else if(getFormObject("reslease", "contractCountry").value=="AU") {
      ausjurisdictionCode = "AU_" + jurisdictionCode;
      codeArray = actNameAndLink[ausjurisdictionCode];
      if (codeArray != null) {
         setVisDisp("lawInfoSpan", true);

       spanString = "The relevant legislation for the tenancy created by this Agreement is " + codeArray[0] + ".";
         if (codeArray[1] != null && codeArray[1] != "") {
            spanString += " If you would like to review the actual provisions of this legislation, <a href=\"" + codeArray[1] + "\" target=\"_blank\">click here</a>";
            for(i=2; i<codeArray.length; ++i){
               if (codeArray[i] != null && codeArray[i] != ""){
                  if(i==codeArray.length-1){
                     spanString += " and ";
                  }
                  else{
                     spanString += ", ";
                  }
                  spanString += "<a href=\"" + codeArray[i] + "\" target=\"_blank\">click here</a>";
               }
            }
            spanString += ".";

         }
         //show the Note disclaimer if user selects New South Wales
         if (ausjurisdictionCode == "AU_NSW")
            { setVisDisp("NSW_Note",true);}
         else
            { setVisDisp("NSW_Note",false);}
      }
      else
         setVisDisp("lawInfoSpan", false);
   } // end of australia
   else{
      codeArray = actNameAndLink[jurisdictionCode];
      if (codeArray != null) {
         setVisDisp("lawInfoSpan", true);
         spanString = "The relevant legislation for the tenancy created by this Agreement is " + codeArray[0] + ".";
         if (codeArray[1] != null && codeArray[1] != "") {
            spanString += " If you would like to review the actual provisions of this legislation, <a href=\"" + codeArray[1] + "\" target=\"_blank\">click here</a>";
            for(i=2; i<codeArray.length; ++i){
               if (codeArray[i] != null && codeArray[i] != ""){
                  if(i==codeArray.length-1){
                     spanString += " and ";
                  }
                  else{
                     spanString += ", ";
                  }
                  spanString += "<a href=\"" + codeArray[i] + "\" target=\"_blank\">click here</a>";
               }
            }

            spanString += ".";

         }
      }
      else
         setVisDisp("lawInfoSpan", false);

   } // end of != New York

   getObject("lawInfoSpan").innerHTML = spanString;
}


/*
 * In certain circumstances, the user should be referred to our roommate agreement.
 */
function seeRoommate() {
   premType = getFormObject("reslease", "premisesType").value;
   if (  (premType == "suite") || (premType == "room") || premType=="houseshare" || premType == "flatshare" ) {
      setVisDisp("referToRoommate", true);
   }
   else {
      setVisDisp("referToRoommate", false);
   }
}

/*
 * This function is a result of the updates implemented January 2005.
 * It be called in DivDisplay, as well as when the province is changed or the premisesType is changed.
 */
function propertyTypeQuestions() {
   countryCode = getFormObject("reslease", "contractCountry").value;
   jurisdictionCode = getFormObject("reslease", "contractJuris").value;
   premType = getFormObject("reslease", "premisesType").value;

   terminationDisplay = true;

   canadaSpecialDisplay = false;
   specialYesDisplay = false;
   specialNoDisplay = false;
   specialNoDisplay2 = false;
   specialNoDisplay3 = false;

   propertyOwnerWording = "";
   specialYesWording = "";
   specialNoWording = "";
   specialNoWording2 = "";
   specialNoWording3 = "";

   attorneyFeesDisplay = true;
   attorneyFeesAlternateDisplay = false;
   attorneyFeesHawaiiDisplay = false;

   if ( (jurisdictionCode == "BC") && ( (premType == "suite") || (premType == "room") ) ) {
      propertyOwnerWording = "Will the Tenant be sharing a bathroom or kitchen with the property owner?";
      canadaSpecialDisplay = true;
   }
   else if ( ( (jurisdictionCode == "AB") || (jurisdictionCode == "SK") ) && ( (premType == "suite") || (premType == "room") ) ) {
      propertyOwnerWording = "Will the Tenant be sharing a bathroom, living room, kitchen, or other vital living quarters with the owner of the property?";
      canadaSpecialDisplay = true;
   }
   else if ( (jurisdictionCode == "ON") && ( (premType == "suite") || (premType == "room") ) ) {
      propertyOwnerWording = "Will the Tenant be sharing a bathroom or kitchen facility with the owner, the owner's spouse, child, or parent?";
      canadaSpecialDisplay = true;
   }
   else if ( (jurisdictionCode == "NF") && ( (premType == "suite") || (premType == "room") ) ) {
      propertyOwnerWording = "Will the Tenant be sharing a bathroom or kitchen with the property owner?";
      canadaSpecialDisplay = true;
   }

   if (jurisdictionCode == "SK") {
      specialYesWording = "Do you live within a 5 mile radius of any city, town, village, or hamlet?";
      specialYesDisplay = true;
   }
   else if (jurisdictionCode == "ON") {
      specialNoWording = "Is the occupancy conditional upon the tenant being employed on a farm?";
      specialNoDisplay = true;
   }
   else if (jurisdictionCode == "PE") {
      specialNoWording = "Is the residence normally occupied by the owner for more than 5 months of the year?";
      specialNoDisplay = true;
   }
   else if (jurisdictionCode == "NF") {
      specialNoWording = "Does the owner provide meals or bed linens?";
      specialNoDisplay = true;
   }
   else if ( (jurisdictionCode == "AK") || (jurisdictionCode == "AZ") || (jurisdictionCode == "IN") || (jurisdictionCode == "IA") || (jurisdictionCode == "KS") || (jurisdictionCode == "KY") || (jurisdictionCode == "MT") || (jurisdictionCode == "NE") || (jurisdictionCode == "NV") || (jurisdictionCode == "NM") || (jurisdictionCode == "OR") || (jurisdictionCode == "SC") || (jurisdictionCode == "VA") || (jurisdictionCode == "WA") ) {

      if (jurisdictionCode == "MT")
         specialNoWording = "Is the occupancy primarily for commercial or agricultural purposes?";
      else
         specialNoWording = "Is the occupancy primarily for agricultural purposes?";

      specialNoDisplay = true;

      if ( (jurisdictionCode == "WA") && (getFormObject("reslease", "specialNo2").value == "no") ) {
         specialNoWording3 = "Is the Tenant a seasonal worker whose tenancy will terminate when he is no longer employed by the owner?";
         specialNoDisplay3 = true;
      }
      else {
         attorneyFeesDisplay = false;
      }


      specialNoWording2 = "Is the Tenant the custodian or manager of the property?";
      specialNoDisplay2 = true;

      if (getFormObject("reslease", "specialNo2").value == "yes")
         terminationDisplay = false;

      if ( (jurisdictionCode == "WA") && (getFormObject("reslease", "specialNo3").value == "yes") ) {
         terminationDisplay = false;
      }

   }
   else if ( (jurisdictionCode == "CT") || (jurisdictionCode == "DE") || (jurisdictionCode == "FL") || (jurisdictionCode == "MI") || (jurisdictionCode == "TX") || (jurisdictionCode == "WI") ) {
      attorneyFeesDisplay = false;
   }
   else if ( (jurisdictionCode == "GA") || (jurisdictionCode == "VT") ) {
      attorneyFeesDisplay = false;
      attorneyFeesAlternateDisplay = true;
   }
   else if (jurisdictionCode == "HI") {
      attorneyFeesDisplay = false;
      attorneyFeesHawaiiDisplay = true;

      specialNoWording2 = "Is the Tenant the custodian or manager of the property?";
      specialNoDisplay2 = true;

      if (getFormObject("reslease", "specialNo2").value == "yes")
         terminationDisplay = false;
   }
   else if (jurisdictionCode == "RI") {
      attorneyFeesDisplay = false;

      specialNoWording2 = "Is the Tenant the custodian or manager of the property and is there more than 11 rental units?";
      specialNoDisplay2 = true;

      if (getFormObject("reslease", "specialNo2").value == "yes")
         terminationDisplay = false;
   }
   else if (jurisdictionCode == "MS") {
      specialNoWording = "Is the occupant a farm laborer for the owner of the property and is renting for less than market value?";
      specialNoDisplay = true;
   }
   else if ( (jurisdictionCode == "NH") && ( (premType == "suite")|| (premType == "room") ) ) {
      specialNoWording = "Will the tenant be sharing a bathroom, living room, kitchen, or other vital living quarters with the owner of the property?";
      specialNoDisplay = true;
   }
   else if (jurisdictionCode == "OH") {
      specialNoWording = "Is the rental agreement for 2 or more acres of agricultural land to be worked by the occupants?";
      specialNoDisplay = true;

      attorneyFeesDisplay = false;
      attorneyFeesAlternateDisplay = true;
   }
   else if (jurisdictionCode == "OK") {
      specialNoWording = "Is the occupancy primarily for agricultural purposes?";
      specialNoDisplay = true;

      attorneyFeesDisplay = false;
   }
   else if (jurisdictionCode == "TN") {
      specialYesWording = "Do you live in the county of Davidson, Hamilton, Knox, or Shelby?";
      specialYesDisplay = true;

      attorneyFeesDisplay = false;
   }

   setVisDisp("attorneyFeesDiv", attorneyFeesDisplay);
   setVisDisp("attorneyFeesHawaiiDiv", attorneyFeesHawaiiDisplay);
   setVisDisp("attorneyFeesAlternateDiv", attorneyFeesAlternateDisplay);
   setVisDisp('shortHoldTenancyNoteEngWales',(premType == "house" || premType == "flat")&&(countryCode == "GB")&&(jurisdictionCode == "ENG" || jurisdictionCode == "WAL"));//RED
   setVisDisp('shortHoldTenancyNoteSCT',(premType == "house" || premType == "flat")&&(countryCode == "GB")&&(jurisdictionCode == "SCT"));//RED
if(dbcountry != 'AU') { //////////////////
   setVisDisp("terminationDiv", terminationDisplay);
}

   getObject("shareWithPropertyOwnerSpan").innerHTML = propertyOwnerWording;
   setVisDisp("CanadaSpecial", canadaSpecialDisplay);

   getObject("specialYesSpan").innerHTML = specialYesWording;
   setVisDisp("specialYesDiv", specialYesDisplay);

   getObject("specialNoSpan").innerHTML = specialNoWording;
   setVisDisp("specialNoDiv", specialNoDisplay);

   getObject("specialNoSpan2").innerHTML = specialNoWording2;
   setVisDisp("specialNoDiv2", specialNoDisplay2);

   getObject("specialNoSpan3").innerHTML = specialNoWording3;
   setVisDisp("specialNoDiv3", specialNoDisplay3);
   // UK Jurisdictions
   if (countryCode == "GB"){
      checkTermLength();
      setTermLengthExample();
      setTermination();
      setVisDisp("utilitiesShareDiv", premType == "houseshare" || premType == "flatshare" || premType=="room" || premType=="other");

      setVisDisp('landlordShareNote', jurisdictionCode != 'NIR' && premType=='room' && getFormObject('reslease', 'landlordShare')[1].checked);
      if(jurisdictionCode == "ENG" || jurisdictionCode == "WAL"){
         getObject('landlordShareNote').innerHTML = "You are creating an assured shorthold tenancy.  An assured shorthold tenancy agreement provides the tenant with greater protection from eviction than a house/flat share agreement.  If you wish to create an agreement which allows the tenant and landlord to end the tenancy more quickly select House Share or Flat Share.";
      }
      else if(jurisdictionCode == "SCT"){
         getObject('landlordShareNote').innerHTML = "You are creating a short assured tenancy.  A short assured tenancy agreement provides the tenant with greater protection from eviction than a house/flat share agreement.  If you wish to create an agreement which allows the tenant and landlord to end the tenancy more quickly select House Share or Flat Share.";
      }
      setTermType();

      setVisDisp('improvementsLabel', jurisdictionCode!='NIR');
      setVisDisp('repairsLabel', jurisdictionCode=='NIR');
      setVisDisp('improvementsTenantLabel', jurisdictionCode!='NIR');
      setVisDisp('repairsTenantLabel', jurisdictionCode=='NIR');
      if(jurisdictionCode=="NIR"){
         getObject('improvementTenantDescLabel').innerHTML = "Terms Regarding Tenant Performing Repairs:";
         getObject('tenantImprovementsTitle').innerHTML = "<span>Tenant Repairs</span>";
         getObject('landlordImprovementsTitle').innerHTML = "<span>Landlord Repairs and Signing Incentives</span>";
         getObject('improvementDescLabel').innerHTML = "Description of Landlord Repairs Required:";
         getObject('taxesLabel').innerHTML = "Other taxes payable by Tenant?";
         getObject('noticeNoCauseExample').innerHTML = "(e.g.&nbsp;4 weeks)";
      }
      else{
         getObject('improvementTenantDescLabel').innerHTML = "Terms Regarding Tenant Performing Improvements:";
         getObject('tenantImprovementsTitle').innerHTML = "<span>Tenant Improvements</span>";
         getObject('landlordImprovementsTitle').innerHTML = "<span>Landlord Improvements and Signing Incentives</span>";
         getObject('improvementsLabel').innerHTML = "Required Landlord Improvements:";
         getObject('improvementDescLabel').innerHTML = "Description of Landlord Improvements Required:";
         getObject('taxesLabel').innerHTML = "Taxes payable by Tenant?";
         getObject('noticeNoCauseExample').innerHTML = "(e.g.&nbsp;30 days, one month, etc.)";
      }
      setVisDisp('rentBookDiv', jurisdictionCode=='NIR');
      setVisDisp('minNoticeDiv', jurisdictionCode=='NIR');
      setVisDisp('irelandTerminationDiv', jurisdictionCode!="NIR");
      setVisDisp('ratesDiv', jurisdictionCode=="NIR");
      setVisDisp("assignLeaseNIRWarn", jurisdictionCode=="NIR");
      //setVisDisp("irelandJurisDiv", jurisdictionCode=="NIR");
      setVisDisp("engWalMisc", jurisdictionCode=="ENG" || jurisdictionCode=="WAL");
      setVisDisp("englandDepositDiv", jurisdictionCode=="ENG" || jurisdictionCode=="WAL");
      if(jurisdictionCode=="ENG" || jurisdictionCode=="WAL"){
         getStyleObject("serviceChannelsRow").display = "";
      }
      else{
         getStyleObject("serviceChannelsRow").display = "none";
      }
   }
}

// Sets up the options for the term type select box.
function setTermType(){
   countryCode = getFormObject("reslease", "contractCountry").value;
   jurisdictionCode = getFormObject("reslease", "contractJuris").value;
   premisesType = getFormObject("reslease", "premisesType").value;
   landlordShare = getFormObject("reslease", "landlordShare")[0].checked;
   termType = getFormObject("reslease", "termType");
   if(countryCode == "GB"){
      // In Scotland if the landlord is not a resident for a room then don't allow for automatic renewel.
      if(jurisdictionCode=="SCT" && (premisesType=='house' || premisesType=='flat' || (!landlordShare && premisesType == "room"))){
         // Make sure the selected index is valid.
         if (termType.selectedIndex > 3){
            termType.selectedIndex = termType.selectedIndex - 3;
         }

         // Remove the extra options.
         while(termType.options.length > 4){
            termType.options[4] = null;
         }

      }
      else{

         if (termType.options.length < 8){
            // If the automatic renewal options have been removed, re add them.
            termType.options[4] = new Option("Weekly with Automatic Renewal", "weekly");
            termType.options[5] = new Option("Fortnightly with Automatic Renewal", "fortly");
            termType.options[6] = new Option("Monthly with Automatic Renewal", "monthly");
            termType.options[7] = new Option("Yearly with Automatic Renewal", "yearly");
         }
      }
   }
}

// Adds and removes the "Do not specify" option from the termination drop down.
function setTermination(){
   countryCode = getFormObject("reslease", "contractCountry").value;
   jurisdictionCode = getFormObject("reslease", "contractJuris").value;
   premisesType = getFormObject("reslease", "premisesType").value;
   landlordShare = getFormObject("reslease", "landlordShare")[0].checked;
   termination = getFormObject("reslease", "termination");
   if(countryCode == 'GB' || countryCode == 'AU'){
      selectedValue = termination.value;
      termination.options[0] = new Option("Do Not Specify", "dns");
      termination.options[1] = new Option("Use the Legal Minimum", "legal");
      termination.options[2] = new Option("Specify the Notice Period", "specify");
      if(jurisdictionCode == "NIR"){
         // Remove "Do not specify"
         termination.options[0] = null;
      }
      else if(jurisdictionCode=="SCT" && (premisesType=='house' || premisesType=='flat' || (!landlordShare && premisesType == "room"))){
         // Remove "Specify the Notice Period"
         termination.options[2] = null;
      }
      termination.selectedIndex = 0;
      for(i=termination.options.length-1; i>=0; --i){
         if(termination.options[i].value == selectedValue){
            termination.selectedIndex = i;
            break;
         }
      }
   }
}

// Sets up the controlled Tenenacy stuff for Northern Ireland.
// function setControlledTenancy(){
//   if(getFormObject("reslease", "contTen")[0].checked){
//      setVisDisp("irelandContTenDiv", true);
//      setVisDisp("irelandContTenPar", true);
//      setVisDisp("irelandUncontTenPar", false);
//   }
//   else{
//      setVisDisp("irelandContTenDiv", false);
//      setVisDisp("irelandContTenPar", false);
//      setVisDisp("irelandUncontTenPar", true);
//   }
//}

//function setControlledTenancyType(){
//   switch(getFormObject("reslease", "contTenType").value){
//      case "restricted":
//         getObject("contTenTypePar").innerHTML = "Restricted Tenancies are properties generally in a poor state of repair with Net Annual Value (NAV) less than &#163;60 and rent frozen at the 1978 level (usually less than &#163;1.00 per week).";
//         break;
//      case "regulated":
//         getObject("contTenTypePar").innerHTML = "Regulated Tenancies are properties where rent cannot be increased above the level payable in 1978 unless it has been registered with the Housing Executive. The rent payable is set using a formula provided in law.";
//         break;
//      case "protected":
//         getObject("contTenTypePar").innerHTML = "Protected Shorthold Tenancies are a form of protected tenancy where the initial term of the tenancy is limited to between 1 and 5 years. The rent must be registered with the Housing Executive."
//         break;
//   }
//}

/*
 * This function is used to change the "default" value of certain options.
 * It MUST NOT be called in DivDisplay
 */
function defaultChange() {
   jurisdictionCode = getFormObject("reslease", "contractJuris").value;
   premType = getFormObject("reslease", "premisesType").value;
   termSelect = getFormObject("reslease", "termination");

   if (jurisdictionCode == "BC") {
      if ( (premType == "other") || ( ( (premType == "room") || (premType == "suite")) && (getFormObject("reslease", "shareWithPropertyOwner").value == "yes") ) ) {
         termSelect.selectedIndex = 2;
      }
      else {
         termSelect.selectedIndex = 0;
      }
   }
   else if ( (jurisdictionCode == "AB") || (jurisdictionCode == "SK") || (jurisdictionCode == "ON") || (jurisdictionCode == 'NF')) {
      if ( ( (premType == "room") || (premType == "suite")) && (getFormObject("reslease", "shareWithPropertyOwner").value == "yes") ) {
         termSelect.selectedIndex = 2;
      }
      else if ( (jurisdictionCode == "SK") && (getFormObject("reslease", "specialYes").value == "no") )
         termSelect.selectedIndex = 2;
      else if ( (jurisdictionCode == "ON" || jurisdictionCode == 'NF') && (getFormObject("reslease", "specialNo").value == "yes") )
         termSelect.selectedIndex = 2;
      else {
         termSelect.selectedIndex = 0;
      }
   }
   else if ( ( (jurisdictionCode == "PE") || (jurisdictionCode == "AK") || (jurisdictionCode == "AZ") || (jurisdictionCode == "IN") || (jurisdictionCode == "IA") || (jurisdictionCode == "KS") || (jurisdictionCode == "KY") || (jurisdictionCode == "MS") || (jurisdictionCode == "MT") || (jurisdictionCode == "NE") || (jurisdictionCode == "NV") || (jurisdictionCode == "NH") || (jurisdictionCode == "NM") || (jurisdictionCode == "OH") || (jurisdictionCode == "OK") || (jurisdictionCode == "OR") || (jurisdictionCode == "SC") || (jurisdictionCode == "VA") || (jurisdictionCode == "WA") ) && (getFormObject("reslease", "specialNo").value == "yes") ) {
      termSelect.selectedIndex = 2;
   }
   else if ( (jurisdictionCode == "TN") && (getFormObject("reslease", "specialYes").value == "no") ) {
      termSelect.selectedIndex = 2;
   }
   else {
      termSelect.selectedIndex = 0;
   }

   divdisplay(); // This is necessary since when we change a select box in JavaScript, its onChange method is not called.
}

function checkInput() {
   return true;
}
function checkInput() {
   var checkInputReturn = true;
   var fo = getFormObject('reslease','contractJuris');
   var so = getStyleObject('jurisHelpText');
   if(fo.type == "select-one" && fo.selectedIndex < 1) {
      so.color = "#FF0000";
      setVisDisp('jurisHelpText',true);
      getFormObject('reslease','contractJuris').focus();
      checkInputReturn = false;
   } else {
      setVisDisp('jurisHelpText',false);
   }

   return checkInputReturn;
}

// This function returns true if the event is a keypress of 0-9 or a .
function onlyNumeric(event) {
   var strUserAgent = navigator.userAgent.toLowerCase();
   var isIE = strUserAgent.indexOf("msie") > -1;
   if(isIE)
      iKeyCode = event.keyCode;
   else
      iKeyCode = event.which;
   if(
         (iKeyCode >= 32 && iKeyCode <= 45) ||
         (iKeyCode == 47) ||
         iKeyCode >= 58
     )
     return false;
   return true;

}

function purchaseOption() {
   premType = getFormObject('reslease', 'premisesType').value;
      if(dbcountry == 'US' || dbcountry == 'CA') {
         if (premType =='room' || premType =='suite') {
            getFormObject("reslease","optionPurchaseYN")[0].checked=false;
            getFormObject("reslease","optionPurchaseYN")[1].checked=true;
            setVisDisp('PurchaseLeaseUS_CA',false);
         } else {
            setVisDisp('PurchaseLeaseUS_CA',true);
            setVisDisp('selPurchasePrice',getFormObject("reslease","optionPurchaseYN")[0].checked);
            setVisDisp('divSpecifyPrice',getFormObject("reslease", "ddlPurchasePrice").value=='specify');
            setVisDisp('divOptionFee',getFormObject("reslease", "optionFeeYN")[0].checked);
            setVisDisp('divSpecifiedDate',getFormObject("reslease","ddlOptionExp").value=='specify');
         }
      } else {
         setVisDisp('PurchaseLeaseUS_CA',false);
   }
}

