	var growthb1 = 3/100;
	var growthb2 = 10/100;
	var growthb4 = 3/100;
	
	var js_a1, js_a2, js_a3, js_a4, js_a7;
	var js_b1, js_b2, js_b3, js_b4;
	var js_c1, js_c2, js_c3, js_c4;
	var js_d1, js_d2, js_d3, js_d4;
	var js_e1, js_e2, js_e3, js_e4;
	var js_f1, js_f2, js_f3, js_f4;

	var js_c5, js_c6, js_c7, js_c8, js_c9;
	var js_d5, js_d6, js_d7, js_d8, js_d9;
	var js_e5, js_e6, js_e7, js_e8, js_e9;
	var js_f5, js_f6, js_f7, js_f8, js_f9;

	var nw;

function HHelp(d) {
document.getElementById(d).style.display = "none";
}
function SHelp(d) {
document.getElementById(d).style.display = "block";
}

function row1() {
	js_a1 = document.getElementById("a1").value;
	js_c1 = js_a1;
	document.getElementById("c1").innerHTML = Math.round(js_c1,0);
	js_d1 = js_c1 * (1 + growthb1);
	document.getElementById("d1").innerHTML = Math.round(js_d1,0);
	js_e1 = js_d1 * (1 + growthb1);
	document.getElementById("e1").innerHTML = Math.round(js_e1,0);
	js_f1 = js_e1 * (1 + growthb1);
	document.getElementById("f1").innerHTML = Math.round(js_f1,0);
}

function row2() {
	js_a2 = document.getElementById("a2").value;
	js_c2 = js_a2;
	document.getElementById("c2").innerHTML = Math.round(js_c2,0);
	js_d2 = js_c2 * (1 + growthb2);
	document.getElementById("d2").innerHTML = Math.round(js_d2,0);
	js_e2 = js_d2 * (1 + growthb2);
	document.getElementById("e2").innerHTML = Math.round(js_e2,0);
	js_f2 = js_e2 * (1 + growthb2);
	document.getElementById("f2").innerHTML = Math.round(js_f2,0);
        row3();
}

function row3() {
	
	if (js_a2 < 5)         { js_a3 = 5; }
	else if (js_a2 < 10)   { js_a3 = 7.5; }
	else if (js_a2 < 20)   { js_a3 = 10; }
	else if (js_a2 < 50)   { js_a3 = 15; }
	else if (js_a2 < 100)  { js_a3 = 24; }
	else if (js_a2 < 500)  { js_a3 = 48; }
	else if (js_a2 < 1000)  { js_a3 = 96; }
	else if (js_a2 >= 1000) { js_a3 = 192; }
	else                   { js_a3 = 0; }
	document.getElementById("a3").innerHTML = Math.round(js_a3,2) + " hrs";
	js_c3 = js_a3;
	document.getElementById("c3").innerHTML = Math.round(js_c3,2) + " hrs";
	js_d3 = js_c3 * (1);
	document.getElementById("d3").innerHTML = Math.round(js_d3,2) + " hrs";
	js_e3 = js_d3 * (1);
	document.getElementById("e3").innerHTML = Math.round(js_e3,2) + " hrs";
	js_f3 = js_e3 * (1);
	document.getElementById("f3").innerHTML = Math.round(js_f3,2) + " hrs";
}


function row4() {
	js_a4 = document.getElementById("a4").value;
	js_c4 = js_a4;
	document.getElementById("c4").innerHTML = "$ " + Math.round(nFormat(js_c4),2);
	js_d4 = js_c4 * (1 + growthb4);
	document.getElementById("d4").innerHTML = "$ " + Math.round(nFormat(js_d4),2);
	js_e4 = js_d4 * (1 + growthb4);
	document.getElementById("e4").innerHTML = "$ " + Math.round(nFormat(js_e4),2);
	js_f4 = js_e4 * (1 + growthb4);
	document.getElementById("f4").innerHTML = "$ " + Math.round(nFormat(js_f4),2);
}

