function Is ()
{   // convert all characters to lowercase to simplify testing
    var agt=navigator.userAgent.toLowerCase()
    // *** BROWSER VERSION ***
    this.major = parseInt(navigator.appVersion)
    this.nav  = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
                && (agt.indexOf('compatible') == -1)))
    this.nav4 = (this.nav && (this.major == 4))
    this.nav4up = this.nav && (this.major >= 4)
    this.ie   = (agt.indexOf("msie") != -1)
    this.ie4  = (this.ie && (this.major == 4))
    this.ie4up  = this.ie  && (this.major >= 4)
}
var is = new Is();

function setUpHelp()
{
   maketheBalloon("food",200,"Food = breakfast, lunch, school lunch, snacks, dinner, dessert, coffee, juice, soda, water, groceries");
   maketheBalloon("transportation",200,"Transportation = gasoline, parking & tolls, public transit, auto maintentance & repairs, auto registration & tags &taxes, car wash");
   maketheBalloon("entertainment",200,"Entertainment = newspaper, magazines, books, video & dvd rentals, cd & video & dvd purchases, hobbies, sports, movies, concerts, plays, nightclubs, bars, software, games, etc.");
   maketheBalloon("miscellaneous",200,"Miscellaneous = cigarettes, alcohol, lottery tickets, charitable donations, church tithes, internet access, legal fees, financial service fees, etc.");
   maketheBalloon("childcare",200,"Child Care = daycare, babysitters, diapers, formula, clothes, school supplies, allowance, tuition, child support, etc.");
   maketheBalloon("petcare",200,"Pet Care = food, toys, vet services, grooming, etc.");
   maketheBalloon("selfcare",200,"Self Care = cosmetics, toiletries, beauty & barber shop, nail care, hair care, health club fees, etc.");
   maketheBalloon("medicalcare",200,"Medical Care = medical costs, dental costs, optical costs, glasses, contacts, prescriptions, vitamins");
   maketheBalloon("clothing",200,"Clothing = clothes and shoes for the entire family, accessories, laundry, dry cleaning");
   maketheBalloon("gifts",200,"Gifts = cards, birthday & anniversary presents, wedding & shower presents, Christmas presents, special person or event gifts, etc.");
   maketheBalloon("utilities",200,"Utilities = gas, electric, water, sewer, telephone, cell phone, beeper, cable TV, etc.");
   maketheBalloon("home",200,"Home = rent or mortgage, second mortgage, property tax, property insurance, association dues, home maintenance & repairs, trash collection, maid service, furnishings, lawn maintenance, pool expenses, etc.");
   maketheBalloon("savings",200,"Savings = emergency fund, retirement funds, pension contributions, stocks and bonds, college funds, other savings");
   maketheBalloon("education",200,"Education = adult tuition, adult lab fees, adult books, school supplies");
   maketheBalloon("loans",200,"Loans = car payments, loan payments, student loan payments, credit card payments, other payments");
   maketheBalloon("insurance",200,"Insurance Payments = premiums paid for medical, dental, optical, disability, life, auto and home insurance");
   maketheBalloon("incometaxes",200,"Income Taxes = federal, state, local, social security (FICA), medicare");
   maketheBalloon("other",200,"Other = alimony payments, vacations, etc.");
}

function maketheBalloon(id, width, message)
{
   var theString = '<STYLE TYPE="text/css">#'+id+'{width:'+width+';}</STYLE>';
   theString+='<DIV CLASS="balloon" id="'+id+'">'+message+'</DIV>';
   document.write(theString);
}

function makeItVisible(id, event)
{
        if (is.nav4up) {
                document.layers[id].left = event.pageX + 10;
                document.layers[id].top = event.pageY + 10;;
                document.layers[id].visibility="show";
        }
        else {
                document.all[id].style.pixelLeft = (document.body.scrollLeft +event.clientX) + 10;
                document.all[id].style.pixelTop = (document.body.scrollTop + event.clientY) + 10;
                document.all[id].style.visibility="visible";
        }    
}

