/* ****************************************************************** */
function at_show_aux(parent,child) {
var p = document.getElementById(parent);
var c = document.getElementById(child );
var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;
for (; p; p = p.offsetParent) {
  top  += p.offsetTop;
  left += p.offsetLeft;
  }
c.style.position   = "absolute";

//Beg iManPro Hack

divleft = document.getElementById(parent).offsetLeft;
divtop  = document.getElementById(c["at_div"]).offsetTop;
top  = top-divtop;
left = divleft;
//alert(top); alert(divtop); alert(left);
//end iManPro Hack

c.style.top        = (top+(c["at_tpx"]*1))  +'px';
c.style.left       = (left+(c["at_lpx"]*1)) +'px';
c.style.display    = "";
}
// ***** at_show *****
function at_show(tpx,lpx) {
var p = document.getElementById(this["at_parent"]);
var c = document.getElementById(this["at_child" ]);
at_show_aux(p.id,c.id);
clearTimeout(c["at_timeout"]);
}
// ***** at_hide *****
function at_hide() {
var p = document.getElementById(this["at_parent"]);
var c = document.getElementById(this["at_child" ]);
c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.display = 'none'", 100);
}
// ***** at_click *****
function at_click() {
var p = document.getElementById(this["at_parent"]);
var c = document.getElementById(this["at_child" ]);
if (c.style.display != "none") at_show_aux(p.id, c.id); else c.style.display = "none";
  return false;
}
function at_attach(parent,child,showtype,position,cursor,tpx,lpx,div) {
var p = document.getElementById(parent);
var c = document.getElementById(child);
p["at_parent"]     = p.id;     c["at_parent"]     = p.id;
p["at_child"]      = c.id;     c["at_child"]      = c.id;
p["at_position"]   = position; c["at_position"]   = position;
c.style.position   = "absolute";
c.style.display    = "none";
c.style.zIndex     = "5000"; 
c["at_tpx"]=tpx; c["at_lpx"]=lpx; c["at_div"]=div; 
if (cursor != undefined) p.style.cursor = cursor;
switch (showtype) {
  case "click":
   p.onclick     = at_click; p.onmouseout  = at_hide;
   c.onmouseover = at_show; c.onmouseout  = at_hide;
   break;
  case "hover":
   p.onmouseover = at_show; p.onmouseout  = at_hide;
   c.onmouseover = at_show; c.onmouseout  = at_hide;
   break;
  }
}
/* ****************************************************************** */
function getSpec() {
var x=document.forms[0].sid;
if (!x.value) {
  alert('Invalid or Missing Unit. Ask your Sales Associate for Help');
  return false;
  }
x=x.value;
var URL='/spec/'+ x;
location.href=URL;
}
var state = 'none';
/* ****************************************************************** */
function tableOver() {
if (document.getElementById && document.createTextNode) {
  var tables=document.getElementsByTagName('table');
  for (var i=0;i<tables.length;i++) {
    if(tables[i].className=='tblWrap'||tables[i].className=='tblWrapNp') {
      var trs=tables[i].getElementsByTagName('tr');
      for(var j=0;j<trs.length;j++) {
        if(trs[j].parentNode.nodeName=='TBODY') {
          if (j>0) {
	         trs[j].onmouseover=function(){this.className='rowOver';return false}
	         trs[j].onmouseout=function(){this.className='rowCell';return false}
	         }
	       }
	     }
      }
    }
  }
}
/* ****************************************************************** */
function wrDate(){
var theDate=new Date();
document.write(theDate.getFullYear());
}
/* ****************************************************************** */
//Figure Loan Payment for Total Financed
function getPayment() {
var x=document.forms['F1'];
var totl=x.totlP.value;
if (isNaN(totl)) {
  x.paymentP.value='NA';
  return false;
  }
var i=x.intrP.value;
if (i == parseFloat(i)){
  var intr=(i/100/12);
  } else {
  x.paymentP.value='NA';
  return false;
  }
var term=x.termP.options[x.termP.selectedIndex].value;
var z=(totl*intr)/(1-Math.pow(1+intr,-term));
z=Math.round(z*1)/1
if (z == parseFloat(z)){
   x.paymentP.value=z;
  }
}
//Figure Total Afford based on Payment/Int/Term
function getAfford() {
var x=document.forms['F1'];
var p=x.paymentA.value;
if (isNaN(p)) {
  x.totlA.value='NA';
  }
var i=x.intrA.value;
if (i == parseFloat(i)){
  var intr=(i/100/12);
  } else {
  x.totlA.value='NA';
  }
var term=x.termA.options[x.termA.selectedIndex].value;
var z = 1*(0+p*(1+intr*0)*((Math.pow(1+intr,term))-1)/intr)/(Math.pow(1+intr,term));
z=Math.round(z*1)/1
if (z == parseFloat(z)){
  x.totlA.value=z;
  }
}
/* ****************************************************************** */
