function ich_loadValues()
{
	var parameters = ich_WhereCanIBuy.getParameters();
	var pArray = parameters.split("&&");
	
	document.forms['ich_MainForm'].elements['ich_vClientName'].value = pArray[0];
	document.forms['ich_MainForm'].elements['ich_vClientNum'].value = pArray[1];
	document.forms['ich_MainForm'].elements['ich_vCalc'].value = pArray[2];
	document.forms['ich_MainForm'].elements['ich_vDate'].value = pArray[3];
	
	document.forms['ich_MainForm'].elements['ich_vJointIncome'].value = pArray[4];
	document.forms['ich_MainForm'].elements['ich_vDependants'].value = pArray[5];
	document.forms['ich_MainForm'].elements['ich_vSalaryFreq'].value = pArray[6];
	document.forms['ich_MainForm'].elements['ich_vSalary'].value = pArray[7];
	document.forms['ich_MainForm'].elements['ich_vSalary2Freq'].value = pArray[8];
	document.forms['ich_MainForm'].elements['ich_vSalary2'].value = pArray[9];
	document.forms['ich_MainForm'].elements['ich_vOtherIncomeFreq'].value = pArray[10];
	document.forms['ich_MainForm'].elements['ich_vOtherIncome'].value = pArray[11];
	document.forms['ich_MainForm'].elements['ich_vCarRepayment'].value = pArray[12];
	document.forms['ich_MainForm'].elements['ich_vCreditLimit'].value = pArray[13];
	document.forms['ich_MainForm'].elements['ich_vOtherPaymentsFreq'].value = pArray[14];
	document.forms['ich_MainForm'].elements['ich_vOtherPayments'].value = pArray[15];
	document.forms['ich_MainForm'].elements['ich_vInterestRate'].value = pArray[16];
	document.forms['ich_MainForm'].elements['ich_vTerm'].value = pArray[17];
	document.forms['ich_MainForm'].elements['ich_vBorrowNum'].value = pArray[18];
	document.forms['ich_MainForm'].elements['ich_vBorrowAmountLabel'].value = pArray[19];
	document.forms['ich_MainForm'].elements['ich_vBorrowAmount'].value = pArray[20];
	document.forms['ich_MainForm'].elements['ich_vRepayments'].value = pArray[21];
	
	document.forms['ich_MainForm'].elements['ich_dbDependants'].value = pArray[22];
	document.forms['ich_MainForm'].elements['ich_dbSalary'].value = pArray[23];
	document.forms['ich_MainForm'].elements['ich_dbSalary2'].value = pArray[24];
	document.forms['ich_MainForm'].elements['ich_dbOtherIncome'].value = pArray[25];
	document.forms['ich_MainForm'].elements['ich_dbCarRepayment'].value = pArray[26];
	document.forms['ich_MainForm'].elements['ich_dbCreditLimit'].value = pArray[27];
	document.forms['ich_MainForm'].elements['ich_dbOtherPayments'].value = pArray[28];
	document.forms['ich_MainForm'].elements['ich_dbInterestRate'].value = pArray[29];
	document.forms['ich_MainForm'].elements['ich_dbTerm'].value = pArray[30];
	document.forms['ich_MainForm'].elements['ich_dbBorrowAmount'].value = pArray[31];
	document.forms['ich_MainForm'].elements['ich_dbRepayments'].value = pArray[32];
	
	document.forms['ich_MainForm'].elements['ich_vAnnualExpenses'].value = pArray[33];
	document.forms['ich_MainForm'].elements['ich_vMaxPercent'].value = pArray[34];
	document.forms['ich_MainForm'].elements['ich_vExtraInterest'].value = pArray[35];
	
	document.forms['ich_MainForm'].elements['ich_vSuburb1'].value = pArray[36];
	document.forms['ich_MainForm'].elements['ich_vSuburb2'].value = pArray[37];
	document.forms['ich_MainForm'].elements['ich_vSuburb3'].value = pArray[38];
	document.forms['ich_MainForm'].elements['ich_vSuburb4'].value = pArray[39];
	document.forms['ich_MainForm'].elements['ich_vSuburb5'].value = pArray[40];
	document.forms['ich_MainForm'].elements['ich_vSuburb6'].value = pArray[41];
	document.forms['ich_MainForm'].elements['ich_vSuburb7'].value = pArray[42];
	document.forms['ich_MainForm'].elements['ich_vSuburb8'].value = pArray[43];
	document.forms['ich_MainForm'].elements['ich_vSuburb9'].value = pArray[44];
	document.forms['ich_MainForm'].elements['ich_vSuburb10'].value = pArray[45];
	document.forms['ich_MainForm'].elements['ich_vSuburb11'].value = pArray[46];
	document.forms['ich_MainForm'].elements['ich_vSuburb12'].value = pArray[47];
	document.forms['ich_MainForm'].elements['ich_vSuburb13'].value = pArray[48];
		
	document.forms['ich_FriendForm'].elements['ich_vCalc'].value = pArray[2];
	document.forms['ich_FriendForm'].elements['ich_vDate'].value = pArray[3];
	document.forms['ich_FriendForm'].elements['ich_vJointIncome'].value = pArray[4];
	document.forms['ich_FriendForm'].elements['ich_vDependants'].value = pArray[5];
	document.forms['ich_FriendForm'].elements['ich_vSalaryFreq'].value = pArray[6];
	document.forms['ich_FriendForm'].elements['ich_vSalary'].value = pArray[7];
	document.forms['ich_FriendForm'].elements['ich_vSalary2Freq'].value = pArray[8];
	document.forms['ich_FriendForm'].elements['ich_vSalary2'].value = pArray[9];
	document.forms['ich_FriendForm'].elements['ich_vOtherIncomeFreq'].value = pArray[10];
	document.forms['ich_FriendForm'].elements['ich_vOtherIncome'].value = pArray[11];
	document.forms['ich_FriendForm'].elements['ich_vCarRepayment'].value = pArray[12];
	document.forms['ich_FriendForm'].elements['ich_vCreditLimit'].value = pArray[13];
	document.forms['ich_FriendForm'].elements['ich_vOtherPaymentsFreq'].value = pArray[14];
	document.forms['ich_FriendForm'].elements['ich_vOtherPayments'].value = pArray[15];
	document.forms['ich_FriendForm'].elements['ich_vInterestRate'].value = pArray[16];
	document.forms['ich_FriendForm'].elements['ich_vTerm'].value = pArray[17];
	document.forms['ich_FriendForm'].elements['ich_vBorrowNum'].value = pArray[18];
	document.forms['ich_FriendForm'].elements['ich_vBorrowAmountLabel'].value = pArray[19];
	document.forms['ich_FriendForm'].elements['ich_vBorrowAmount'].value = pArray[20];
	document.forms['ich_FriendForm'].elements['ich_vRepayments'].value = pArray[21];
	
	document.forms['ich_FriendForm'].elements['ich_vAnnualExpenses'].value = pArray[33];
	document.forms['ich_FriendForm'].elements['ich_vMaxPercent'].value = pArray[34];
	document.forms['ich_FriendForm'].elements['ich_vExtraInterest'].value = pArray[35];
	
	document.forms['ich_FriendForm'].elements['ich_vSuburb1'].value = pArray[36];
	document.forms['ich_FriendForm'].elements['ich_vSuburb2'].value = pArray[37];
	document.forms['ich_FriendForm'].elements['ich_vSuburb3'].value = pArray[38];
	document.forms['ich_FriendForm'].elements['ich_vSuburb4'].value = pArray[39];
	document.forms['ich_FriendForm'].elements['ich_vSuburb5'].value = pArray[40];
	document.forms['ich_FriendForm'].elements['ich_vSuburb6'].value = pArray[41];
	document.forms['ich_FriendForm'].elements['ich_vSuburb7'].value = pArray[42];
	document.forms['ich_FriendForm'].elements['ich_vSuburb8'].value = pArray[43];
	document.forms['ich_FriendForm'].elements['ich_vSuburb9'].value = pArray[44];
	document.forms['ich_FriendForm'].elements['ich_vSuburb10'].value = pArray[45];
	document.forms['ich_FriendForm'].elements['ich_vSuburb11'].value = pArray[46];
	document.forms['ich_FriendForm'].elements['ich_vSuburb12'].value = pArray[47];
	document.forms['ich_FriendForm'].elements['ich_vSuburb13'].value = pArray[48];
}	
	