function roi_calc() {

	nWinOpen();

	js_c5 = ((js_c1 * js_c3) * 12);
	js_d5 = ((js_d1 * js_d3) * 12);
	js_e5 = ((js_e1 * js_e3) * 12);
	js_f5 = ((js_f1 * js_f3) * 12);


	js_c6 = js_c5*js_c4;
	js_d6 = js_d5*js_d4;
	js_e6 = js_e5*js_e4;
	js_f6 = js_f5*js_f4;


	if (js_a2 < 5)         { js_a7 = 20; }
	else if (js_a2 < 10)   { js_a7 = 25; }
	else if (js_a2 < 20)   { js_a7 = 30; }
	else if (js_a2 < 50)   { js_a7 = 35; }
	else if (js_a2 < 100)  { js_a7 = 40; }
	else if (js_a2 < 500)  { js_a7 = 45; }
	else if (js_a2 >= 500) { js_a7 = 50; }
	else                   { js_a7 = 0; }

	js_c8 = js_c5*(js_a7/100);
	js_d8 = js_d5*(js_a7/100);
	js_e8 = js_e5*(js_a7/100);
	js_f8 = js_f5*(js_a7/100);

	js_c9 = js_c8*js_a4;
	js_d9 = js_d8*js_a4;
	js_e9 = js_e8*js_a4;
	js_f9 = js_f8*js_a4;


	nWinWrite();

}

