<!--
		
function formatNumber( expr, decimals )
{
         var str = "" + Math.round( eval(expr) * Math.pow(10,decimals))
         while (str.length <= decimals) { str = "0" + str } 
         var decpoint = str.length - decimals;
         var result = str.substring(0,decpoint);
         if (decimals) result += "." + str.substring(decpoint,str.length);
         return result;
}

function calc( block )
{
	if( block.txtEstimatedClosingDate.value == '' )
	{
		alert( 'You must enter the estimated closing date first.' );
	}
	else if( block.selCounty.selectedIndex == 0 )
	{
		block.txtNetSellerProceeds.value = 0;
		alert( 'You must select a county!' );
	}
	else
	{
	var closingDate;
	var today;
	var endYear;
	var msPerDay;
	var daysLeft;
	var daysPast;
	
    closingDate = new Date();
    closingDate.setTime(Date.parse(block.txtEstimatedClosingDate.value));
        
    today = new Date();
    endYear = new Date("December 31, 2010"); // Set day and month
    endYear.setYear( closingDate.getFullYear()); // Set year to this year
    msPerDay = ( 24 * 60 * 60 * 1000 ); // Number of milliseconds per day
    daysLeft = ((endYear.getTime() - closingDate.getTime()) / msPerDay);
    daysLeft = Math.round(daysLeft);
    daysPast = 365 - daysLeft;
    //alert("Closing day day of this year: " + days_past)
    
    if ( daysPast > 182 )
	{
		// second half closing date
       	block.txtTotalDays.value = daysPast;
    }
	else
	{
		// first half closing date
       	block.txtTotalDays.value =  daysPast + 183;
    }
    
    block.txtAmountPerDay.value = Math.round(100*(eval(block.txtFirstHalf.value) + eval(block.txtSecondHalf.value)) / 365)/100;
      
    block.txtDailyTax.value = eval(eval(block.txtTotalDays.value) * eval(block.txtAmountPerDay.value));
    block.txtDailyTax.value = Math.round(100 * eval(block.txtDailyTax.value)) / 100;
    block.txtLessTax.value = formatNumber(eval(block.txtDailyTax.value),2);
    
	//Comission  
	if (block.radCommission[0].checked) { // straight commission
	      block.txtSplitListOne.value = 0
   	      block.txtSplitListTwo.value = 0
	      block.txtSplitCoOpOne.value = 0
	      block.txtSplitCoOpTwo.value = 0
	      block.txtSplitListComission.value = 0
	      block.txtSplitCoOpComission.value = 0
       block.txtListCommission.value = Math.round(100*eval(eval(block.txtListingPercentage.value) / 100 * eval(block.txtSellingPrice.value)))/100
       block.txtCoOpComission.value = Math.round(100*eval(eval(block.txtCoOpPercentage.value) / 100 * eval(block.txtSellingPrice.value)))/100
	} else { // split commission
	    if (eval(block.txtSplitListOne.value) == 0) {
	      block.txtSplitListOne.value = 3.5
   	      block.txtSplitListTwo.value = 2.5
	      block.txtSplitCoOpOne.value = 3.5
	      block.txtSplitCoOpTwo.value = 2.5
	    } 
       block.txtListingPercentage.value = 0
       block.txtCoOpPercentage.value = 0
       block.txtListCommission.value = 0
       block.txtCoOpComission.value = 0
       if (eval(block.txtSellingPrice.value) > 100000) {
         var gr_amt = eval(block.txtSellingPrice.value) - 100000
         block.txtSplitListComission.value = Math.round(100 * eval( eval(block.txtSplitListOne.value ) / 100 * 100000 ) )/100 + Math.round(100 * eval( eval( block.txtSplitListTwo.value ) / 100 * gr_amt))/100
         block.txtSplitCoOpComission.value = Math.round(100 * eval(eval(block.txtSplitCoOpOne.value) / 100 * 100000))/100 + Math.round(100*eval(eval(block.txtSplitCoOpTwo.value) / 100 * gr_amt))/100
       } else { 
         block.txtSplitListComission.value = Math.round(100 * eval(eval(block.txtSplitListOne.value) / 100 * eval(block.txtSellingPrice.value)))/100
         block.txtSplitCoOpComission.value = Math.round(100 * eval(eval(block.txtSplitCoOpOne.value) / 100 * eval(block.txtSellingPrice.value)))/100       	
       }
	}      
      
      
	var index = block.selCounty.selectedIndex
	
	//Updated Conveyance Fees on 4/6/2009
	if (index == 0)
	{
       block.txtNetSellerProceeds.value = 0
       alert("You must select a county!")
    }
	else if (index == 54)
	{
		var con = 2.5
	}
	else if (index == 14)
	{
		var con = 3.5
    }
	else if (index == 2 || index == 4 || index == 6 || index == 7 || index == 8 || index == 9 || index == 20 || index == 21 || index == 24 || index == 31 || index == 32 || index == 36 || index == 42 || index == 52 || index == 53 || index == 56 || index == 57 || index == 58 || index == 60 || index == 63 || index == 65 || index == 83 || index == 87)
	{
		var con = 3
    }
	else if (index == 11 || index == 19 || index == 25 || index == 29 || index == 39 || index == 45 || index == 46 || index == 49 || index == 51 || index == 55 || index == 62 || index == 66 || index == 68 || index == 80 || index == 85)
	{
		var con = 2
	}
	else if (index == 71)
	{
		var con = 1
	}
	else
	{
		var con = 4
	}
	
	if ( block.txtSellingPrice.value != 0.00 )
	{
      block.txtConveyanceFee.value = eval((Math.ceil(eval(block.txtSellingPrice.value) /100) * 100) * con / 1000) +.50
      block.txtConveyanceFee.value = formatNumber(Math.round(100 * eval(block.txtConveyanceFee.value)) / 100,2)
	}
     
      if (block.txtSellingPrice.value <= 150000)
	  {
         var div = 5.75
         var base_policy_amount = 0
         var variable_policy_amount = eval(block.txtSellingPrice.value)
      }
	  else if (block.txtSellingPrice.value <= 250000 && block.txtSellingPrice.value > 150000)
	  {
         var div = 4.5
         var base_policy_amount = 187.50
         var variable_policy_amount = eval(block.txtSellingPrice.value)
      }
	  else if (block.txtSellingPrice.value <= 500000 && block.txtSellingPrice.value > 250000)
	  {
         var div = 3.5
         var base_policy_amount = 437.50
         var variable_policy_amount = eval(block.txtSellingPrice.value)
      }
	  else if (block.txtSellingPrice.value <= 10000000 && block.txtSellingPrice.value > 500000)
	  {
         var div = 2.75
         var base_policy_amount = 812.50
         var variable_policy_amount = eval(block.txtSellingPrice.value)
      }
	  else
	  {
         var div = 2.75
         var base_policy_amount = 5812.50
         var variable_policy_amount = eval(block.txtSellingPrice.value)
      }                             

      variable_policy_amount = eval(Math.ceil(eval(variable_policy_amount) /1000))
      block.txtOwnersPolicy.value = Math.round(100*eval(div * variable_policy_amount))/100 + base_policy_amount
      block.txtOwnersPolicy.value = Math.round(100 * eval(block.txtOwnersPolicy.value) / 2) / 100

	if (block.txtOwnersPolicy.value < 175)
	{
		block.txtOwnersPolicy.value = 175
	}
	else
	{
		block.txtOwnersPolicy.value = eval(block.txtOwnersPolicy.value) 
	}
	
      var mortgage_num = block.selNumberOfMortgages.selectedIndex
      if (mortgage_num == 0)
	  {
         var mortnum = 0
      }
	  else if (mortgage_num == 1)
	  {
         var mortnum = 1
      }
	  else if (mortgage_num == 2)
	  {
         var mortnum = 2
      }
	  else
	  {
         var mortnum = 3
      }
      block.txtHoldSignature.value = formatNumber(25 * mortnum,2)

	// calculate title examination fee
	/*var coindex = block.selCounty.selectedIndex
	if (coindex == 18 || coindex == 43 || coindex == 4 || coindex == 28 || coindex == 22 || coindex == 39 || coindex == 47 || coindex == 72 || coindex == 78)
	{
	   block.txtTitleExamination.value = 325; // cuyahoga lake ashtbula geauga erie huron lorain sandusky trumbull
	}
	else if (coindex == 3 || coindex == 38)
	{
	   block.txtTitleExamination.value = 285; // ashland holmes   
	}
	else if (coindex == 55 || coindex == 57 || coindex == 83 || coindex == 29 || coindex == 12 || coindex == 68)
	{
	   block.txtTitleExamination.value = 175 // miami montgomery warren greene clark preble     
	}
	else
	{
	   block.txtTitleExamination.value = 300;
	}*/
      
	  //calculate title examination fee as of 10/05/2009
	  var coindex = block.selCounty.selectedIndex;
	  if(coindex == 52 || coindex == 67 || coindex == 76 || coindex == 77)
	  {
	  	block.txtTitleExamination.value = 300;
	  }
	  else
	  {
	  	block.txtTitleExamination.value = 325;
	  }
	  
   	  // calculate escrow closing fee
      var coindex = block.selCounty.selectedIndex
   	  sp = eval(block.txtSellingPrice.value)
    
      // New Close calculations as of 10/19/08
      if (block.txtSellingPrice.value <= 100000)
	  {
         block.txtEscrowClosingFee.value = 355;
      }
	  else if (block.txtSellingPrice.value <= 200000 && block.txtSellingPrice.value > 100000)
	  {
         block.txtEscrowClosingFee.value = 385;
      }
	  else
	  {
         block.txtEscrowClosingFee.value = 395;
      }         
      
    // Set closing for certain counties as of 11/2/08
    // carroll mahoning medina portage stark summit 
    //if (coindex == 10 || coindex == 50 || coindex == 52 || coindex == 67 || coindex == 76 || coindex == 77)
	//{
    //   block.txtEscrowClosingFee.value = 250;
    //}
     
	// Set escrow closing for certain counties as of 10/05/2009
	if (coindex == 52 || coindex == 67 || coindex == 76 || coindex == 77)     
	{
		block.txtEscrowClosingFee.value = 250;
	}
	
      block.txtSellingPrice.value = formatNumber(eval(block.txtSellingPrice.value),2)
      block.txtLessMortgage.value = formatNumber(eval(block.txtLessMortgage.value),2)
      
      block.txtFirstHalf.value = formatNumber(eval(block.txtFirstHalf.value),2)
      block.txtSecondHalf.value = formatNumber(eval(block.txtSecondHalf.value),2)
      
      block.txtListCommission.value = formatNumber(eval(block.txtListCommission.value),2)
      block.txtCoOpComission.value = formatNumber(eval(block.txtCoOpComission.value),2)
      block.txtSplitListComission.value = formatNumber(eval(block.txtSplitListComission.value),2)
      block.txtSplitCoOpComission.value = formatNumber(eval(block.txtSplitCoOpComission.value),2)   
      
      block.txtDeedPreparations.value = formatNumber(eval(block.txtDeedPreparations.value),2)
      block.txtHomeWarranty.value = formatNumber(eval(block.txtHomeWarranty.value),2)
      block.txtWaterHold.value = formatNumber(eval(block.txtWaterHold.value),2)
      block.txtTermiteInspection.value = formatNumber(eval(block.txtTermiteInspection.value),2)
      block.txtTitleExamination.value = formatNumber(eval(block.txtTitleExamination.value),2)
      block.txtEscrowClosingFee.value = formatNumber(eval(block.txtEscrowClosingFee.value),2)
      block.txtHandlingProcessing.value = formatNumber(eval(block.txtHandlingProcessing.value),2)
      block.txtTitleUpdate.value = formatNumber(eval(block.txtTitleUpdate.value),2)
      block.txtWireFee.value = formatNumber(eval(block.txtWireFee.value),2)
	  block.txtAddSellersFee.value = formatNumber(eval(block.txtAddSellersFee.value),2)
      block.txtOwnersPolicy.value = formatNumber(eval(block.txtOwnersPolicy.value),2)
      
      block.txtLessTotalSales.value = formatNumber(Math.round(100 * eval(eval(block.txtCoOpComission.value) + eval(block.txtListCommission.value)))/100 + Math.round(100 * eval(eval(block.txtSplitCoOpComission.value) + eval(block.txtSplitListComission.value)))/100,2)
      block.txtLessTotalFee.value = formatNumber(eval(eval(block.txtConveyanceFee.value) + eval(block.txtHomeWarranty.value) + eval(block.txtWaterHold.value) + eval(block.txtHandlingProcessing.value) + eval(block.txtTermiteInspection.value) + eval(block.txtTitleExamination.value) + eval(block.txtHoldSignature.value) + eval(block.txtEscrowClosingFee.value) + eval(block.txtDeedPreparations.value) + eval(block.txtTitleUpdate.value) + eval(block.txtAddSellersFee.value) + eval(block.txtWireFee.value)),2)
      block.txtLessTitleInsurance.value = formatNumber(Math.round(100 * eval(eval(block.txtOwnersPolicy.value) - 0))/100,2)
      block.txtNetSellerProceeds.value = formatNumber(Math.round(100*eval(eval(block.txtSellingPrice.value) - eval(block.txtLessMortgage.value) - eval(block.txtLessTax.value) - eval(block.txtLessTotalSales.value) - eval(block.txtLessTotalFee.value) - eval(block.txtLessTitleInsurance.value)))/100,2)

	 } 
}
//-->
