// Support Script (779)
// Copyright (c) 1998 by Elemental Software, Inc. - ALL RIGHTS RESERVED.
//
// This class finds the named object in either 4.0 DOM and 
// gathers information about it.
//
function objectInfo(objName)
{
 this.fullName = ""; // if this does not get filled the object could not be found.

 if (objName.length == 0) return;

 this.hide = objectInfoHide;
 this.show = objectInfoShow;
 this.setLeft = objectInfoSetLeft;
 this.setTop  = objectInfoSetTop;
 this.getPosition  = objectInfoGetPosition;
 this.isValid      = objectInfoIsValid;
 this.isValidIE    = objectInfoIsValidIE;
 this.getZindex    = objectInfoGetZindex;
 this.setZindex    = objectInfoSetZindex;
 this.getDimension = objectInfoGetDimension;
 this.setDimension = objectInfoSetDimension;
 this.shiftTo      = objectInfoShiftTo;

 // find the named object in the DOM and then get the properties

 if (document.all) // IE
 {
  while (true)
  {
   if (eval("document.all.DBStyle" + objName))
   {
    if (eval("document.all.DBStyle" + objName + ".offsetWidth"))
    {
     this.fullName = "document.all.DBStyle" + objName;
     this.tagName  = this.fullName;
    }
   }
   else if (eval("document.all." + objName))
   {
    if (eval("document.all." + objName + ".offsetWidth"))
    {
     // Text in DIV tags are caught here
     this.fullName = "document.all." + objName;
     this.tagName  = this.fullName;
    }
    else if (eval("document.all." + objName + "." + objName) != null)
    {
     // Other tags are caught here.
     if (eval("document.all." + objName + "[1].tagName")  != "DIV")
     {
      this.fullName = "document.all." + objName + "[0]";
      this.tagName  = "document.all." + objName + "[1]";
     }
    }
   }

   // strip underscores out of input and try one more time
   if (this.fullName.length > 0) break;
   objName2 = objName.replace(/_/, "");
   if (objName2 == objName) break;
   objName = objName2;
  }

  
  if (this.fullName.length > 0)
  {
   this.styleKey = '.style'; // used to access style info
   this.width  = eval(this.fullName + ".offsetWidth");
   this.height = eval(this.fullName + ".offsetHeight");
  }
 }
 else  // NC
 {
  if (document.layers)
  {
   sectionNumber = 0;
   while (true)
   {
    sectionName = "LyrSection" + sectionNumber.toString();
    if (eval("document.layers." + sectionName) == null) break;  // can't find object in DOM

    // see if this is an object in the DOM
    if (eval("document.layers." + sectionName + ".document"))
    {
     while (true)
     {
      if (eval("document.layers." + sectionName + ".document.layers.LyrDBStyle" + objName))
      {
       this.fullName = "document.layers." + sectionName + ".document.layers.LyrDBStyle" + objName;
       this.tagName  = "document.layers." + sectionName + ".document." + objName; 
       break;
      }
      else if (eval("document.layers." + sectionName + ".document.layers.Lyr" + objName))
      {
       this.fullName = "document.layers." + sectionName + ".document.layers.Lyr" + objName;
       this.tagName  = "document.layers." + sectionName + ".document." + objName; 
       break;
      }
      else if (eval("document.layers." + sectionName + ".document.layers." + objName))
      {
       this.fullName = "document.layers." + sectionName + ".document.layers." + objName;
       this.tagName  = "document.layers." + sectionName + ".document." + objName; 
       break;
      }

      // strip underscores out of input and try one more time
      if (this.fullName.length > 0) break;
      objName2 = objName.replace(/_/, "");
      if (objName2 == objName) break;
      objName = objName2;
     }

    } else alert("objectInfo: " + "document.layers." + sectionName + ".document" + " is not an object");

    sectionNumber++;
   } // end while (looping over all SectionN relative positioning layers)

   if (this.fullName.length > 0 && "undefined" != typeof(eval(this.fullName + ".pageX")))
   {
    this.styleKey = '';

    if (eval(this.fullName + ".dbWidth"))
    {
     // we have previously set the values - get them from here, since if we changed
     // the clipping region the size will be wrong (it will be clipping size - not native size).
     this.width  = eval(this.fullName + ".dbWidth");
     this.height = eval(this.fullName + ".dbHeight");
    }
    else
    {
     // get the clipping size and save it off since we haven't yet clipped this guy.
     this.width  = eval(this.fullName + ".clip.width");
     this.height = eval(this.fullName + ".clip.height");
     eval(this.fullName + ".dbWidth  = this.width");
     eval(this.fullName + ".dbHeight = this.height");
    }
   }
   else
   {
    this.fullName = "";
    this.tagName  = "";
   }
  }  // end if (document.layers  e.g. NC)
 }
 this.object = null;
 if (this.fullName.length > 0)
  this.object = eval(this.fullName);
}

