<!--
	
document.write('<script src="http://www.cancelcable.com/widgets/js/prototype.js" type="text/javascript"></script>'); 
document.write('<script src="http://www.cancelcable.com/widgets/js/effects.js" type="text/javascript"></script>');

function CommaFormatted(amount)
{
	amount=amount + '.00';
	var delimiter = ","; // replace comma if desired
	var a = amount.split('.',2)
	var d = a[1];
	var i = parseInt(a[0]);
	if(isNaN(i)) { return ''; }
	var minus = '';
	if(i < 0) { minus = '-'; }
	i = Math.abs(i);
	var n = new String(i);
	var a = [];
	while(n.length > 3)
	{
		var nn = n.substr(n.length-3);
		a.unshift(nn);
		n = n.substr(0,n.length-3);
	}
	if(n.length > 0) { a.unshift(n); }
	n = a.join(delimiter);
	
	amount=n;
	
	//if(d.length < 1) { amount = n; } 
	//else { amount = n + '.' + d; }
	amount = minus + amount;
	return amount;
}
// end of function CommaFormatted()

function docalc() {
	if (isNaN(document.getElementById('monthly').value) || isNaN(document.getElementById('rate').value)) {
		alert("Please enter only numbers!");
	} else if (!document.getElementById('monthly').value || !document.getElementById('rate').value) {
		alert("Please fill in every field!");
//	} else if (document.getElementById('days').value > 7) {
//		alert("There's only 7 days in a week!");
	} else {
		//alert("This is a test");
		monthly = document.getElementById('monthly').value;
		rate = document.getElementById('rate').value;
		yearly = Math.round(12 * monthly);
		
		
		//miles = document.getElementById('miles').value;
		//price = document.getElementById('price').value;
		//mpg = document.getElementById('mpg').value;
		//days = document.getElementById('days').value;
		//dailytotal = Math.round(((miles/mpg)*price)*100)/100;
		//weeklytotal = Math.round((((miles/mpg)*price)*days)*100)/100;
		//yearlytotal = Math.round(((((miles/mpg)*price)*days)*52)*100)/100;
	
		//total = "<br />Daily Savings: " + currency + dailytotal.toFixed(2) + "<br />Weekly Savings: " + currency + weeklytotal.toFixed(2) + "<br />Yearly Total: " + currency + yearlytotal.toFixed(2);
		total ='<br />Cable TV is costing you <b>$' + yearly + '</b> a year!<br /><br />';
		//total =total + "<br />";
		//total = total + "You should also know...";
		SavingsArray = new Array();
		dosum(monthly);
		finalbalance=Math.round(finalbalance);
		//total = total + "Canceling cable and investing the difference could  you <b> $" + finalbalance + '</b> in 5 years.';
		//total = total + '<br /><br />';
		//total = total + "And in three years\.\.\." + SavingsArray[3];
		
		newanswer='<hr><center><font size=\"-1\" face=\"Arial, Helvetica, sans-serif\"><strong>You \
            would save...</strong></font></center><br />\
			<ul>\
            <li><span style=\"opacity: 0.999999;\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"><b>$' + CommaFormatted(String(SavingsArray[1])) + '</b> \
              <font size=\"-1\">in 1 year</font></font></span></li>\
            <li><span style=\"opacity: 0.999999;\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"><b>$' + CommaFormatted(String(SavingsArray[3])) + '</b><font size=\"-1\"> \
              in 3 years</font></font></span></li>\
            <li><span style=\"opacity: 0.999999;\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"><b>$' + CommaFormatted(String(SavingsArray[5])) + '</b> \
              <font size=\"-1\">in 5 years</font></font></span></li>\
            <li><span style=\"opacity: 0.999999;\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"><b>$' + CommaFormatted(String(SavingsArray[10])) + '</b> \
              <font size=\"-1\">in 10 years</font></font></span></li>\
            <li><span style=\"opacity: 0.999999;\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"><b>$' + CommaFormatted(String(SavingsArray[20])) + '</b> \
              <font size=\"-1\">in 20 years</font></font></span></li>\
          </ul>';
		total=newanswer;
// comment1
// comment2
// comment3	
document.getElementById('answer').innerHTML=total; 	
// comment1
// comment2
// comment3
//		new Effect.Appear(document.getElementById('answer'));
	}
}

function floor(val)
{
  var newval=100*val;
  newval = Math.round(newval);
  var dollars = Math.floor(newval/100);
  var cents = newval - dollars * 100;
  if (cents == 0) {var centst = new String("00");}
  if (cents < 10) {var centst = "0" + String(cents);}
  if (cents > 9) {var centst = new String(cents);}
  return (dollars + "." + centst);
}

function dosum(monthly)
{
  
  //var mi = document.temps.IR.value / 1200;
//  var mi = 5/1200;    	// Hardcode interest rate of 5%
var mi=Number(rate)/1200;
  
  //var base = Number(document.temps.IB.value);
  var base=0;			// Hardcode initial balance of 0
  output = "";
  var pp = 0;
  var yr = 0;
  
  
  
  //var mc = Number(document.temps.MC.value);
  //alert(monthly);
  var mc=Number(monthly);
  //testmc="*" & mc & "*";
  //var yrs = Number(document.temps.YR.value);
  var yrs = 20;			// Hardcode years=20
  
  var tc = floor(base + 12 * yrs * mc);
  for (i=0; i< yrs * 12; i++)
  {
    base = base * (1 + mi) + mc;
    pp++;
    if (pp == 12)
    {
      yr++;
      if (yr < 10) { sp = " "; } else { sp = ""; } 
      output = 
        output + "\n" + sp + yr + " : " + floor(base);
      pp = 0;
	  //testoutput="count " + i + " " + output;
	  //alert(output);
	  SavingsArray[yr]=Math.round(floor(base));
	  //alert(yr);
	  //alert(SavingsArray[yr]);
    }
  }
  //document.temps.FB.value = floor(base);
  finalbalance=floor(base);
  //alert(SavingsArray[3]);
  //document.temps.TC.value = floor(tc)
  //document.temps.TE.value = floor(base - tc)
}