function ich_saveCalc(jointIncome,dependants,salaryFreq,salary,salary2Freq,salary2,otherIncomeFreq,
						otherIncome,carRepayment,creditRepayments,otherPaymentsFreq,otherPayments,interestRate,term,
						borrowNum,borrowAmountLabel,borrowAmount,repayments,annualExpenses, maxPercent, extraInterest,suburbs)
{
	var winRef = window.open('','saveWindow','location=no,resizable=yes,scrollbars=yes,width=500,height=420,left=400,top=100');
	var s = ' ';
	s = ich_makeReport(jointIncome,dependants,salaryFreq,salary,salary2Freq,salary2,otherIncomeFreq,
						otherIncome,carRepayment,creditRepayments,otherPaymentsFreq,otherPayments,interestRate,term,
						borrowNum,borrowAmountLabel,borrowAmount,repayments,annualExpenses, maxPercent, extraInterest,suburbs);
	winRef.document.write(s);
	winRef.document.close();
}

function ich_makeReport(jointIncome,dependants,salaryFreq,salary,salary2Freq,salary2,otherIncomeFreq,
						otherIncome,carRepayment,creditRepayments,otherPaymentsFreq,otherPayments,interestRate,term,
						borrowNum,borrowAmountLabel,borrowAmount,repayments,annualExpenses, maxPercent, extraInterest,suburbs)
{
	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>Your Details </h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>Income Details :</strong><br>"+
						"<strong>Dependants :</strong> "+dependants+"<br>"+
						"<strong>Salary :</strong> $"+salary+" "+salaryFreq+"<br>";
	if(jointIncome == "true") {
		saveFrameStr = saveFrameStr + "<strong>Salary 2 :</strong> $"+salary2+" "+salary2Freq+"<br>";
	}					
	saveFrameStr = saveFrameStr + "<strong>Other net income :</strong> $"+otherIncome+" "+otherIncomeFreq+"<br>"+	
					"<strong>Maximum percent of income available : </strong>"+maxPercent+"%<br><br>"+	
						"<strong>Expense Details :</strong><br>"+
						"<strong>Annual expenses :</strong> $"+annualExpenses+"<br>"+
						"<strong>Monthly car loan repayment :</strong> $"+carRepayment+"<br>"+
						"<strong>Average monthly credit card repayments :</strong> $"+creditRepayments+"<br>"+
						"<strong>Other payments :</strong> $"+otherPayments+" "+otherPaymentsFreq+"</p>"+
				"</div>"+
		"</div>"+
		"<div id=\\'column_container\\'>"+
			"<h3>Loan Details </h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>Interest Rate :</strong> "+interestRate+"%<br>"+
						"<strong>Interest rate buffer :</strong> "+extraInterest+"%<br>"+
						"<strong>Loan Term :</strong> "+term+" years</p>"+
				"</div>"+
		"</div>"+

		"<div id=\\'results_container\\'>"+
			"<h3>Results</h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>"+borrowAmountLabel+"</strong>";		
															
	if(borrowNum>0) {
		saveFrameStr = saveFrameStr + " " + borrowAmount;
	}
	saveFrameStr = saveFrameStr + "<br><strong>Monthly repayments :</strong> "+repayments+"</p>"+					
				"</div>"+
		"</div>" + 
	
		"<div id=\\'results_container\\'>"+
			"<h3>Affordable Suburbs</h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						suburbs+	
					"</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>Where Can I Buy 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=\"350,*\" 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;
}

