// Fix browser display issues
function chkBrowser() {
	/*if (navigator.appName.indexOf("Microsoft") >= 0) { // if Browser is Microsoft...
	}
	else {
		document.getElementById("ulTopNav").style.MarginTop = "10px";
	}*/
}

function popWin(theFile) {
	poppedWin = window.open(theFile,
						'poppedWin',
						'width=400,height=550,top=10,left=10,screenx=10,screeny=10,resizable=yes');
}

// BEGIN Code related to the Mortgage Calculator
function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function _calc() {
  var mi = document.piti.interest.value / 1200;
  var base = 1;
  var mbase = 1 + mi;
  for (i=0; i<document.piti.years.value * 12; i++)
  {
    base = base * mbase;
  }
  document.piti.p_i.value = floor(document.piti.amt.value * mi / ( 1 - (1/base)));
  document.piti.mtax.value = floor(document.piti.tax.value / 12);
  document.piti.mins.value = floor(document.piti.ins.value / 12);
  document.piti.mhoassn.value = floor(document.piti.hoassn.value / 12);
  var _sum = document.piti.amt.value * mi / ( 1 - (1/base)) +
	document.piti.tax.value / 12 + 
	document.piti.ins.value / 12 +
	document.piti.hoassn.value / 12;
  document.piti.mpay.value = floor(_sum);
}

function clearVal(_field) {
	curVal = _field.value;
	_field.value='';
}

function checkVal(_field) {
	if (_field.value == '') { //if, on exit, the field is blank and a
		if (curVal)			  // previous value exists, re-enter it
		_field.value=curVal;
	}
	else {					  // otherwise check the new value
		var newVal = '';
		var v = _field.value;
		for (i=0;i<v.length;i++) {
			_char = v.substring(i,i+1);  // check each character for num or dot
			if ((!isNaN(_char) && !isNaN(parseInt(_char))) || _char == '.')
				newVal += _char;  // create new value composed of only those chars
		}
		if (newVal == '')
			newVal = curVal;
		_field.value=newVal;
	}
}

function _reset() {
	document.piti.reset();
}
// END Code related to the Mortgage Calculator
