/* This JavaScript (Email Spider Stumper) developed by Scott Clark
The Source is available at http://www.clarksco.com/blog/
Copyright 2005 Clark Consulting
-------------------------------------------------------------------
Modified by Jim Degerstrom (info@jimdegerstrom.com) to include a mortgage calculator 2/21/2007 */

function blocker(name) 
{
var domain ="latinconnectionrealty.com";
	document.write('<a href="mailto:' + name + '@' + domain + '">' + name + '@' + domain + '</a>');
}

// This script adds a subject field to the email.

function blockersubject(name,subject)
{
    var domain ="latinconnectionrealty.com";
    document.write('<a href="mailto:' + name + '@' + domain + '?subject=' + subject + '">' + name + '@' + domain + '</a>');
}

//  This script is for using as an "Email Me" or like in a menu system.

function blocker2(name,text)
{
    var domain ="latinconnectionrealty.com";
    document.write('<a href="mailto:' + name + '@' + domain + '">' + text + '</a>');
}

//  This script allows the adding of a subject, but also displayable text for a menu system.
function blockersubject2(name,subject,text)
{
    var domain ="latinconnectionrealty.com";
    document.write('<a href="mailto:' + name + '@' + domain + '?subject=' + subject + '">' + text + '</a>');
}

// This section added, and features a mortgage calculator function.

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function dosum()
{
  var oRate = document.getElementById("rate");
  var oTerm = document.getElementById("term");
  var oAmount = document.getElementById("amount");
  var oPayment = document.getElementById("payment");
  var oDown = document.getElementById("down");
  
  var val = oAmount.value * ((100 - oDown.value) / 100)
  //var val = oAmount.value
  var mi = oRate.value / 1200;
  var base = 1;
  var mbase = 1 + mi;
  var terms = oTerm.value
 var end = ""
  for (i=0; i<(terms * 12); i++)
  {
    base = base * mbase
  }
  var Num = "" + floor(val * mi / ( 1 - (1/base)))
    
  if (Num.indexOf(".")>0)
	{
		arr = Num.split(".")
		if (arr[1].length==1) end = "0"
	}
	else{
		end = ".00"
	}
	
		Num = Num + end

  
  //dec = Num.indexOf(".");
  //end = ((dec > -1) ? "" + Num.substring(dec,Num.length) : ".00");
  //Num = "" + parseInt(Num);
  //if (end.length == 2) end += "0";
  //if (end.length == 1) end += "00";
  //if (end == "") end += ".00";
  

  oPayment.value = Num
  //document.temps.MT.value = floor(document.temps.AT.value / 12)
  //document.temps.MI.value = floor(document.temps.AI.value / 12)
  //var dasum = document.temps.amount.value * mi / ( 1 - (1/base)) +
	//document.temps.AT.value / 12 + 
	//document.temps.AI.value / 12;
  //document.temps.MP.value = floor(dasum);
}

//--------------------------------------------------------------------------------------------------