/*
var message="Copyright: WebTech Dezine Inc.";

function clickIE()
  {
  if ( event.button==2 )
    {
    alert(message);
    return false;
    }
  }

function clickNS(e)
{
if (document.layers || document.getElementById&&!document.all)
  {
  if (e.which==2||e.which==3)
    {
    alert(message);
    return false;
    }
  }
}

if (document.layers)
{
   document.captureEvents( Event.MOUSEDOWN );
   document.onmousedown = clickNS;
}
else if (document.all && !document.getElementById )
   document.onmousedown = clickIE;

document.oncontextmenu = new Function( "alert(message); return false" )
*/
function mortgage_calculator( ini_value )
{
   var r_i;
   r_i = document.form.interestRate.value/1200;
   var factr        = 1;
 	var ratePlusOne  = r_i + 1;

   for ( var i = 0; i < document.form.nrOfMonths.value; i++ )
      factr *= ratePlusOne;
  
   am = ini_value ? ini_value : document.form.loanAmount.value;
   x  = Math.ceil(100*(am * factr * r_i) / (factr - 1));
   document.form.m_payment.value = x / 100;
return true;
}
 
function land_transfer()
{
  var prop_value = document.form.prop_amount.value;
  var province   = document.form.province.options[document.form.province.selectedIndex].value;
  var land_tax_value;
  var toronto_land_tax_value;
  get_provincial_div ( province );

  if( prop_value == 0 )
		alert( "Please enter a property value!" );
	else if ( prop_value > 0 && prop_value <= 100 )
		alert( "Please choose a property value over $100!" );
	else
   {
	if( province == "Alberta" )
    {
			if( prop_value != 0 )
         {
				land_tax_value = ( (0.001 * prop_value) + 35 );
				document.form.land_tax.value = land_tax_value;
			}
	 }else if( province == "British Columbia" )
    {
			if( prop_value <= 200000 )
         {
				land_tax_value = (0.01 * prop_value);
				document.form.land_tax.value = land_tax_value;
			} else if(prop_value > 200000)
         {
				land_tax_value = ((0.02 * prop_value) - 2000);
				document.form.land_tax.value = land_tax_value;
			}
	 }else if( province == "Manitoba" )
    {
		if( prop_value <= 30000 )
         {
				land_tax_value = "0";
				document.form.land_tax.value = land_tax_value;
			} else if( prop_value > 30000 && prop_value <= 90000 )
         {
				land_tax_value = ((0.005 * prop_value) - 110);
				document.form.land_tax.value = land_tax_value;
			} else if(prop_value > 90000 && prop_value <= 150000)
         {
				land_tax_value = ((0.01 * prop_value) - 560);
				document.form.land_tax.value = land_tax_value;
			} else if(prop_value > 150000)
         {
				land_tax_value = ((0.015 * prop_value) - 1350);
				document.form.land_tax.value = land_tax_value;
			}
	  }else if( province == "New Brunswick")
     {
			if(prop_value != 0)
         {
				land_tax_value = ((0.0025 * prop_value) + 55);
				document.form.land_tax.value = land_tax_value;
			}
    }else if( province == "Newfoundland")
    {
			if(prop_value != 0)
         {
				land_tax_value = ((0.004 * prop_value) + 50);
				document.form.land_tax.value = land_tax_value;
			}
	 }else if( province == "Northwest Territories")
    {
			if( prop_value <= 1000000 )
         {
				land_tax_value = ( (0.0015 * prop_value) + 40 );
				document.form.land_tax.value = land_tax_value;
			} else if( prop_value > 1000000 )
         {
				land_tax_value = (0.001 * prop_value);
				document.form.land_tax.value = land_tax_value;
			}
	 }else if( province == "Nova Scotia")
    {
		   if( prop_value != 0 )
         {
				land_tax_value = (0.0005 * prop_value);
				document.form.land_tax.value = land_tax_value;
			}
	 }else if( province == "Ontario")
    {
         if(prop_value <= 55000)
         {
				land_tax_value = (0.005 * prop_value);
			} else if ( prop_value > 55000 && prop_value <= 250000 )
         {
				land_tax_value = ( (0.01 * prop_value) - 275 );
			} else if( prop_value > 250000 && prop_value <= 400000 )
         {
				land_tax_value = ((0.015 * prop_value) - 1525 );
			} else if( prop_value > 400000 )
         {
				land_tax_value = ((0.02 * prop_value) - 3525 );
			}
         land_tax_value  =  !document.form.ft_buyer.checked  ?  land_tax_value  :  ( land_tax_value > 2000  ?  ( eval ( land_tax_value )  -  2000 )  :  0 );
         document.form.land_tax.value = land_tax_value;
	 }else if( province == "Ontario (Toronto)")
    {
         if ( prop_value  <=  55000 )
         {
				land_tax_value  =  ( 0.005 * prop_value );
            toronto_land_tax_value  =  !document.form.ft_buyer.checked  ?  land_tax_value  :  0;
			} else if ( prop_value > 55000 && prop_value <= 250000 )
         {
				land_tax_value  =  (0.01 * prop_value) - 275;
            toronto_land_tax_value  =  !document.form.ft_buyer.checked  ?  land_tax_value  :  0;
			} else if( prop_value > 250000 && prop_value <= 400000 )
         {
				land_tax_value = ((0.015 * prop_value) - 1525 );
				toronto_land_tax_value  =  !document.form.ft_buyer.checked  ?  prop_value * 0.01 - 275  :  0;
            // land_tax_value + 620 + ((prop_value - 400000) * 0.02);
			} else if( prop_value > 400000 )
         {
				land_tax_value = ((0.02 * prop_value) - 3525 );
				toronto_land_tax_value  =  !document.form.ft_buyer.checked  ?  prop_value * 0.02 - 4275  :  ( prop_value  -  400000 )  *  0.02;
			}
         land_tax_value  =  ( !document.form.ft_buyer.checked  ?  land_tax_value  :  ( land_tax_value  >  2000  ?   land_tax_value  -  2000  :  0 ) ) +  toronto_land_tax_value;
         document.form.land_tax.value = land_tax_value;
	 }    
/*
    else if( province == "Ontario (Toronto)")
    {
         document.getElementById( 'img_spacer' ).style.display   =  'none';
         document.getElementById( 'ontario_tbl' ).style.display  =  'none';
         document.getElementById( 'toronto_tbl' ).style.display  =  'block';			
         document.form.ft_buyer_new_toronto.checked  =  false;
         document.form.ft_buyer_toronto.checked      =  false;
         if(prop_value <= 55000)
         {
				land_tax_value = (0.005 * prop_value);
				document.form.land_tax.value = land_tax_value * 2;
			} else if ( prop_value > 55000 && prop_value <= 250000 )
         {
				land_tax_value = ( (0.01 * prop_value) - 275 );
				document.form.land_tax.value = land_tax_value  * 2;
			} else if( prop_value > 250000 && prop_value <= 400000 )
         {
				land_tax_value = ((0.015 * prop_value) - 1525 );
				document.form.land_tax.value = land_tax_value + ( prop_value * 0.01 - 275 );
            // land_tax_value + 620 + ((prop_value - 400000) * 0.02);
			} else if( prop_value > 400000 )
         {
				land_tax_value = ((0.02 * prop_value) - 3525 );
				document.form.land_tax.value = land_tax_value + ( prop_value * 0.02 - 4275 );
			}
	 }
*/
    else if( province == "Prince Edward Island" )
    {
			if(prop_value > 500)
         {
				land_tax_value = (0.01 * prop_value );
				document.form.land_tax.value = land_tax_value;
			}else
         {
				land_tax_value = 0;
				document.form.land_tax.value = land_tax_value;
			}
	 }else if(province == "Quebec")
    {
		  if(prop_value <= 50000)
        {
				land_tax_value = ( 0.005 * prop_value );
				document.form.land_tax.value = land_tax_value;
		  } else if ( prop_value > 50000 && prop_value <= 250000 )
        {
				land_tax_value = ((0.01 * prop_value) - 250);
				document.form.land_tax.value = land_tax_value;
		  } else if(prop_value > 250000)
        {
				land_tax_value = ((0.015 * prop_value) - 1500);
				document.form.land_tax.value = land_tax_value;
		  }
	  }else if( province == "Saskatchewan" )
     {
		  if ( prop_value <= 1000 )
        {
				land_tax_value = "0";
				document.form.land_tax.value = land_tax_value;
		  } else if(prop_value > 1000)
        {
				land_tax_value = ((0.0015 * prop_value) + 15);
				document.form.land_tax.value = land_tax_value;
			}
	   } else if ( province == "Yukon Territory" )
      {
			if ( prop_value <= 10000 )
         {
				land_tax_value = (0.001 * prop_value);
				document.form.land_tax.value = land_tax_value;
			} else if ( prop_value > 10000 && prop_value <= 25000)
         {
				land_tax_value = (0.005 * prop_value);
				document.form.land_tax.value = land_tax_value;
			} else if ( prop_value > 25000)
         {
				land_tax_value = (0.0025 * prop_value);
				document.form.land_tax.value = land_tax_value;
			}
		}
	}
}

function get_provincial_div ( province )
{
   if ( province  ==  "Ontario"  ||  province  ==  "Ontario (Toronto)" )
   {
      document.getElementById( 'img_spacer' ).style.display   =  'none';
      document.getElementById( 'ontario_tbl' ).style.display  =  'block';
   }else
   {
      document.getElementById( 'img_spacer' ).style.display   =  'block';
      document.getElementById( 'ontario_tbl' ).style.display  =  'none';
   }
}