document.write("<html><head><title>Cancel cable calculator</title> \
<div id=\"cablecalc\" style=\"none;\"><form style=\"margin-bottom: 0px;\">\
    <table width=\"175\" border=\"0\" bordercolor=\"#FFFFCC\" bgcolor=\"#FFFFCC\" style=\"margin-bottom: 0px;\">\
      <tr bgcolor=\"#ffffcc\"> \
        <td style=\"margin: 0pt; padding: 0pt;\"><p align=\"center\"><font face=\"Arial, Helvetica, sans-serif\"><span style=\"opacity: 0.999999;\"><a href=\"http://www.cancelcable.com\"><img src=\"http://ccmrksd34543275io3dazmn5.s3.amazonaws.com/cancelcablesmall.jpg\" width=\"174\" height=\"25\" border=0></a></span></font></p>\
          <p align=\"center\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"><strong> \
            See how much cable TV really costs.\
            </strong></font></p><font face=\"Arial, Helvetica, sans-serif\" size=\"2\">Instantly see how much you could save by canceling cable and investing instead...</font>\
          </td>\
      </tr>\
      <tr bgcolor=\"#ffffcc\"> \
        <td style=\"margin: 0pt; padding: 0pt;\">&nbsp;</td>\
      </tr>\
      <tr bgcolor=\"#ffffcc\"> \
        <td style=\"margin: 0pt; padding: 0pt;\"><div align=\"right\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\">Monthly \
            cable bill:&nbsp; \
            <input name=\"monthly\" type=\"text\" size=\"2\" class=\"text incalc\" id=\"monthly\" style=\"border: 1px solid rgb(170, 170, 170); margin: 0pt; padding: 3px 0pt; width: 44;\" value=\" 75\">\
            </font></div></td>\
      </tr>\
      <tr bgcolor=\"#ffffcc\"> \
        <td style=\"margin: 0pt; padding: 0pt;\"> <div align=\"right\"><font face=\"Arial, Helvetica, sans-serif\" size=\"3\">In</font><font face=\"Arial, Helvetica, sans-serif\" size=\"3\">terest \
            rate:&nbsp;</font><font face=\"Arial, Helvetica, sans-serif\" size=\"3\"> \
            <select id=\"rate\" name=\"rate\">\
              <option value=\"3.0\">3.0</option>\
              <option value=\"3.5\">3.5</option>\
              <option value=\"3.0\">3.0</option>\
              <option value=\"4.5\">4.5</option>\
              <option value=\"5.0\">5.0</option>\
              <option value=\"5.5\">5.5</option>\
              <option value=\"6.0\" selected>6.0</option>\
              <option value=\"6.5\">6.5</option>\
              <option value=\"7.0\">7.0</option>\
              <option value=\"7.5\">7.5</option>\
              <option value=\"8.0\">8.0</option>\
              <option value=\"8.5\">8.5</option>\
              <option value=\"9.0\">9.0</option>\
            </select>\
            </font> </div></td>\
      </tr>\
      <tr> \
        <td> <div align=\"center\" >\
           <br /> <input value=\"Calculate\" id=\"calcsubmit\" name=\"calcsubmit\" onclick=\"docalc()\" style=\"border: 1px solid rgb(170, 170, 170); margin: 0pt; padding: 3px 0pt; width: 65;\" type=\"button\">\
          </form></div>\
          </td>\
      </tr>\
      <tr>\
        <td><div id=\"answer\"><span id=\"answer\" style=\"opacity: 0.999999;\" ></span></div>\
          </td></tr></table></div></body></html>");

//    <table width=\"175\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" bordercolor=\"#FFFFCC\" bgcolor=\"#FFFFCC\">\
//      <tr>\
//        <td bgcolor=\"#FFFFCC\"> \
//          <div align=\"center\">\
//            <p><span style=\"opacity: 0.999999;\"><font size=\"-1\" face=\"Arial, Helvetica, sans-serif\">Visit \
//              <a href=\"http://www.cancelcable.com\">CancelCable.com</a> to learn \
//              how to watch your favorite shows for free on digital TV and the \
//              Net.</font></span></p>\
//            <hr>\
//            <span style=\"opacity: 0.999999;\"><font size=\"-2\" face=\"Arial, Helvetica, sans-serif\"><a href=\"link.htm\"><font color=\"#FF0000\" size=\"-1\">Add \
//            this widget to your site</font><font color=\"#FF0000\">.</font></a></font></span></div></td>\
//      </tr>\
//    </table>\


//<br /><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\"><b>You would save...</b></font>

//<span style=\"opacity: 0.999999;\"><font size=\"-2\" face=\"Arial, Helvetica, sans-serif\"><a href=\"link.htm\"><font color=\"#FF0000\" size=\"-1\">Add \
//            this widget to your site</font><font color=\"#FF0000\">.</font></a></font></span>




 -->
