//document.onselectstart = new Function( "return false");

var toolTip1  = "The Commissioner of Land Tax calculates land tax assessments based on the total relevant unimproved value of the land. An explanation detailing how the relevant unimproved value is determined is included on this website.";

// Initialize arrays.

// Initialize objects

var oCalculator = null;

var oReport     = null;


function frmCalcResult()
{
    oCalculator.reset();
        
    var oForm = document.forms.frmLTAXEstimator;
        
	if (oCalculator == null || oCalculator == "" || typeof(oCalculator) == "undefined") {
	
	   alert("A calculator instance has not been created!");
	   return;
	}	
		
	if (oForm.indChkBx.checked == true) {
		//alert("ot: 1");
		oCalculator.putOwnerType(1);
	}
		
	if (oForm.ctChkBx.checked == true){
		//alert("ot: 2");
		oCalculator.putOwnerType(2);
	}
		
	if (oForm.absenteeChkBx.checked == true){
		//alert("ot: 3");
		oCalculator.putOwnerType(3);
	}
		
	oCalculator.putTotUnImprovedValue1(oForm.totUnImprovedValue1.value);
    oCalculator.putTotUnImprovedValue2(oForm.totUnImprovedValue2.value);
    
    // note: this value is calculated in calc object
//    oCalculator.putTotUnImprovedValue3(oForm.totUnImprovedValue3.value);
            
    if (oCalculator.isValid() == false) {
    
        alert(oCalculator.getErrorText());
        
        if ( oCalculator.isOwnerTypeValid () == false) { 
             oForm.indChkBx.focus();
        }
       
        if ( oCalculator.isTotUnImprovedValue1Valid () == false) { 
             oForm.totUnImprovedValue1.focus();
        }
                        
        return;
    }
     
    if (oCalculator.calculate() == false) {
    
        alert(oCalculator.getErrorText());
        return;
    }
    
    oForm.totUnImprovedValue3.value = utilities_dollarformat( oCalculator.calcTotUnImprovedValue3());
    
    oForm.ltaxPayable.value = utilities_dollarformat( oCalculator.getLTAXPayable());
}    

function frmLoad()
{    	
  document.frmLTAXEstimator.reset();
  document.frmLTAXEstimator.indChkBx.focus();
}

function frmReset(){
        
  document.frmLTAXEstimator.reset();

  oCalculator.reset();

  document.frmLTAXEstimator.totUnImprovedValue2.disabled = false;
  
  document.frmLTAXEstimator.indChkBx.focus();
}

function frmCreateToolTip()
{
  createTooltip();
}

function frmReport()
{
   if (oCalculator.isValidCalculation() == false) {
       alert("A report cannot be produced prior to a valid calculation being completed");
       return;
   }
       
   hideElementArray = new Array( 1);
       
   hideElementArray[0] = "divLTAXEstimatorFrm";
            
   oReport.show(hideElementArray);
}

function frmCreateReport()
{
  oReport = new Report("Land Tax Estimator Calculation Report", "LTAXEstimatorCalc", oCalculator);
}


function frmCreateCalculator()
{
  oCalculator = new LTAXEstimator(); 
}

function frmInit()
{
  frmLoad();
   
  frmCreateToolTip();
 
  frmCreateCalculator();

  frmCreateReport();
}

function frmToggleChkBox1()
{
  document.frmLTAXEstimator.indChkBx.checked = true;
  
  document.frmLTAXEstimator.ctChkBx.checked = false;
  document.frmLTAXEstimator.absenteeChkBx.checked = false;

  document.frmLTAXEstimator.totUnImprovedValue2.disabled = false;

}

function frmToggleChkBox2()
{
  document.frmLTAXEstimator.ctChkBx.checked = true;
  
  document.frmLTAXEstimator.indChkBx.checked = false;
  document.frmLTAXEstimator.absenteeChkBx.checked = false;

  document.frmLTAXEstimator.totUnImprovedValue2.disabled = false;

}

function frmToggleChkBox3()
{
  document.frmLTAXEstimator.absenteeChkBx.checked = true;

  document.frmLTAXEstimator.indChkBx.checked = false;
  document.frmLTAXEstimator.ctChkBx.checked = false;

  document.frmLTAXEstimator.totUnImprovedValue2.value = 0;
  document.frmLTAXEstimator.totUnImprovedValue2.disabled = true;

}

function frmClearCalcField()
{
	var oForm = document.forms.frmLTAXEstimator;
    
	if (oCalculator == null || oCalculator == "" || typeof(oCalculator) == "undefined") {
	
	   alert("A calculator instance has not been created!");
	   return;
	}
	
	oForm.ltaxPayable.value = "";
	
	oForm.totUnImprovedValue3.value = "";
	
    oCalculator.reset();
}