function objectInfoHide()
{ 
 if (this.fullName.length > 0)
  eval(this.fullName + this.styleKey + ".visibility = 'hidden';");
}

function objectInfoShow()
{
 if (this.fullName.length > 0)
  eval(this.fullName + this.styleKey + ".visibility = 'visible';");
}

function objectInfoSetLeft(left)
{
 if (this.fullName.length > 0)
  eval(this.fullName + this.styleKey + ".left = left");
}

function objectInfoSetTop(top)
{
 if (this.fullName.length > 0)
  eval(this.fullName + this.styleKey + ".top = top");
}

function objectInfoGetPosition()
{
 ret = null;
 if (this.fullName.length > 0)
 {
  if ("undefined" != typeof(eval(this.fullName + ".offsetLeft")))
  {
   ret = new Object;
   ret.left   = eval(this.fullName + ".offsetLeft");
   ret.top    = eval(this.fullName + ".offsetTop");
  }
  else if ("undefined" != typeof(eval(this.fullName + ".pageX")))
  {
   ret = new Object;
   ret.left = eval(this.fullName + ".pageX");
   ret.top  = eval(this.fullName + ".pageY");
  }
 }
 return ret;
}

function objectInfoIsValid()
{
 return (this.fullName.length > 0 && this.object);
}

function objectInfoIsValidIE()
{
 return (this.fullName.length > 0 && this.object && document.all);
}


function objectInfoGetZindex()
{
   if (this.fullName.length > 0)
   {
    ret = eval(this.fullName + this.styleKey + ".zIndex");
    return (ret);
   }
}

function objectInfoSetZindex(ind)
{
  if (this.fullName.length > 0 )
  {
    eval(this.fullName + this.styleKey + ".zIndex = ind");
  }
}

function objectInfoGetDimension()
{

   ret = null;
   ret = new Object;
   if (document.all) {  // IE
      ret.width = eval(this.fullName + ".offsetWidth");
      ret.height = eval(this.fullName + ".offsetHeight");
   }
   else {  // NC
      if (eval(this.fullName + ".dbWidth")) {
         ret.width  = eval(this.fullName + ".dbWidth");
         ret.height = eval(this.fullName + ".dbHeight");
      }
      else {
         ret.width = eval(this.fullName + ".clip.width");
         ret.height = eval(this.fullName + ".clip.height");
      }
   }
    
   return (ret);
}       

function objectInfoSetDimension(w, h)
{
   if (document.all) { // IE
     eval(this.fullName + this.styleKey + ".width = w");
     eval(this.fullName + this.styleKey + ".height = h");
   }
   else { // NC
     if (eval(this.fullName + ".clip.width")) {
        eval(this.fullName + ".clip.width = w");
        eval(this.fullName + ".clip.height = h");
     }
     eval(this.fullName + ".dbWidth = w");
     eval(this.fullName + ".dbHeight = h");
   }
   this.width = w;
   this.height = h;
}

function objectInfoShiftTo(x, y)
{
   if (document.all) { // IE
      eval(this.fullName + this.styleKey + ".left = x");
      eval(this.fullName + this.styleKey + ".top  = y");
   }
   else { // NC
      eval(this.fullName + ".moveTo(x,y)");
   }
}
function document_onLoad() {
Finance.focus();
 }
