function ich_thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function ich_loadValues()
{
	var parameters = ich_thisMovie("ich_IncomeTax").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_vAnnualIncome.value = pArray[4];
//	ich_MainForm.ich_vNewTax.value = pArray[5];
//	ich_MainForm.ich_vNewNet.value = pArray[6];
//	ich_MainForm.ich_vNewNetWeek.value = pArray[7];
//	ich_MainForm.ich_vTax.value = pArray[8];
//	ich_MainForm.ich_vNet.value = pArray[9];
//	ich_MainForm.ich_vNetWeek.value = pArray[10];
//	ich_MainForm.ich_vDiff.value = pArray[11];
//	ich_MainForm.ich_vNewYear.value = pArray[16];
//	ich_MainForm.ich_vCurrYear.value = pArray[17];
//	ich_MainForm.ich_dbAnnualIncome.value = pArray[12];
//	ich_MainForm.ich_dbNewTax.value = pArray[13];
//	ich_MainForm.ich_dbNewNet.value = pArray[14];
//	ich_MainForm.ich_dbNewNetWeek.value = pArray[15];
	
	
	ich_FriendForm.ich_vCalc.value = pArray[2];
	ich_FriendForm.ich_vDate.value = pArray[3];
	ich_FriendForm.ich_vAnnualIncome.value = pArray[4];
	ich_FriendForm.ich_vNewTax.value = pArray[5];
	ich_FriendForm.ich_vNewNet.value = pArray[6];
	ich_FriendForm.ich_vNewNetWeek.value = pArray[7];
	ich_FriendForm.ich_vTax.value = pArray[8];
	ich_FriendForm.ich_vNet.value = pArray[9];
	ich_FriendForm.ich_vNetWeek.value = pArray[10];
	ich_FriendForm.ich_vDiff.value = pArray[11];
	ich_FriendForm.ich_vNewYear.value = pArray[16];
	ich_FriendForm.ich_vCurrYear.value = pArray[17];
}

function ich_saveCalc(AI,NT,NN,NW,T,N,W,D,NewYear,CurrYear)	
{
	var winRef = window.open('','saveWindow','location=no,resizable=yes,scrollbars=yes,width=500,height=400,left=400,top=100');
	var s = ' ';
	s = ich_makeReport(AI,NT,NN,NW,T,N,W,D,NewYear,CurrYear);
	winRef.document.write(s);
	winRef.document.close();
}

function ich_makeReport(AI,NT,NN,NW,T,N,W,D,NewYear,CurrYear)
{
	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>Income tax Details </h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>Annual Income :</strong> $"+AI+"<br><br>"+
						"<strong> "+NewYear +"</strong> <br>"+
						"<strong>Tax :</strong> "+NT+"<br>"+
						"<strong>Net Income :</strong> "+NN+"<br>"+
						"<strong>Net Income :</strong> "+NW+"<br><br>"+
						
						"<strong>"+CurrYear +"</strong> <br>"+
						"<strong>Tax :</strong> "+T+"<br>"+
						"<strong>Net Income :</strong> "+N+"<br>"+
						"<strong>Net Income :</strong> "+W+"<br><br>"+
						"<strong>Difference per week :</strong> "+D+"<br></p>"+
					"<p class=\\'column2\\'> </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>Income Tax 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=\"290,*\" 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;
}

