function ich_thisMovie(movieName) {
    if (navigator.appName.indexOf("Microsoft") != -1) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function ich_changeDisclaimer(tabNum){
	if(tabNum == 1 || tabNum == 3 || tabNum == 5 ){
		document.getElementById("ich_ing_disclaimer_title").firstChild.data = "Important Information";
		document.getElementById("ich_ing_disclaimer").style.paddingTop="10px";
		document.getElementById("ich_ing_disclaimer").style.paddingBottom="10px";
	}else{
		document.getElementById("ich_ing_disclaimer_title").firstChild.data = "";
		document.getElementById("ich_ing_disclaimer").style.paddingTop="0px";
		document.getElementById("ich_ing_disclaimer").style.paddingBottom="0px";
	}
	if(tabNum == 1 || tabNum == 5 ){
		document.getElementById("ich_ing_disclaimer_text").firstChild.data = "This calculator is intended for use by you (individuals only) as a guide only and not intended to be relied on as providing you with all costs involved in buying a property. The figures and formulae used within this calculator may change at any time without notice and additional fees and charges may apply. The calculator does not include all the fees and charges that may apply and does not take into consideration any concessions, discounts, exemptions or grants that you may be entitled to other than stamp duty exemptions and concessions that have been included in the calculation based on information you have provided. However, we advise that you check with your solicitor/conveyancer to see if you are eligible for the exception/concessions. The total buying cost is an indicative estimate only and ING DIRECT does not warrant accuracy. You should speak to a Mortgage Specialist, Solicitor, Conveyancer and Real Estate Agent to determine exact costs.";
	}else{
		if(tabNum == 3){
			document.getElementById("ich_ing_disclaimer_text").firstChild.data = "Legal fees may be greater than $220 depending on the location of the property purchased.";
		}else{
			document.getElementById("ich_ing_disclaimer_text").firstChild.data = "";
		}
	}
}

function ich_loadValues()
{

}

/*
function ich_setEmailType(emailType)
{
    ich_MainForm.ich_vEmailType.value = emailType;
}
*/

function ich_saveCalc(stateTerritory, loanPurpose, estValue, deposit, loanType, govtCharges, ingFees, otherCosts, totalCosts)
{
	var winRef = window.open('','saveWindow','location=no,resizable=yes,scrollbars=yes,width=500,height=400,left=400,top=100');
	var s = ' ';
	s = ich_makeReport(stateTerritory, loanPurpose, estValue, deposit, loanType, govtCharges, ingFees, otherCosts, totalCosts);
	winRef.document.write(s);
	winRef.document.close();
}

function ich_makeReport(stateTerritory, loanPurpose, estValue, deposit, loanType, govtCharges, ingFees, otherCosts, totalCosts)
{
	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("ING Property Buying Cost Calculator") +
	"<body>"+
	"<div id=\\'brandingColor\\'></div>"+
	"<div id=\\'global_container\\'>"+
		"<h2>Calculator Summary</h2>"+
		"<div id=\\'column_container\\'>"+
			"<h3>Property Details </h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>State/Territory :</strong> "+stateTerritory+"<br>"+
						"<strong>Loan purpose :</strong> "+loanPurpose+"<br>"+
						"<strong>Estimated property value :</strong> $ "+estValue+"<br>"+
						"<strong>Deposit amount :</strong> $ "+deposit+"</p>"+
				"</div>"+
		"</div>"+
		"<div id=\\'results_container\\'>"+
			"<h3>Results summary</h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong> "+loanType+"</strong><br><br>"+
						"<strong>Total government charges :</strong> "+govtCharges+"<br>"+
						"<strong>Total ING fees and charges :</strong> "+ingFees+"<br>"+
						"<strong>Total other costs :</strong> "+otherCosts+"<br><br>"+
						"<strong>Total home loan costs : "+otherCosts+"</strong><br>"+
					"</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>Property Buying Cost Calculator</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=\"300,*\" 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;
}


function ich_printPage(printOrSave, summ_Result, stateTerritory, loanPurpose, 
						   estValue, deposit, proposedLoan, loanType,
						   stamp_TransferLand, stamp_Mortgage, rego_TransferLand, 
						   rego_Mortgage, totalGovt,
						   legalFees, appFee, mortgageInsurance, fixedRate, 
						   smartPack, otherFee, ingTotal,
						   homeInsurance, contentsInsurance, solicitor, pestInspection,
						   strata, movingExpenses, connectingUtilities, BuildReport,
						   otherRates, landTax, Others, otherTotal,
						   totalCosts)
{
	var winRef = window.open('','printCalc','location=no,resizable=yes,scrollbars=yes,width=500,height=600,left=400,top=100');
	var s = ' ';
	s = ich_makePrintReport(printOrSave, summ_Result, stateTerritory, loanPurpose, 
						   estValue, deposit, proposedLoan, loanType,
						   stamp_TransferLand, stamp_Mortgage, rego_TransferLand, 
						   rego_Mortgage, totalGovt,
						   legalFees, appFee, mortgageInsurance, fixedRate, 
						   smartPack, otherFee, ingTotal,
						   homeInsurance, contentsInsurance, solicitor, pestInspection,
						   strata, movingExpenses, connectingUtilities, BuildReport,
						   otherRates, landTax, Others, otherTotal,
						   totalCosts);
	winRef.document.write(s);
	winRef.document.close();
}

function ich_makePrintReport(printOrSave, summ_Result, stateTerritory, loanPurpose, 
						   estValue, deposit, proposedLoan, loanType,
						   stamp_TransferLand, stamp_Mortgage, rego_TransferLand, 
						   rego_Mortgage, totalGovt,
						   legalFees, appFee, mortgageInsurance, fixedRate, 
						   smartPack, otherFee, ingTotal,
						   homeInsurance, contentsInsurance, solicitor, pestInspection,
						   strata, movingExpenses, connectingUtilities, BuildReport,
						   otherRates, landTax, Others, otherTotal,
						   totalCosts)
{
	
	// generate the html page for the save table frame.
	var printFrameStr = ich_saveHeader("ING Property Buying Cost Calculator") +
	"<body>"+
	"<div id=\\'brandingColor\\'></div>"+
	"<div id=\\'global_container\\'>"+
		"<h2>Calculator Summary</h2>"+
		
		"<div id=\\'column_container\\'>"+
		    "<strong>"+summ_Result +"</strong><br>"+
		    
			"<h3>Property Details </h3>"+
				"<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
						"<strong>State/Territory :</strong> "+stateTerritory+"<br>"+
						"<strong>Loan purpose :</strong> "+loanPurpose+"<br>"+
						"<strong>Estimated property value :</strong> $ "+estValue+"<br>";
	if(deposit.length != 0){
				printFrameStr += "<strong>Deposit amount :</strong> $ "+deposit+"<br>";
	}
	printFrameStr +=     "<strong>Proposed loan amount :</strong> "+proposedLoan+"<br>" +
	                    "<strong>Loan type :</strong> "+loanType+"<br>" +
				"</p></div></div>"+
		"<div id=\\'column_container\\'>"+
			"<h3>Government Charges </h3>"+
			    "<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
					    "<strong>Stamp duty on property :</strong> "+stamp_TransferLand+"<br>"+
					    "<strong>Stamp duty on the mortgage :</strong> "+stamp_Mortgage+"<br>"+
					    "<strong>Transfer registration fee :</strong> "+rego_TransferLand+"<br>"+
					    "<strong>Registration of mortgage :</strong> "+rego_Mortgage+"<br>"+
					    "<strong>Total government charges : "+totalGovt+"</strong><br>"+
					"</p></div></div>"+
		"<div id=\\'column_container\\'>"+
			"<h3>ING DIRECT fees and charges </h3>"+
			    "<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
					    "<strong>Legal fees :</strong> "+legalFees+"<br>"+
					    "<strong>Home loan application fee :</strong> "+appFee+"<br>"+
					    "<strong>Lender\\'s Mortgage Insurance or Reduced Equity Fee :</strong> "+mortgageInsurance+"<br>";
	if(fixedRate.toLowerCase() == "true"){
				printFrameStr += "<strong>Fixed rate lock in :</strong> "+otherFee+"<br>";
	}
	if(smartPack.toLowerCase() == "true"){
				printFrameStr += "<strong>SmartPack fee :</strong> "+otherFee+"<br>";
	}
	printFrameStr +=    "<strong>Total ING DIRECT fees and charges : "+ingTotal+"</strong><br>"+
					"</p></div></div>"+
		"<div id=\\'column_container\\'>"+
			"<h3>Other costs </h3>"+
			    "<div class=\\'content_container\\'>"+
					"<p class=\\'column1\\'>"+
					    "<strong>Home insurance :</strong> $"+homeInsurance+"<br>"+
					    "<strong>Contents insurance :</strong> $"+contentsInsurance+"<br>"+
					    "<strong>Solicitor/Conveyancing fees :</strong> $"+solicitor+"<br>"+
					    "<strong>Pest inspection :</strong> $"+pestInspection+"<br>"+
					    "<strong>Strata search :</strong> $"+strata+"<br>"+
					    "<strong>Moving expenses :</strong> $"+movingExpenses+"<br>"+
					    "<strong>Connecting utilities :</strong> $"+connectingUtilities+"<br>"+
					    "<strong>Building report :</strong> $"+BuildReport+"<br>"+
					    "<strong>Rates :</strong> $"+otherRates+"<br>"+
					    "<strong>Land tax :</strong> $"+landTax+"<br>"+
					    "<strong>Others :</strong> $"+Others+"<br>"+
					    
					    "<strong>Total other costs : "+otherTotal+"</strong><br><br>"+
					    "<strong>Estimated total buying costs : "+totalCosts+"</strong><br>"+
					"</p></div></div>"+	
					
			
		"</div>"+
	"</body>"+
	"</html>";

	// generate a html page consisting of the save button.
	var buttonFrameStr;
	if(printOrSave == "save"){
	    buttonFrameStr = ich_saveButtonPage();
	     
	}else{
	    buttonFrameStr = ich_printButtonPage();
    }
	
	// 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>Property Buying Cost Calculator</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('"+printFrameStr+"');"+
	    "window.saveFrame.document.close();"+
	    "window.buttonFrame.document.open();"+
	    "window.buttonFrame.document.write('"+buttonFrameStr+"');"+
	    "window.buttonFrame.document.close();"+
	"}";
	
	if(printOrSave == "save"){
	    str+=
    	"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.\");"+
    		"}"+
    	"}";
	}else{
	    str+=
	    "function doPrint() {" +
	        "window.saveFrame.focus();window.print();" +
	    "}";
    }
	
	str+=
	"document.write('<frameset rows=\"500,*\" 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;
}


function ich_printButtonPage() 
{

	var str = "<html>"+
			"<head>"+
			"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"+

			"<style type=\"text/css\">"+
			"body { background-color: #FFFFFF; padding-left: 10px; }"+
			"</style>"+

			"<title>Button Frame</title>"+
			"</head>"+
			
			"<body>"+
			
			"<form name=\\'PrintForm\\' id=\\'PrintForm\\'>"+
			"<input type=\\'button\\' value=\\'Print\\' onclick=\\'parent.doPrint();\\'>"+
			"</form>"+
			"</body>"+
			"</html>";
			
	return str;
}