function Finance__onChange() {
var i

principal = new String()
outprincipal = new String()
newprincipal = new String()

principal = Finance.getText()
principal = principal.toString()
outprincipal = ""
newprincipal = ""

for (i = 1; i <= principal.length; i++){ 
    inchar = principal.substring(i-1,i) 
    if ((inchar >= "0") && (inchar <= "9")) {
       newprincipal = newprincipal + inchar
    }
}

principal = newprincipal

for (i = 0; i < principal.length; i++){
      outprincipal = principal.substring(principal.length - i -1, principal.length - i) + outprincipal
      switch (outprincipal.length) {
             case 3 : 
                  if (principal.length > 3) {
                     outprincipal = "," + outprincipal 
                  }
                  break;
             case 7 : 
                  if (principal.length > 6) {
                     outprincipal = "," + outprincipal
                  }
                  break;
   }
 }
outprincipal = "$" + outprincipal
Finance.setText(outprincipal)
 }
function _Finance__onChange() { if (Finance) return Finance.onChange(); }
function ImageButton1_onClick() {
var i
buildpayment = new String() 
outpayment = new String()
numerate = new Number()
base = new Number()
exp = new Number()

principal = Finance.getText()
principal = principal.toString()
newprincipal = ""
interest = eval(InterestRate.getText())
interest = (interest/12)/100
term = eval(Term.getText())
term = term * 12

for (i = 1; i <= principal.length; i++){ 
    inchar = principal.substring(i-1,i) 
    if ((inchar >= "0") && (inchar <= "9")) {
       newprincipal = newprincipal + inchar
    }
}

beforeprinc = (interest * newprincipal) / (1-Math.pow(1+interest,-1*term))
newpayment = beforeprinc * 100
newpayment=Math.round(newpayment)/100;
buildpayment = newpayment.toString()

for (i = 0; i < buildpayment.length; i++) {
   outpayment = buildpayment.substring(buildpayment.length - i -1,buildpayment.length - i) + outpayment
   switch (outpayment.length) {
        case 6 :
               if (buildpayment.length > 6) { 
                  outpayment = "," + outpayment;
               }
               break;
        case 11:
               if (buildpayment.length > 10) { 
                  outpayment = "," + outpayment;
               }
   }    
}

payment.setText("$" + outpayment);
var objInfo = new objectInfo("interestmsg");
objInfo.hide();
var objInfo = new objectInfo("termmsg");
objInfo.hide();
if ( eval(InterestRate.getText()) < "1") {
   var objInfo = new objectInfo("interestmsg");
   objInfo.show();
}
if ( eval(Term.getText()) > "20") {
   var objInfo = new objectInfo("termmsg");
   objInfo.show();
}
 }
function _ImageButton1_onClick() { if (ImageButton1) return ImageButton1.onClick(); }
function ImageButton2_onClick() {
var i
buildpayment = new String() 
outpayment = new String()
numerate = new Number()
base = new Number()
exp = new Number()

pmt = payment.getText()
pmt = pmt.toString()
newpmt = ""
interest = eval(InterestRate.getText())
interest = (interest/12)/100
term = eval(Term.getText())

for (i = 1; i <= pmt.length; i++){ 
    inchar = pmt.substring(i-1,i) 
    if ((inchar >= "0") && (inchar <= "9") || (inchar == ".")) {
       newpmt = newpmt + inchar
    }
}

newloan = newpmt * (1/interest) * (1-Math.pow(1/(1+interest), term*12));
newloan=Math.round(newloan);


buildpayment = newloan.toString()

for (i = 0; i < buildpayment.length; i++) {
   outpayment = buildpayment.substring(buildpayment.length - i -1,buildpayment.length - i) + outpayment
   switch (outpayment.length) {
        case 3 :
               outpayment = "," + outpayment;
               break;
        case 8:
               if (buildpayment.length > 10) { 
                  outpayment = "," + outpayment;
               }
   }    
}
Finance.setText("$" + outpayment);
var objInfo = new objectInfo("interestmsg");
objInfo.hide();
var objInfo = new objectInfo("termmsg");
objInfo.hide();
if ( eval(InterestRate.getText()) < "1") {
   var objInfo = new objectInfo("interestmsg");
   objInfo.show();
}
if ( eval(Term.getText()) > "20") {
   var objInfo = new objectInfo("termmsg");
   objInfo.show();
}
 }
function _ImageButton2_onClick() { if (ImageButton2) return ImageButton2.onClick(); }


