function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function jump(targ,selObj,restore){ //v3.0
	if (selObj.options[selObj.selectedIndex].value) 
		eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}

function addbookmark() {
	bookmarkurl="http://www.realflip.net/eng402/"
	bookmarktitle="WWU What Can I Do With An English Major?"
	if (document.all)
	window.external.AddFavorite(bookmarkurl,bookmarktitle)
}

///////// Math rounding function //////
// Permission to use/change this code is granted for all puposes
// as long as this header remains in tact.
//
// Parameters --
//   input  -- pass in any number (int,float)
//   output -- returns a string representing the input
//             rounded off to 100ths place
//
//  (C) 1996 Andy Augustine for Frequency Graphics 3.1.96
//
dtuition = 0
dbooks = 0
dfees = 0
dsupplies = 0
drent = 0
dutils = 0
dphone = 0
dboard = 0
dpers = 0
dbus = 0
dcomm = 0
dcarinsur = 0
dhthinsur = 0
ddoctors = 0
dprescrip = 0
dlaundry = 0
ddrugs = 0
dmovies = 0
deother = 0
dunsub = 0
ddepend = 0
demerg = 0
doexp = 0
geducation = 0
gTotal = 0

function isFieldBlank(theField)
{
  if(theField.value.length == 0)
  {
   alert("All fields must be completed.")
   theField.focus()
   return true
  }
  else
   return false
}

function moneyFormat(input)
{
  var dollars = Math.floor(input)
  var cents  = "" + Math.round(input * 100)
  cents = cents.substring(cents.length-2, cents.length)
  if (cents == "0")
  {
    input = dollars + ".00"
  }
  else
  {
    input = dollars + "." + cents
  }
  return input
}

function balanceFormat(input)
{
  var dollars = 0
  var cents = 0
  if (input < 0)
  {
    dollars = Math.ceil(input)
  }
  else
 {
   dollars = Math.floor(input)
 }
 cents  = "" + Math.round(input * 100)
 cents = cents.substring(cents.length-2, cents.length)
 if ((input < 0) && (input > -1) && (cents == "0"))
 {
   input = "-" + dollars + ".00"
 }
 else if ((input < 0) && (input > -1) && (cents != "0"))
 {
   input = "-" + dollars + "." + cents
 }
 else if ((input >=0) || (input < -1))
 {
   if (cents == "0")
   {
     input = dollars + ".00"
   }
   else
   {
     input = dollars + "." + cents
   }
 }
 return input
}

function checkNumber(input, msg)
{
  msg = msg + " field has invalid data: " + input.value;
  var str = input.value;
  for (var i = 0; i < str.length; i++)
  {
   var ch = str.substring(i, i + 1)
   if ((ch < "0" || "9" < ch) && ch != '.') 
   {
     alert(msg);
     input.focus()
     return false;
   }
  }
  input.value = str;
  return true;
}

