<!--
// This JavaScript was last modified by <markus> on <12/11/2001>

function removeComma(num)
{
// All variables are decalared here
	var re =/,/g;
	var str = num.toString();

// This function looks at the incoming string and removes all the commas from it.
	str = str.replace(re,"");

	return parseFloat(str);
}

function formatAmount(Expr,DecPlaces)
{

// All variables are decalared here

        //var DecPlaces = 2;

        var str = "" + Math.round(eval(Expr) * Math.pow(10, DecPlaces));
        var DecPoint;
        var Result;
        var re;

// This function looks at the incoming string and formats it with 'DecPlaces' decimal places
// and a comma for every 3 digits.

        while (str.length <= DecPlaces)
        {
                str = "0" + str;
        }
        
        DecPoint = str.length - DecPlaces;

        if (DecPlaces > 0) {
			Result = str.substring(0, DecPoint) + "." + str.substring(DecPoint, str.length);
		}
		else {
			Result = str.substring(0, DecPoint);
		}
		
        re = /(-?\d+)(\d{3})/;

        while (re.test(Result))
        {
                Result = Result.replace(re, "$1,$2");
        }

        return Result;
}

function totalCalculate()
{

// All variables are decalared here

        var valpropertyTotal = removeComma(document.cpbc.propertyTotal.value);
		var valinvestmentTotal = removeComma(document.cpbc.investmentTotal.value);
		var valprotectionTotal = removeComma(document.cpbc.protectionTotal.value);
		var valdaytodayTotal = removeComma(document.cpbc.daytodayTotal.value);
		var valadditionalTotal = removeComma(document.cpbc.additionalTotal.value);
		var valsubTotal = removeComma(document.cpbc.subTotal.value);
		var valpackageFee = removeComma(document.cpbc.packageFee.value);
		var valsavingsTotal = removeComma(document.cpbc.savingsTotal.value);
		
// Calculate the totals and display them to screen
		valpackageFee = -395; // -375; (30/01/2009)
// Totals
		
		valsubTotal = valpropertyTotal + valinvestmentTotal + valprotectionTotal + valdaytodayTotal;
		document.cpbc.subTotal.value = formatAmount(valsubTotal,2);
		document.cpbc.packageFee.value = formatAmount(valpackageFee,2);
		valsavingsTotal = valsubTotal + valpackageFee;
        document.cpbc.savingsTotal.value = formatAmount(valsavingsTotal,2);
		
}

function CPBCPrint(frame,frame1){
// write values to print frame before printing
	frame1.getParentValues();
	frame1.propertyCalculate();
	frame1.investmentCalculate();
	frame1.protectionCalculate();
	frame1.daytodayCalculate();
	frame1.additionalCalculate();
}

function CPBCSubmit() {
//function CPBCSubmit(frame,frame1){
// write values to print frame before printing
	//frame1.getParentValues();
	//frame1.propertyCalculate();
	//frame1.investmentCalculate();
	//frame1.protectionCalculate();
	//frame1.daytodayCalculate();
	//frame1.additionalCalculate();
	subWindow = window.open('', 'sumbitToBanker', 'width=740,height=540,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1,top=0,left=0,screenX=0,screenY=0');
	document.cpbc.submit;
}

function changeText1(){
	htmlWrite("mphtml", "<p>Thank you for your consent to send you information about our products and services to your e-mail address. You can withdraw your consent by clicking on the &quot;NO&quot; button.</p> We always seek to better understand and serve your financial, e-commerce and lifestyle needs so we can offer you other products and services that aim to meet those needs as well as promotions or other opportunities.  This applies to each organisation within the National Australia Bank Group including our banking, financing, funds management, financial planning, superannuation, insurance, broking and e-commerce organisations.<br>To undertake these activities we may need to use your personal information and disclose it to our service providers (for example data processors).  However, for National customers, this would not include your health information.");
}

function changeText2(){
	htmlWrite("mphtml", "You have chosen not to receive information about our products and services to your e-mail address.");
}

function htmlWrite(idDiv, html){
	if (document.layers){
		document.layers[idDiv].document.open('text/html');
		document.layers[idDiv].document.write(html);
		document.layers[idDiv].document.close();
		window.innerWidth = window.innerWidth + 1;
		window.innerWidth = window.innerWidth - 1;
	} else {document.all[idDiv].innerHTML = html}
}

function openWin( windowURL, windowName, windowFeatures)
{//Used for help popup
	return window.open(windowURL, windowName, windowFeatures);
} 

function openRegWin(targetURL, uniqueName)
{
	window.open(targetURL, uniqueName);
}

//-->