function nFormat(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '.00';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function nFormat2(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function nWinOpen()
{
	nw = window.open("","nw","toolbar=no, location=no, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=yes, copyhistory=yes, width=800, height=600") ;
}

function nWinWrite()
{

	nw.document.open();
	nw.document.write("<HTML>");
	nw.document.write("<HEAD>");
	nw.document.write(" <title>Interwoven ROI Results</title>"+
"<LINK REL=STYLESHEET TYPE='text/css' HREF='/toolkit/styles/v5.css' TITLE='Default'>"+
"</HEAD>"+
"<body bgcolor='#FFFFFF' link='#3E474F;' vlink='#3E474F;' alink='#3E474F;' "+
"TEXT=#3E474F marginheight='0' marginwidth='0' topmargin='0' leftmargin='0' rightmargin='0'>"+
"<BASEFONT SIZE='8' COLOR=#3E474F; FACE='Arial'>"+
"<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0>"+
"<tr>"+
		"<TD width='2%' VALIGN='TOP'></TD>"+
		"<TD width='96%' VALIGN='TOP'>	"+
"<table border='0' cellpadding='1' cellspacing='1'>"+
   "<tr> "+
    "<td align='left' rowspan='2'><img src='/media/common_images/logo.jpg' border='0'></td>"+
    "<td colspan='8' align='right' valign='top'> "+
	"<h1>Interwoven Composite Application Provisioning Solution</h1>"+
    "</td>"+
  "</tr>"+
   "<tr> "+
    "<td></td>"+
    "<td colspan='8' align='right' valign='top'> "+
	"<h1>ROI Results</h1>"+
    "</td>"+
  "</tr>"+
   "<tr> "+
    "<td colspan='9' align='right' valign='top'> "+
	"&nbsp;"+
    "</td>"+
  "</tr>"+
  "<tr> "+
    "<td  bgcolor='#c1c1c1' colspan='9' valign='top' align='left'><b>CURRENT PROCESS</b></td>"+
  "</tr>"+
  "<tr> "+
    "<td valign='top' align='left'> </td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='center'> </td>"+
    "<td valign='top' align='center'> </td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='center'> <b>Year 1</b> </td>"+
    "<td valign='top' align='center'> <b>Year 2</b> </td>"+
    "<td valign='top' align='center'> <b>Year 3</b> </td>"+
    "<td valign='top' align='center'> <b>Year 4</b> </td>"+
  "</tr>"+
  "<tr> "+
    "<td valign='top' align='left'> <b>Total time spent (annually) deploying "+
      "changes</b> </td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'> </td>"+
    "<td valign='top' align='right'> </td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_c5,0)) + " hrs</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_d5,0)) + " hrs</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_e5,0)) + " hrs</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_f5,0)) + " hrs</td>"+
  "</tr>"+
  "<tr> "+
	  "<td valign='top' align='left'><b>Total cost to currently deploy Web "+
			  "changes</b></td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'></td>"+
    "<td valign='top' align='right'></td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_c6,2)) + "</nobr></td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_d6,2)) + "</nobr></td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_e6,2)) + "</nobr></td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_f6,2)) + "</nobr></td>"+
  "</tr>"+
  "<tr> "+
    "<td colspan='9' valign='top' align='left'><br></td>"+
  "</tr>"+
   "<tr> "+
    "<td colspan='9' align='right' valign='top'> "+
	"&nbsp;"+
    "</td>"+
  "</tr>"+
  "<tr> "+
    "<td  bgcolor='#c1c1c1' colspan='9' valign='top' align='left'><b>EXPECTED SAVINGS WITH INTERWOVEN</b></td>"+
  "</tr>"+
  "<tr> ");
    	nw.document.write("<td valign='top' align='left'><nobr><b>Time Savings " + js_a7 + " %</b></nobr>  </td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='center'></td>"+
    "<td valign='top' align='center'></td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='center'> <b>Year 1</b> </td>"+
    "<td valign='top' align='center'> <b>Year 2</b> </td>"+
    "<td valign='top' align='center'> <b>Year 3</b> </td>"+
    "<td valign='top' align='center'> <b>Year 4</b> </td>"+
  "</tr>"+
   "<tr> "+
    "<td colspan='9' align='right' valign='top'> "+
	"<hr>"+
    "</td>"+
  "</tr>"+
  "<tr> "+
  "<td valign='top' align='left'>Hour savings</td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'></td>"+
    "<td valign='top' align='right'></td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_c8,0)) + " hrs</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_d8,0)) + " hrs</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_e8,0)) + " hrs</td>"+
    "<td valign='top' align='right'>" + nFormat2(Math.round(js_f8,0)) + " hrs</td>"+
  "</tr>"+
  "<tr> "+
  "<td valign='top' align='left'>Dollar savings</td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'></td>"+
    "<td valign='top' align='right'></td>"+
    "<td valign='top' align='right'> "+
      "<!-- BLANK COL -->"+
    "</td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_c9,2)) + "</nobr></td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_d9,2)) + "</nobr></td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_e9,2)) + "</nobr></td>"+
    "<td valign='top' align='right'><nobr>$ " + nFormat(Math.round(js_f9,2)) + "</nobr></td>"+
  "</tr>"+
   "<tr> "+
    "<td colspan='9' align='right' valign='top'> "+
	"<hr>"+
    "</td>"+
  "</tr>"+
   "<tr> "+
    "<td colspan='9' align='left' valign='top'> "+
    "<h2>About the calculator</h2>"+
    "<p>This calculator is intended to provide a high-level estimate of time and money saved with an automated composite application provisioning solution.  To get a more detailed cost comparison please contact Interwoven at 888.468.3796 or <a href='mailto:cap@interwoven.com'>cap@interwoven.com</a></p>"+
    "<p>For more information on the Interwoven CAP Solution please visit: <a href='http://www.interwoven.com/cap' target='_blank'>http://www.interwoven.com/cap</a></p>"+
    "<p>Interwoven calculated the deployment times using industry standards, internal tests, and customer reports for automated composite application provisioning with the Interwoven CAP Solution.</p>"+
    "</td>"+
		"<TD width='2%' VALIGN='TOP'></TD>"+
  "</tr>"+
"</table>"+
			"<!-- End Contributor Page Pattern -->"+
				"</TD>"+
			"</TR>"+
		"</TABLE>");
nw.document.write("</body>");
nw.document.write("</html>");
nw.document.close();

}

