function calc_repayments (calc) {

  // calculates the periodic repayments

  // based on algorithms provided by cps credit union

  // script by dave sag © 1998 virtual artists pty ltd

  // dave@va.com.au | http://www.va.com.au

  // included with the VCE 1.5.4 beta 131

  

var A=calc.principal.value;

if ((((A+0)!=0)&&((calc.rate.value+0)!=0))&&((calc.term.value+0)!=0)) {

var i=calc.rate.value/100;

var f=calc.foc.options[calc.foc.selectedIndex].value;

if (f==52) var period="week"

else if (f==26) var period="fortnight"

else if (f==12) var period="month";

var n=calc.term.value;

var iONf=i/f;

  var R=A/(1-Math.pow(1+iONf,-n*f))*iONf;



calc.repayments.value="$"+(Math.round(R*100)/100)+" per "+period



var X=calc.xtra.value;

if (X!="") {

// calculate the new loan term too.

var R1=R+eval(X);

calc.new_pay.value="$"+(Math.round(R1*100)/100)+" per "+period

var n1=Math.log(1-i*A/(R1*f))/(-f*Math.log(1+iONf));

calc.new_term.value="approx "+Math.round(n1*10)/10+" years."

} else {

calc.new_pay.value=""

calc.new_term.value=""

}

} else {

calc.repayments.value="";

}

return true

  }


function max_loan(calc) {

// calculates the most you could borrow

// based on how much you can afford to repay

// per time over some number of years.

// assumes form fields

// foc, repayments, rate, term and principal.

// based on algorithms provided by cps credit union

// script by dave sag, © virtual artists pty ltd.



var R = calc.repayments.value;

if ((((R+0)!=0)&&((calc.rate.value+0)!=0))&&((calc.term.value+0)!=0)) {

var i=calc.rate.value/100;

var f=calc.foc.options[calc.foc.selectedIndex].value;

if (f==52) var period="week"

else if (f==26) var period="fortnight"

else if (f==12) var period="month";

var n=calc.term.value;

var A = R*f*(1-Math.pow(1+(i/f),-n*f))/i;

calc.principal.value="approx $"+Math.round(A*10)/10

} else {

calc.principal.value=""

}

return true

}



var butt_type=".gif";

var my_base_path=self.location.href.substring(0,self.location.href.lastIndexOf("/"))+"/";

// var graphics_folder=my_base_path+"/resources/";

var graphics_folder="/resources/";





window.defaultStatus="BricksAndMortar.co.nz Calculator";



function waxon(butt_name) {

// does nothing

}



function waxoff(butt_name) {

// does nothing

}



function clickety_click(image_name) {

// null.  replaced by js1.1 code that follows.

}



function statuson (text) {

        window.status=text;

        if(parseInt(navigator.appVersion.substring(0,1))<3) {

        setTimeout("statusoff()",2000);

        }

}



function statusoff () {

        window.status="";

}



function prewax() {

// does nothing

}



// WAXON/OFF BUTT SET

// this set of scripts implements automatic buttons for Netscape3+

// and MSIE 4+.  buttons must follow the following guidelines

//

// see also: http://www.va.com.au/afringe for a version of his script which

//           implements a click butt in addition to mouse overs.

//

// naming:   all buttons need an 'on' and 'off' state, reflecting

//           whether the mouse is on or off the button.

//           the on and off states must be the same filetype (ie gif or jpg)

//           different buttons may be different fle types however.

//

// use:      name your images and call onLoad="prewax();return true;" from

//           within the body tag. see the example button below.

//

// credits:  this code was written by dave sag (dave@va.com.au) July 1997

//           it is based on Mark King's (mark.king@va.com.au) original

//           waxon/off script set.

//           if you use this code please email us and let us know.

//

// disclaimer: Neither Dave Sag, Mark King, Virtual Artists or Ampersand Internet

//             make any warranty as to the usefullness or accuracy of this code and

//             accept no liability for its use, or from incidents arising from its use.

//

// contacts:   Virtual Artists Pty Ltd   http://www.va.com.au    va@va.com.au

//             Dave Sag                  http://dave.va.com.au   dave@va.com.au

//             Mark King                 http://mark.va.com.au   mark.king@va.com.au

//

// history:    last modified 12 Aug 1997 by Dave Sag

//             now works for any images as long as they end in _off.{jpg|gif} and _on.{jpg|gif}

//             no ned for the image name to match the src location.

//             works propely with non local images and images outside of a graphics folder





function waxon (butt_name) {

        if(document.images) {

                document.images[butt_name].src=graphics_folder+"butt_"+butt_name+"_on"+butt_type;

        }

}





function waxoff (butt_name) {

        if(document.images) {

                document.images[butt_name].src=graphics_folder+"butt_"+butt_name+"_off"+butt_type;

        }

}







function prewax () {

  if(document.images) {

      on_butts = new Array ();



      for (var i=0;i<document.images.length;i++){

        var tempt = document.images[i].src.indexOf("_off",1)

        if (tempt>0) {

      on_butts[i] = new Image();

      var butt_name = document.images[i].name;

      on_butts[i].src = graphics_folder+"butt_"+butt_name+"_on"+butt_type;



      }

    }

  }

}



		


if (document.images) {

  image1on = new Image();

  image1on.src = "/img_site/nav/over-on.gif";



  image2on = new Image();

  image2on.src = "/img_site/nav/agents-on.gif";



  image3on = new Image();

  image3on.src = "/img_site/nav/listings-on.gif";



  image4on = new Image();

  image4on.src = "/img_site/nav/towns-on.gif";



  image5on = new Image();

  image5on.src = "/img_site/nav/finance-on.gif";



  image6on = new Image();

  image6on.src = "/img_site/nav/purchase-on.gif";



  image7on = new Image();

  image7on.src = "/img_site/nav/relo-on.gif";



  image1off = new Image();

  image1off.src = "/img_site/nav/over-off.gif";



  image2off = new Image();

  image2off.src = "/img_site/nav/agents-off.gif";



  image3off = new Image();

  image3off.src = "/img_site/nav/listings-off.gif";



  image4off = new Image();

  image4off.src = "/img_site/nav/towns-off.gif";



  image5off = new Image();

  image5off.src = "/img_site/nav/finance-off.gif";



  image6off = new Image();

  image6off.src = "/img_site/nav/purchase-off.gif";



  image7off = new Image();

  image7off.src = "/img_site/nav/relo-off.gif";



  otherImageDefault = new Image();

  otherImageDefault.src = "/financing/nav2.jpg";



  otherImage1 = new Image();

  otherImage1.src = "/img_site/nav/over2.jpg";



  otherImage2 = new Image();

  otherImage2.src = "/img_site/spacer.gif";



  otherImage3 = new Image();

  otherImage3.src = "/img_site/nav/";



  otherImage4 = new Image();

  otherImage4.src = "";



  otherImage5 = new Image();

  otherImage5.src = "/img_site/nav/finance2.jpg";



  otherImage6 = new Image();

  otherImage6.src = "/img_site/nav/purchase2.gif";





  otherImage7 = new Image();

  otherImage7.src = "/img_site/nav/relo2.jpg";



}



function changeImages() {

  if (document.images) {

    for (var i=0; i<changeImages.arguments.length; i+=2) {

      document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");

    }

  }

}