function processCalc(form)
{
// Validate Input
 if ((isFieldBlank(form.education) == true) || (isFieldBlank(form.housing) == true) ||
 (isFieldBlank(form.food) == true) || (isFieldBlank(form.transportation) == true) ||
 (isFieldBlank(form.health) == true) || (isFieldBlank(form.personal) == true) ||
 (isFieldBlank(form.entertain) == true) || (isFieldBlank(form.intpay) == true) ||
 (isFieldBlank(form.depend) == true) || (isFieldBlank(form.emerg) == true) ||
 (isFieldBlank(form.othexp) == true) || (isFieldBlank(form.family) == true) ||
 (isFieldBlank(form.financial) == true) || (isFieldBlank(form.nontax) == true) ||
 (isFieldBlank(form.grant) == true) || (isFieldBlank(form.fedloan) == true) ||
 (isFieldBlank(form.loans) == true) || (isFieldBlank(form.scholar) == true) ||
 (isFieldBlank(form.employ) == true) || (isFieldBlank(form.othinc) == true))
 return false

 if ((!checkNumber(form.education, "Education")) || (!checkNumber(form.housing, "Housing")) ||
 (!checkNumber(form.food, "Food")) || (!checkNumber(form.transportation, "Transportation")) ||
 (!checkNumber(form.health, "Health")) || (!checkNumber(form.personal, "Personal/Misc")) ||
 (!checkNumber(form.entertain, "Entertainment")) || (!checkNumber(form.intpay, "In-School Interest Payments")) ||
 (!checkNumber(form.depend, "Dependent Care")) || (!checkNumber(form.emerg, "Emergencies")) ||
 (!checkNumber(form.othexp, "Other Expenses")) || (!checkNumber(form.family, "Family Contribution")) ||
 (!checkNumber(form.financial, "Financial Assistance")) || (!checkNumber(form.nontax, "Non-Taxable Income")) ||
 (!checkNumber(form.grant, "Financial Aid Grants")) || (!checkNumber(form.fedloan, "Federal Direct Loans")) ||
 (!checkNumber(form.loans, "Loans")) || (!checkNumber(form.scholar, "Scholarships")) ||
 (!checkNumber(form.employ, "Employment")) || (!checkNumber(form.othinc, "Other Income/Resources")))
 return false

// Get Input values
 geducation = parseFloat(form.education.value)
 ghousing = parseFloat(form.housing.value)
 gfood = parseFloat(form.food.value)
 gtrans = parseFloat(form.transportation.value)
 ghealth = parseFloat(form.health.value)
 gpersonal = parseFloat(form.personal.value)
 gentertain = parseFloat(form.entertain.value)
 gintpay = parseFloat(form.intpay.value)
 gothexp = parseFloat(form.othexp.value)
 gfamily = parseFloat(form.family.value)
 gfinance = parseFloat(form.financial.value)
 gnontax = parseFloat(form.nontax.value)
 ggrants = parseFloat(form.grant.value)
 gdepend = parseFloat(form.depend.value)
 gemerg = parseFloat(form.emerg.value)
 gfedloan = parseFloat(form.fedloan.value)
 gloans = parseFloat(form.loans.value)
 gscholar = parseFloat(form.scholar.value)
 gemploy = parseFloat(form.employ.value)
 gothinc = parseFloat(form.othinc.value)

 dtotexp  = geducation + ghousing + gfood + gtrans + ghealth + gpersonal + gentertain
 + gintpay + gdepend + gemerg + gothexp

 dtotinc =  gfamily + gfinance + gnontax + ggrants + gfedloan + gloans + gscholar
 + gemploy + gothinc

 geducation = moneyFormat(geducation)
 ghousing = moneyFormat(ghousing)
 gfood = moneyFormat(gfood)
 gtrans = moneyFormat(gtrans)
 ghealth = moneyFormat(ghealth)
 gpersonal = moneyFormat(gpersonal)
 gentertain = moneyFormat(gentertain)
 gintpay = moneyFormat(gintpay)
 gdepend = moneyFormat(gdepend)
 gemerg = moneyFormat(gemerg)
 gothexp = moneyFormat(gothexp)
 gfamily = moneyFormat(gfamily)
 gfinance = moneyFormat(gfinance)
 gnontax = moneyFormat(gnontax)
 ggrants = moneyFormat(ggrants)
 gfedloan = moneyFormat(gfedloan)
 gloans = moneyFormat(gloans)
 gscholar = moneyFormat(gscholar)
 gemploy = moneyFormat(gemploy)
 gothinc = moneyFormat(gothinc)
 dtotexp = moneyFormat(dtotexp)
 dtotinc = moneyFormat(dtotinc)
 dbalance = dtotinc - dtotexp
 dbalance = balanceFormat(dbalance)

 form.totinc.value = dtotinc
 form.totexp.value = dtotexp
 form.education.value = geducation
 form.housing.value = ghousing
 form.food.value = gfood
 form.transportation.value = gtrans
 form.health.value = ghealth
 form.personal.value = gpersonal
 form.entertain.value = gentertain
 form.intpay.value = gintpay
 form.depend.value = gdepend
 form.emerg.value = gemerg
 form.othexp.value = gothexp
 form.family.value = gfamily
 form.financial.value = gfinance
 form.nontax.value = gnontax
 form.grant.value = ggrants
 form.fedloan.value = gfedloan
 form.loans.value = gloans
 form.scholar.value = gscholar
 form.employ.value = gemploy
 form.othinc.value = gothinc
 form.balance.value = dbalance
 form.balance.focus()
 return true
}

function clearForm(form)
{
 form.totinc.value = ""
 form.totexp.value = ""
 form.education.value = "0.00"
 form.housing.value = "0.00"
 form.food.value = "0.00"
 form.transportation.value = "0.00"
 form.health.value = "0.00"
 form.personal.value = "0.00"
 form.entertain.value = "0.00"
 form.intpay.value = "0.00"
 form.depend.value = "0.00"
 form.emerg.value = "0.00"
 form.othexp.value = "0.00"
 form.family.value = "0.00"
 form.financial.value = "0.00"
 form.nontax.value = "0.00"
 form.grant.value = "0.00"
 form.fedloan.value = "0.00"
 form.loans.value = "0.00"
 form.scholar.value = "0.00"
 form.employ.value = "0.00"
 form.othinc.value = "0.00"
 form.balance.value = ""
}

function educfocus()
{
  document.budget.education.focus()
}

function test(who,category,title)
{
  who = window.open(category + ".htm", "title", "scrollbars=no,width=250,toolbars=no,height=250")
  who.creator = window
}

function emulate()
{
}