//begin_lib

//  Copyright (C) 2002 - 2005 by Walter Harder ALL RIGHTS RESERVED
//  e-mail walter@walterharder.ca

function colour(c){
c.style.background = "#E7E0D8";
c.select();
}

function clr(c){
c.style.background = "white";
}

<!-- Tool Tip functions -->
function ShowToolTip(ID){

    if(!document.getElementById) return;
    var obj=document.getElementById(ID);
    obj.style.left = "10px";
    obj.style.top = "10px";
    obj.style.position = "absolute";
    obj.style.display = "block";

}
var Help = false;
function HideToolTip(ID){
    if(!document.getElementById) return;
    var obj=document.getElementById(ID);
    obj.style.display = "none";
}

function ShowTip(ID){
if (Help) ShowToolTip(ID);
}

function ShowHelp(){
	if(!document.getElementById) return;
	var obj=document.getElementById("Body");

Help = !(Help);
HideToolTip("whatsthis");
if (Help) {
document.body.style.cursor = "help";
window.status="What\'s This? mode";
}
else {
document.body.style.cursor = "";
window.status="";
}
}
<!-- End Tool Tip functions -->

<!-- Start of Dollar Function to Strip Out Non-numeric Characters --->

function dollar(inum,dlr)
{
var num2 = inum.value;
var num = "";
var sign = (num2 < 0);
if (num2.substring(0,1) == "(") sign = true;
for (var i = 0; i < num2.length; i++)
{
var chr = num2.substring(i, i + 1);
if ((chr >= "0" && chr <= "9") || chr == '.' || chr == '-') num += chr;
}
num = num.toString().replace(/\$|\,/g,'');
if (isNaN(num)) num = "0";

num = Math.floor(Math.abs(num)*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10) cents = "0" + cents;
if(dlr)
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
if(dlr) {
inum.value = (((sign)?'-':'') + '$' + num + '.' + cents);
}
else { <!-- no dollar sign -->
inum.value = (((sign)?'-':'') + num + '.' + cents);
}
if (dlr == 1) CalcIt();
}

<!-- End of Dollar Function --->

<!-- Start of Nubmr Function to Strip Out Non-numeric Characters --->

function numbr(inum,comma)
{
var num2 = inum.value;
var num = "";
var sign = (num2 < 0);

for (var i = 0; i < num2.length; i++)
{
var chr = num2.substring(i, i + 1);
if ((chr >= "0" && chr <= "9") || chr == '.' || chr == '-')
num += chr;
}
num = num.toString().replace(/\$|\,/g,'');
if (isNaN(num)) num = "0";

num = Math.floor(Math.abs(num)*100+0.50000000001);
num = Math.floor(num/100).toString();
if(comma)
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
inum.value = (((sign)?'-':'') + num );
}

<!-- End of numbr Function --->


<!-- Start of formatdollar function to format numbers as currency -->
function formatdollar(numbr,cts){
if (numbr == 0) {
	return ("");
    } else {
var sign = (numbr < 0);
var num = Math.floor(Math.abs(numbr)*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10) cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
if((cts==0) || (cts==false) ) return (((sign)?'-':'') + '$' + num);
else return (((sign)?'-':'') + '$' + num + '.' + cents);

//if(cts>0) return (((sign)?'-':'') + '$' + num + '.' + cents);
//else return (((sign)?'-':'') + '$' + num);
}
}
<!-- End of formatdollar Function --->

<!-- Start: of formatpct Function to format numbers as percentage (with decimals) -->
function formatpct(numbr,decimals){
var num = Math.floor((numbr) * Math.pow(10,decimals)+.5) + "";
var rtn = num / Math.pow(10,decimals);
if (isNaN(rtn)) rtn = "0";
return (rtn.toString() + "%");
}
<!-- End of formatpct Function --->

<!-- Start of formatnbr Function to format numbers (with decimals) -->
function formatnbr(numbr,decimals){
var num = Math.floor(numbr * Math.pow(10,decimals)) + "";
var rtn = num / Math.pow(10,decimals);
if (isNaN(rtn)) rtn = "0";
return (rtn);
}
<!-- End of formatnbr Function --->

<!-- strip function removes $ and commas from formatted screen text. -->

function strip(input){
return(input.replace(/\$|,|%/g,""));
}
<!-- End of strip Function --->

<!-- Start Function lupd to show last update to page -->
function lupd(){
var Months = ["January","February","March","April","May","June","July","August","September","October","November","December"];
var LastModDate=new Date(document.lastModified);
var Year = LastModDate.getYear();
if (Year < 2000) Year = Year + 1900;
var updated = Months[(LastModDate.getMonth())]+' '+LastModDate.getDate()+', '+Year;
document.write('<div class="upd">This page last updated '+updated+'</div>');
}

<!-- Start Function checkBrowser to warn if browser is too old -->
function checkBrowser(){
var msg = 'For these calculators to work, you need to upgrade your browser to the latest version of '+
'Internet Explorer or Netscape Navigator<BR>'+
'<a href ="http://www.microsoft.com/windows/ie/default.asp"><img src="images/IE.gif" border="0"></a>&nbsp;&nbsp;'+
'<a href ="http://channels.netscape.com/ns/browsers/download.jsp"><img src="images/Netscape.gif" border="0"></a>';
    if (!document.getElementById) document.write(msg);
}

// end_lib
