function ich_loadValues()
{
	var parameters = ich_Savings.getParameters();
	var pArray = parameters.split("&&");
	
	ich_MainForm.ich_vClientName.value = pArray[0];
	ich_MainForm.ich_vClientNum.value = pArray[1];
	ich_MainForm.ich_vCalc.value = pArray[2];
	ich_MainForm.ich_vDate.value = pArray[3];
	ich_MainForm.ich_vInitial.value = pArray[4];
	ich_MainForm.ich_vDeposit.value = pArray[5];
	ich_MainForm.ich_vRate.value = pArray[6];
	ich_MainForm.ich_vTerm.value = pArray[7];
	ich_MainForm.ich_vFreq.value = pArray[8];
	ich_MainForm.ich_vTotalAmount.value = pArray[9];
	ich_MainForm.ich_vTotalInvested.value = pArray[10];
	ich_MainForm.ich_vInterestEarned.value = pArray[11];
	
	ich_MainForm.ich_dbInitial.value = pArray[12];
	ich_MainForm.ich_dbDeposit.value = pArray[13];
	ich_MainForm.ich_dbRate.value = pArray[14];
	ich_MainForm.ich_dbTerm.value = pArray[15];
	ich_MainForm.ich_dbTotalAmount.value = pArray[16];
	ich_MainForm.ich_dbTotalInvested.value = pArray[17];
	ich_MainForm.ich_dbInterestEarned.value = pArray[18];
		 
	ich_FriendForm.ich_vCalc.value = pArray[2];
	ich_FriendForm.ich_vDate.value = pArray[3];
	ich_FriendForm.ich_vInitial.value = pArray[4];
	ich_FriendForm.ich_vDeposit.value = pArray[5];
	ich_FriendForm.ich_vRate.value = pArray[6];
	ich_FriendForm.ich_vTerm.value = pArray[7];
	ich_FriendForm.ich_vFreq.value = pArray[8];
	ich_FriendForm.ich_vTotalAmount.value = pArray[9];
	ich_FriendForm.ich_vTotalInvested.value = pArray[10];
	ich_FriendForm.ich_vInterestEarned.value = pArray[11];
}	

function ich_saveCalc(intial,deposit,rate,term,freq,totalAmount,totalInvested,interestEarned)
{
	var winRef = window.open('','saveWindow','location=no,resizable=yes,scrollbars=yes,width=500,height=400,left=400,top=100');
	var s = ' ';
	s = ich_makeReport(intial,deposit,rate,term,freq,totalAmount,totalInvested,interestEarned);
	winRef.document.write(s);
	winRef.document.close();
}

function ich_makeReport(intial,deposit,rate,term,freq,totalAmount,totalInvested,interestEarned)
{
	var browserSupported = false;
	var browser = navigator.appName;
	var temp,version;	
	if (browser=="Microsoft Internet Explorer") {
		if (navigator.appVersion.indexOf("MSIE")!=-1) {
			temp = navigator.appVersion.split("MSIE");
			version = parseFloat(temp[1]);
		}
		if(version >= 5) {
			browserSupported = true;
		}
	}
	
	// generate the html page for the save table frame.
	var saveFrameStr = ich_saveHeader() +
	"<body>"+
	"<div id=\\'brandingColor\\'></div>"+
	"<div id=\\'global_container\\'>"+
		"<h2>Calculator Summary</h2>"+
		"<div id=\\'column_container\\'>"+
			"<h3>Savings Details </h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>Initial Amount :</strong> $"+intial+"<br>"+
						"<strong>Deposit Amount :</strong> $"+deposit+"<br>"+
						"<strong>Interest rate :</strong> "+rate+"%</p>"+
					"<p class=\\'column2\\'>"+
						"<strong>Savings term :</strong> "+term+" months<br>"+
						"<strong>Deposit frequency :</strong> "+freq+"</p>"+	
				"</div>"+
		"</div>"+
		"<div id=\\'results_container\\'>"+
			"<h3>Results</h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>Total amount at end of term :</strong> "+totalAmount+"<br>"+
						"<strong>Total amount invested :</strong> "+totalInvested+"<br>"+
						"<strong>Total interest earned :</strong> "+interestEarned+"</p>"+				
				"</div>"+
		"</div>" + 
	"</body>"+
	"</html>";

	// generate a html page consisting of the save button.
	var buttonFrameStr = ich_saveButtonPage();
	
	// generate a html page consisting of 2 frames: top frame contains save table.
	// bottom frame contains save button.
	var str = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"+
	"<html><head>"+ 
	"<title>Savings Calculator Information</title>"+
	"<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"+
	"<script type=\"text/javascript\">"+
	"function update() {"+
	    "window.saveFrame.document.open();"+
	    "window.saveFrame.document.write('"+saveFrameStr+"');"+
	    "window.saveFrame.document.close();"+
	    "window.buttonFrame.document.open();"+
	    "window.buttonFrame.document.write('"+buttonFrameStr+"');"+
	    "window.buttonFrame.document.close();"+
	"}"+
	
	"function doSaveAs() {"+
		"var browserSupported = false;"+
		"var browser = navigator.appName;"+
		"var temp,version;"+
		"if (browser==\"Microsoft Internet Explorer\") {"+
			"if (navigator.appVersion.indexOf(\"MSIE\")!=-1) {"+
				"temp = navigator.appVersion.split(\"MSIE\");"+
				"version = parseFloat(temp[1]);"+
				"if(version >= 5) {"+
					"browserSupported = true;"+
				"}"+
			"}"+
		"}"+
		"if(browserSupported) {	"+
			"window.saveFrame.document.execCommand('saveAs',false,'CalculatorResults.html');"+
		"} else {"+
			"var button = window.buttonFrame.document.getElementById('SaveForm');"+
			"button.parentNode.removeChild(button);"+
			"alert(\"Your browser does not support this save function. To save this page press ctrl-S.\");"+
		"}"+
	"}"+

	"document.write('<frameset rows=\"230,*\" onLoad=\"update()\" frameborder=no border=0>');"+
	"document.write('<frame src=\"\" name=saveFrame noresise=noresize>');"+
	"document.write('<frame src=\"\" name=buttonFrame noresise=noresize>');"+
	"document.write('</frameset>');"+
	"</script>"+
	"</head>"+	
	"</html>";
	
	return str;
}