function hideHelp(id)
{
        is.nav4up ? document.layers[id].visibility="hide" : document.all[id].style.visibility="hidden";
}
function openWin( windowURL, windowName, windowFeatures ) 
{
		aName=window.open( windowURL, windowName, windowFeatures );
		return aName;
}
function updCalc(input)
{
        var nttlspent = 0;
		var ttlspent = 0
		var nttlspent2 = 0;
        //if (input.form.mspendable2.value != null && input.form.mspendable2.value.length != 0)
        //{
                //nmttl = eval(input.form.mtotal.value)
				//mspendable = eval(input.form.mspendable2.value);
               //nless = Math.round(nmttl * .28);
                //nspendable = nmttl - nless;
                //input.form.less.value = nless;
                //input.form.mspendable.value = mspendable2;
                //input.form.mspendable2.value = nspendable;
        //}               
        if (input.form.Food_current.value != null && input.form.Food_current.value.length != 0)
        	{ nttlspent += eval(input.form.Food_current.value); }
        if (input.form.Transportation_current.value != null && input.form.Transportation_current.value.length != 0)
        	{ nttlspent += eval(input.form.Transportation_current.value); } 
        if (input.form.Entertainment_current.value != null && input.form.Entertainment_current.value.length != 0)
        	{ nttlspent += eval(input.form.Entertainment_current.value); }
        if (input.form.Miscellaneous_current.value != null && input.form.Miscellaneous_current.value.length != 0)
        	{ nttlspent += eval(input.form.Miscellaneous_current.value); }
        if (input.form.ChildCare_current.value != null && input.form.ChildCare_current.value.length != 0)
        	{ nttlspent += eval(input.form.ChildCare_current.value); }
	    if (input.form.PetCare_current.value != null && input.form.PetCare_current.value.length != 0)
        	{ nttlspent += eval(input.form.PetCare_current.value); }
	    if (input.form.SelfCare_current.value != null && input.form.SelfCare_current.value.length != 0)
        	{ nttlspent += eval(input.form.SelfCare_current.value); }
	    if (input.form.MedicalCare_current.value != null && input.form.MedicalCare_current.value.length != 0)
        	{ nttlspent += eval(input.form.MedicalCare_current.value); }
	    if (input.form.Clothing_current.value != null && input.form.Clothing_current.value.length != 0)
        	{ nttlspent += eval(input.form.Clothing_current.value); }
	    if (input.form.Gifts_current.value != null && input.form.Gifts_current.value.length != 0)
        	{ nttlspent += eval(input.form.Gifts_current.value); }
	    if (input.form.Utilities_current.value != null && input.form.Utilities_current.value.length != 0)
        	{ nttlspent += eval(input.form.Utilities_current.value); }
	    if (input.form.Home_current.value != null && input.form.Home_current.value.length != 0)
        	{ nttlspent += eval(input.form.Home_current.value); }
	    if (input.form.Savings_current.value != null && input.form.Savings_current.value.length != 0)
        	{ nttlspent += eval(input.form.Savings_current.value); }
	    if (input.form.Education_current.value != null && input.form.Education_current.value.length != 0)
        	{ nttlspent += eval(input.form.Education_current.value); }
	    if (input.form.Loans_current.value != null && input.form.Loans_current.value.length != 0)
        	{ nttlspent += eval(input.form.Loans_current.value); }
	    if (input.form.InsurancePayments_current.value != null && input.form.InsurancePayments_current.value.length != 0)
        	{ nttlspent += eval(input.form.InsurancePayments_current.value); }
	    if (input.form.Other_current.value != null && input.form.Other_current.value.length != 0)
        	{ nttlspent += eval(input.form.Other_current.value); }			
 

        input.form.Spending_current.value=nttlspent;
        input.form.Leftover_current.value=input.form.MonthlyIncome_current.value-nttlspent;

return true;
}
function clearForm(input,from,to)
{
  input.form.Food_current.value="";
  input.form.Transportation_current.value="";
  input.form.Entertainment_current.value="";  
  input.form.Miscellaneous_current.value="";  
  input.form.ChildCare_current.value=""; 
  input.form.PetCare_current.value="";  
  input.form.SelfCare_current.value="";   
  input.form.MedicalCare_current.value="";
  input.form.Clothing_current.value="";
  input.form.Gifts_current.value="";
  input.form.Utilities_current.value="";
  input.form.Home_current.value="";
  input.form.Savings_current.value="";
  input.form.Education_current.value="";
  input.form.Loans_current.value="";
  input.form.InsurancePayments_current.value="";
  input.form.IncomeTaxes_current.value="";
  input.form.Other_current.value="";
  input.form.MonthlyIncome_current.value="0";
  input.form.Leftover_current.value="0";
  input.form.Spending_current.value="0";
 
        return true;
}
function clearForm2(input,from,to)
{
  input.form.Food_desired.value="";
  input.form.Transportation_desired.value="";
  input.form.Entertainment_desired.value="";  
  input.form.Miscellaneous_desired.value="";  
  input.form.ChildCare_desired.value=""; 
  input.form.PetCare_desired.value="";  
  input.form.SelfCare_desired.value="";   
  input.form.MedicalCare_desired.value="";
  input.form.Clothing_desired.value="";
  input.form.Gifts_desired.value="";
  input.form.Utilities_desired.value="";
  input.form.Home_desired.value="";
  input.form.Savings_desired.value="";
  input.form.Education_desired.value="";
  input.form.Loans_desired.value="";
  input.form.InsurancePayments_desired.value="";
  input.form.IncomeTaxes_desired.value="";
  input.form.Other_desired.value="";
  input.form.MonthlyIncome_desired.value="0";
  input.form.Leftover_desired.value="0";
  input.form.Spending_desired.value="0";

        return true;
}
