function openWin(file,windowName,w,h,prop)
{
	// some values that can be passed
	// width=600,height=500,left=20,top=20,scrollbars=yes,resizable=yes
	var winl = (screen.width - w) / 2;
	var wint = ((screen.height - h) / 2) - 25;
	var ObjWin = new Object()
	ObjWin.win = window.open(file, windowName, prop+',top='+wint+',left='+winl+',width='+w+',height='+h)
	if (parseInt(navigator.appVersion) >= 4) { ObjWin.win.window.focus(); }
}

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function dosum()
{
  // interest rate
  var mi = replaceChars('%','',document.mortgage_calculator.IR.value) / 1200;
  // loan amount
  var la = replaceChars(',','',document.mortgage_calculator.LA.value);la = replaceChars('$','',la);
  // down payment
  var dp = replaceChars(',','',document.mortgage_calculator.DP.value);dp = replaceChars('$','',dp);
  // create new lown amount
  la = (la-dp);
  // property taxes
  var at = replaceChars(',','',document.mortgage_calculator.AT.value);at = replaceChars('$','',at);
  // Insurance
  var ai = replaceChars(',','',document.mortgage_calculator.AI.value);ai = replaceChars('$','',ai);
  // HOA Fees
  var ah = replaceChars(',','',document.mortgage_calculator.AH.value);ah = replaceChars('$','',ah);
  var base = 1;
  var mbase = 1 + mi;
  for (i=0; i<document.mortgage_calculator.YR.value * 12; i++)
  {
    base = base * mbase
  }
  document.mortgage_calculator.PI.value = floor(la * mi / ( 1 - (1/base)))
  document.mortgage_calculator.MT.value = floor(at / 12)
  document.mortgage_calculator.MI.value = (floor(ai / 12) + floor(ah / 12))
  var dasum = la * mi / ( 1 - (1/base)) +
        at / 12 + 
        ai / 12 +
		ah / 12;
  document.mortgage_calculator.MP.value = floor(dasum);
}


function replaceChars(char_find,char_replace_with,entry)
{
	temp = "" + entry; // temporary holder

	while (temp.indexOf(char_find)>-1)
	{
		pos= temp.indexOf(char_find);
		temp = "" + (temp.substring(0, pos) + char_replace_with + 
		temp.substring((pos + char_find.length), temp.length));
	}
	return temp;
}

function FlashInstalledAdmin()
{
	result = false;

	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"])
	{
		result = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin;
	}
	else if (document.all && (navigator.appVersion.indexOf("Mac")==-1))
	{
		// IE Windows only -- check for ActiveX control, have to hide code in eval from Netscape (doesn't like try)
		eval ('try {var xObj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");if (xObj)	result = true; xObj = null;	} catch (e)	{}');
	}
	return result;
}

function FlashWriteAdmin(url,width,height,bgcolor,FlashVars)
{
	if (FlashInstalledAdmin())
	{
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="' + width + '" height="' + height + '" id="home1" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="' + url + '" /><param name="quality" value="high" /><PARAM NAME="FlashVars" Value="' + FlashVars + '" /><PARAM NAME=bgcolor VALUE=' + bgcolor + ' />'); 
		document.write('<embed src="' + url + '" quality="high" width="' + width + '" height="' + height + '" name="home1" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="' + FlashVars + '"  bgcolor="' + bgcolor + '" />');
		document.write('</object>');
	}
	else
	{
		document.write('The Flash Player is Required to View This Part of the Page.');
	}
}
