var minRate = 5.0;
var maxRate = 11.0;
var minTerm = 10;
var maxTerm = 30;
var defaultRate = 6.5;
var defaultTax = 1.09;
var defaultIns = 0.45;
var defaultTerm = 25;
var toi_TotalSlideCount = 12;
var toi_slideNumber;
var toi_browserIsNetscape = 0;
var popUpWindow = null
var popUpWindowCount = 0
var popUpWindowName = "popUpWindow"

// **********************
function toi_doItWithStyle()
// **********************
{
  toi_getBrowserType();
  toi_preloadImages();
  document.write('<style type="text/css">');
  document.write('.Mblue {text-decoration: none; color:#333fb5; font-size: 12px; line-height: 12pt; font-family: Verdana, Helvetica}');
  document.write('a.blue:hover {text-decoration: underline; color:#000000}');
  document.write('.mwhite {text-decoration: none; color:#FFFFFF; font-size: 11px; line-height: 12pt; font-family: Verdana, Helvetica}');
  document.write('a.white:hover {text-decoration: underline; color:#000000}');
  document.write('.XLblack {text-decoration: none; color:#000000; font-size: 18px; line-height: 10pt; font-family: Verdana, Helvetica}');
  document.write('a.XLblack:hover {text-decoration: underline; color:#F6FF00}');
  document.write('.Lblack {text-decoration: none; color:#000000; font-size: 14px; line-height: 10pt; font-family: Verdana, Helvetica}');
  document.write('a.Lblack:hover {text-decoration: underline; color:#F6FF00}');
  document.write('.Mblack {text-decoration: none; color:#000000; font-size: 12px; line-height: 10pt; font-family: Verdana, Helvetica}');
  document.write('a.Mblack:hover {text-decoration: underline; color:#F6FF00}');
  document.write('.Sblack {text-decoration: none; color:#000000; font-size: 10px; line-height: 10pt; font-family: Verdana, Helvetica}');
  document.write('a.Sblack:hover {text-decoration: underline; color:#F6FF00}');
  document.write( '.swhite {text-decoration: none; color: #FFFFFF; font-size: 7pt; line-height: 11pt; font-family: verdana,arial,helventica}');
  document.write( '.smalltextlink {text-decoration: none; color: #008080; font-size: 11px; line-height: 11pt; font-family: verdana, Arial, Helvetica}');
  document.write( 'a.smalltextlink:hover {text-decoration: underline; color:#0000ff}');
  document.write('.Mtextlink {text-decoration: none; color:#008080; font-size: 12px; line-height: 10pt; font-family: Verdana, Helvetica}');
  document.write('a.Mtextlink:hover {text-decoration: underline; color:#0000ff}');

  document.write('</style>');

}

// *****************************
function toi_getBrowserType()
// *****************************
{
  var browser = navigator.appName
  if (browser == "Netscape")
  {
    toi_browserIsNetscape = 1;
  }
}

// *********************************
function toi_slideShow( increment )
// *********************************
{
  if( increment == 0 )
    window.close();
  else
  {
    if( increment > 0 )
      toi_slideNumber++;
    else
      toi_slideNumber--;
    if( toi_slideNumber > toi_TotalSlideCount )
      toi_slideNumber = 1;
    else if( toi_slideNumber < 1 )
      toi_slideNumber = toi_TotalSlideCount;
  }
  var newSlide = "CaR-PortSlide_" +toi_slideNumber+ ".htm";
  self.location = newSlide;
}


// *************************
function openImageWindow( imageFileName, width, height )
// *************************
{
  //var attrString="toolbar=yes,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=" +width+ ",height=" +height ;
  var attrString="toolbar=yes,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes";
  //window.open(imageFileName,'remote','toolbar=yes,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=" +width+ ',height=' +height+ '');
  toi_openPopUpWindow(imageFileName, width, height, attrString);
  //window.open(imageFileName,'remote', attrString);
}

// *********************************************************
function getCookieVar( forString )
// This function gets the value associated with "forString"
// from the cookie. Return value is numeric
// *********************************************************
{
  var testString = "";
  testString = getCookieStr(forString);
  if( testString == "" )
    return -1;
  else
    return testString.valueOf();
}

// *********************************************************
function getCookieStr( forString )
// This function gets the value associated with "forString"
// from the cookie. Return value is alpa string.
// *********************************************************
{
  var index;
  var namestart;
  var nameend;
  // if this function fails to get a valid string retString
  // will be returned with NULL value.
  var retString = "";
  if(document.cookie)  // is there a cookie?
  {
    // if the cookie exists, get the character position of
    // the first occurance of "forString" in the cookie and
    // assign it to the index variable. -1 is the result
    // when the string is not found within the cookie.
    index = document.cookie.indexOf(forString);
    if (index != -1)
    {
      namestart = (document.cookie.indexOf("=", index) + 1);
      if( namestart == -1 )
        retString = "";
      else
      {
        nameend = document.cookie.indexOf(";", index);
        if (nameend == -1)
        {
          nameend = document.cookie.length;
          retString = document.cookie.substring(namestart, nameend);
        }
        else if ( nameend > namestart )
        {
          retString = document.cookie.substring(namestart, nameend);
        }
      }
    }
  }
  return unescape(retString);
}

// **************************************
function putCookieVar( forString, sVal )
// **************************************
{
  document.cookie = forString+ "=" +sVal
}

// *********************
function changeImages()
// *********************
{
  var i;
	if (document.images)
	{
		for (i=0; i<changeImages.arguments.length; i+=2)
		{
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

//************************
function toi_format(val, post)
//************************
{
  var decpoint;
  var begin;
  var end;
  var valstr;
	var temp_char;

  valstr = "" + val;
  decpoint = valstr.indexOf(".")
  if (decpoint != -1)
  {
    begin = valstr.substring(0,decpoint);
    end = valstr.substring(decpoint+1,valstr.length);
  }
  else
  {
    begin = valstr;
    end = "";
  }
	if (end.length < post)
	{
	  while (end.length < post)
	  {
      end += "0";
    }
  }
	end = end.substring(0,post);
  return (begin+"."+end);
}


// *********************
function toi_pageFooter()
// *********************
{
		document.write('<center><table border="0" cellpadding="0" cellspacing="0">');
			document.write('<tr>');
				document.write('<td valign="top" align="center" class="Sblack">Copyright &copy; 2002 - Cooper and Rock Inc.&nbsp;&nbsp;');
						document.write('All Rights Reserved. <br>');
					//document.write('<font class="Sblack"><i>Design:<b><a href="http://www.3rdorigin.com" target="top" style="color:#000000">3rd Origin</a></b></i>');
					//document.write('<br>');
				document.write('</td>');
			document.write('</tr>');
		document.write('</table>');
}

// *********************************
function toi_standardWindowStatus()
// *********************************
{
  window.status="Cooper and Rock, Fine Custom Homes: Because your home speaks of you.";
}

// *******************************
function toi_writeFrontImageMap()
// *******************************
{
  var SQ = "'";
  document.write('<MAP Name="mHome"><AREA Shape="rect" coords="0,0,112,21" HREF="CaR-Home.htm" ALT="Return to Home Page" onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mCompany"><AREA Shape="rect" coords="0,0,124,22" HREF="CaR-Company.htm" ALT="Facts about Cooper and Rock, Inc." onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');

  document.write('<MAP Name="mPortfolio"><AREA Shape="rect" coords="0,0,112,22" HREF="CaR-Portfolio.htm" ALT="Browse our Portfolio of Houses now Homes" onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mCommunities"><AREA Shape="rect" coords="0,0,112,22" HREF="CaR-Communities.htm" ALT="Communities with the Cooper and Rock touch." onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');

  document.write('<MAP Name="mTrends"><AREA Shape="rect" coords="0,0,112,22" HREF="CaR-Trends.htm" ALT="Current Building Trends" onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mAvailable"><AREA Shape="rect" coords="0,0,112,22" HREF="CaR-Available.htm" ALT="Homes available for purchase." onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mContact"><AREA Shape="rect" coords="0,0,112,21" HREF="CaR-Contact.htm" ALT="Addresses, Phone and email contacts." onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mLinks"><AREA Shape="rect" coords="2,18,107,36" HREF="CaR-Links.htm" ALT="" onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mFAQ"><AREA Shape="rect" coords="0,0,112,22" HREF="CaR-FAQ.htm" ALT="Frequently Asked Questions." onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
}

// *******************************
function toi_writeSubImageMap()
// *******************************
{
  var SQ = "'";
  document.write('<MAP Name="mHome"><AREA Shape="rect" coords="5,0,113,21" HREF="CaR-Home.htm" ALT="Return to Home Page" onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');
  document.write('<MAP Name="mCompany"><AREA Shape="rect" coords="5,0,113,21" HREF="CaR-Company.htm" ALT="Facts about Cooper and Rock, Inc." onClick="if(this.blur)this.blur();"onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');

  document.write('<MAP Name="mPortfolio"><AREA Shape="rect" coords="5,0,113,21" HREF="CaR-Portfolio.htm" ALT="Browse our Portfolio of Houses now Homes" onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');
  document.write('<MAP Name="mCommunities"><AREA Shape="rect" coords="5,1,113,22" HREF="CaR-Communities.htm" ALT="Communities with the Cooper and Rock touch." onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');

  document.write('<MAP Name="mTrends"><AREA Shape="rect" coords="5,0,113,21" HREF="CaR-Trends.htm" ALT="Current Building Trends" onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');
  document.write('<MAP Name="mAvailable"><AREA Shape="rect" coords="5,1,113,23" HREF="CaR-Available.htm" ALT="Homes available for purchase." onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');
  document.write('<MAP Name="mContact"><AREA Shape="rect" coords="5,0,112,22" HREF="CaR-Contact.htm" ALT="Addresses, Phone and email contacts." onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');
  document.write('<MAP Name="mLinks"><AREA Shape="rect" coords="5,18,108,38" HREF="CaR-Links.htm" ALT="" onClick="if(this.blur)this.blur();" onMouseOut="toi_standardWindowStatus();"></MAP>');
  document.write('<MAP Name="mFAQ"><AREA Shape="rect" coords="5,0,113,22" HREF="CaR-FAQ.htm" ALT="Frequently Asked Questions." onClick="if(this.blur)this.blur();" onMouseOut="window.status=' +SQ+ 'Cooper and Rock, Fine Custom Homes: Because your home speaks of you.' +SQ+ ';"></MAP>');
}

// *************************
function toi_writeSubPageTable1()
// *************************
{
  document.write( '<TABLE WIDTH=640 BORDER=0 CELLPADDING=0 CELLSPACING=0>');
  document.write( '<TR>');
  document.write( '<TD rowspan=2 VALIGN=TOP>');
  document.write( '<TABLE Border=0 CELLPADDING=0 CELLSPACING=0>');
  document.write( '<TR>');
  document.write( '<TD rowspan=18 VALIGN=TOP><IMG SRC="images/CaRSub_01.jpg" WIDTH=4 HEIGHT=425></TD>');
  document.write( '<TD><IMG SRC="images/CaRSub_02.jpg" WIDTH=113 HEIGHT=14></TD>');
  document.write( '<TD rowspan=18 VALIGN=TOP><IMG SRC="images/CaRSub_03.jpg" WIDTH=12 HEIGHT=425></TD>');
  document.write( '</TR>');
  document.write( '<TR><TD><IMG Name="iHome" SRC="images/CaR_05.jpg" WIDTH=113 HEIGHT=22 Border=0 usemap=#mHome></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_06.jpg" WIDTH=113 HEIGHT=13></TD></TR>');
  document.write( '<TR><TD><IMG Name="iCompany" SRC="images/CaR_08.jpg" WIDTH=113 HEIGHT=23 Border=0 usemap=#mCompany></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_08.jpg" WIDTH=113 HEIGHT=16></TD></TR>');
  document.write( '<TR><TD><IMG Name="iPortfolio" SRC="images/CaR_11.jpg" WIDTH=113 HEIGHT=23 Border=0 usemap=#mPortfolio></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_11.jpg" WIDTH=113 HEIGHT=16></TD></TR>');
  document.write( '<TR><TD><IMG Name="iCommunities" SRC="images/CaR_15.jpg" WIDTH=113 HEIGHT=23 Border=0 usemap=#mCommunities></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_13.jpg" WIDTH=113 HEIGHT=16></TD></TR>');
  document.write( '<TR><TD><IMG Name="iTrends" SRC="images/CaR_18.jpg" WIDTH=113 HEIGHT=23 Border=0 usemap=#mTrends></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_15.jpg" WIDTH=113 HEIGHT=14></TD></TR>');
  document.write( '<TR><TD><IMG Name="iAvailable" SRC="images/CaR_21.jpg" WIDTH=113 HEIGHT=23 Border=0 usemap=#mAvailable></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_17.jpg" WIDTH=113 HEIGHT=15></TD></TR>');
  document.write( '<TR><TD><IMG Name="iContact" SRC="images/CaR_24.jpg" WIDTH=113 HEIGHT=22 Border=0 usemap=#mContact></TD></TR>');
  document.write( '<TR><TD><IMG Name="iLinks" SRC="images/CaRSub_19.jpg" WIDTH=113 HEIGHT=65 Border=0 usemap=#mLinks></TD></TR>');
  document.write( '<TR><TD><IMG Name="iFAQ" SRC="images/CaR_28.jpg" WIDTH=113 HEIGHT=23 Border=0 usemap=#mFAQ></TD></TR>');
  document.write( '<TR><TD><IMG SRC="images/CaRSub_21.jpg" WIDTH=113 HEIGHT=74></TD></TR>');
  document.write( '</TABLE>');
  document.write( '</TD>');
  document.write( '<TD VALIGN=TOP><IMG SRC="images/CaRSub_04.jpg" WIDTH=511 HEIGHT=72></TD></TD>');
  document.write( '</TR>');
  document.write( '<TR>');
  document.write( '<TD VALIGN=TOP>  ');
}

// ****************************
function toi_writeSlideTable()
// ****************************
{
  var PN = toi_slideNumber;

  document.write( '<TABLE WIDTH=600 BORDER=0 CELLPADDING=0 CELLSPACING=0>');
  document.write( '<TR>');
  document.write( '<TD><IMG SRC="Portfolio/CaR-PortSlide_Title.gif" WIDTH=600 HEIGHT=53></TD>');
  document.write( '</TR>');
  document.write( '<TR>');
  document.write( '<TD><IMG SRC="Portfolio/CaR-PortSlide_' +PN+ '.gif" WIDTH=600 HEIGHT=321></TD>');
  document.write( '</TR>');
  document.write( '<TR>');
  document.write( '<TD><IMG SRC="Portfolio/CaR-PortSlide_Menu.gif" WIDTH=600 HEIGHT=28 Border=0 usemap=#mSlideMenu></TD>');
  document.write( '</TR>');
  document.write( '</TABLE>');
}

// ******************************
function toi_writeSlideMenuMap()
// ******************************
{
  document.write( '<MAP Name="mSlideMenu">');
  document.write( '<AREA type=rect" coords="140,1,214,20" href="javascript:toi_slideShow(-1);" onClick="if(this.blur)this.blur();">');
  document.write( '<AREA type=rect" coords="283,4,324,21" href="javascript:toi_slideShow(0);" onClick="if(this.blur)this.blur();">');
  document.write( '<AREA type=rect" coords="404,4,455,22" href="javascript:toi_slideShow(1);" onClick="if(this.blur)this.blur();">');
  document.write( '</MAP>');
}

// **********************
function toi_newImage(arg)
// ***********************
{
	if (document.images)
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

// *************************
function toi_preloadImages()
// *************************
{
  if (document.images)
  {
		sub1 = toi_newImage("images/CaRSub_01.jpg");
		sub2 = toi_newImage("images/CaRSub_02.jpg");
		sub3 = toi_newImage("images/CaRSub_03.jpg");
		sub4 = toi_newImage("images/CaRSub_04.jpg");
		sub5 = toi_newImage("images/CaRSub_06.jpg");
		sub6 = toi_newImage("images/CaRSub_08.jpg");
		sub7 = toi_newImage("images/CaRSub_09.jpg");
		sub8 = toi_newImage("images/CaRSub_11.jpg");
		sub9 = toi_newImage("images/CaRSub_13.jpg");
		sub10 = toi_newImage("images/CaRSub_15.jpg");
		sub11 = toi_newImage("images/CaRSub_17.jpg");
		sub12 = toi_newImage("images/CaRSub_19.jpg");
		sub13 = toi_newImage("images/CaRSub_20.jpg");
		sub14 = toi_newImage("images/CaRSub_21.jpg");
		sub15 = toi_newImage("images/CaRSub_22.jpg");

		preloadFlag = true;
	}
}

// **********************************
function toi_preLoadPortfolio()
// **********************************
{
  if (document.images)
  {
		subp00 = toi_newImage("Portfolio/CaR-PortSlide_1.gif");
		subp01 = toi_newImage("Portfolio/CaR-PortSlide_2.gif");
		subp02 = toi_newImage("Portfolio/CaR-PortSlide_3.gif");
		subp03 = toi_newImage("Portfolio/CaR-PortSlide_4.gif");
		subp04 = toi_newImage("Portfolio/CaR-PortSlide_5.gif");
		subp05 = toi_newImage("Portfolio/CaR-PortSlide_6.gif");
		subp06 = toi_newImage("Portfolio/CaR-PortSlide_7.gif");
		subp07 = toi_newImage("Portfolio/CaR-PortSlide_8.gif");
		subp08 = toi_newImage("Portfolio/CaR-PortSlide_9.gif");
		subp09 = toi_newImage("Portfolio/CaR-PortSlide_10.gif");
		subp10 = toi_newImage("Portfolio/CaR-PortSlide_11.gif");
		subp11 = toi_newImage("Portfolio/CaR-PortSlide_12.gif");
  }
}

// *********************
function openMortCalc()
// *********************
{
  //window.open('CaR-MortCalc.htm','remote','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no,width=440,height=490');
  toi_openPopUpWindow('CaR-MortCalc.htm', 440, 490, "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbars=no");
}

// *******************
function toi_recalc()
// *******************
{
  var monthlyPayment = 0.00;
  var downpay = 0;
  mortprice = document.MortCalc.fi_Price.value;
  if( mortFocusDPonP > 0 )
  {
    mortDwnPayA = mortprice * document.MortCalc.fi_dpayrate.value;
    document.MortCalc.fi_dpay.value = mortDwnPayA;
    var dpPerc = 100 * document.MortCalc.fi_dpayrate.value;
  }
  else
  {
    mortDwnPayA = document.MortCalc.fi_dpay.value;
    var dpPerc = (mortDwnPayA / mortprice) * 100;
  }

  var principal = mortprice - mortDwnPayA;
  document.MortCalc.fi_Principle.value = principal;
  var intrate = document.MortCalc.fi_intrate.value;
  var tLength = document.MortCalc.fi_TermLength.value;

  var monthlyInterest = intrate / 1200;
  var termInMonths = 0-(tLength*12);
  var c1 = Math.pow( (Number(monthlyInterest)+1.0 ), Number(termInMonths) );

  var principalPlusInterest = Number(principal) * ( monthlyInterest / ( 1.0 - Number(c1)));
  document.MortCalc.fi_st1.value = "" + toi_format(principalPlusInterest,2);

  var taxes = principal * document.MortCalc.fi_tax.value / 1200;
  document.MortCalc.fi_st2.value = "" + toi_format(taxes,2);
  var insrnc = principal * document.MortCalc.fi_ins.value / 1200;
  document.MortCalc.fi_st3.value = "" + toi_format(insrnc,2);
  var pmirate = 0.0;
  if( dpPerc < 10.0 )
    pmirate = 0.9;
  else if( dpPerc < 20.0 )
    pmirate = 0.5;
  document.MortCalc.fi_pmi.value = pmirate;
  document.MortCalc.fi_st4.value = "" + toi_format( (principal * pmirate / 1200),2);
  var totals = Number(document.MortCalc.fi_st1.value) + Number(document.MortCalc.fi_st2.value) + Number(document.MortCalc.fi_st3.value) + Number(document.MortCalc.fi_st4.value);
  document.MortCalc.fi_monthlyPayment.value = toi_format( totals,2);

  toi_setMortCookie();
}

// ***************************************
function toi_getMortgageVariables()
// ***************************************
{
    var mortTempString;
    if( document.cookie )
    {
      mortPrice = getCookieVar( "TOI_MORTPRICE" );
      mortDwnPayP = getCookieVar( "TOI_MORTDPAYP" );
      if(mortDwnPayP == -1 )
        mortDwnPayP = 0;
      mortDwnPayA = getCookieVar( "TOI_MORTDPAYA" );
      if( mortDwnPayA == -1 )
        mortDwnPayA = 0;
      mortIntRate = getCookieVar( "TOI_MORTIRATE" );
      if( mortIntRate == -1 )
        mortIntRate = defaultRate;
      mortTermLength = getCookieVar( "TOI_MORTTERM" );
      if( mortTermLength == -1 )
        mortTermLength= defaultTerm;
      mortTaxRate = getCookieVar( "TOI_MORTTAX" );
      if( mortTaxRate == -1 )
        mortTaxRate = defaultTax;
      mortInsRate = getCookieVar( "TOI_MORTINS" );
      if( mortInsRate == -1 )
        mortInsRate = defaultIns;
      mortPmiRate = getCookieVar( "TOI_MORTPMI" );
      mortFocusDPonP = getCookieVar( "TOI_MORTDPAYFOCUS" );
    }
    else
    {
      mortIntRate = defaultRate;
      mortTermLength = defaultTerm;
      mortTaxRate = defaultTax;
      mortInsRate = defaultIns;
    }
}

// ***********************************
function toi_setMortCookie()
// ***********************************
{
  var cookieString = "";
  cookieString = ""+document.MortCalc.fi_Price.value;
  putCookieVar( "TOI_MORTPRICE", cookieString );
  cookieString = ""+document.MortCalc.fi_dpayrate.value;
  putCookieVar( "TOI_MORTDPAYP", cookieString );
  cookieString = ""+document.MortCalc.fi_dpay.value;
  putCookieVar( "TOI_MORTDPAYA", cookieString );
  cookieString = "" + document.MortCalc.fi_intrate.value;
  putCookieVar( "TOI_MORTIRATE", cookieString );
  cookieString = "" + document.MortCalc.fi_TermLength.value;
  putCookieVar( "TOI_MORTTERM", cookieString );
  cookieString = "" + document.MortCalc.fi_tax.value;
  putCookieVar( "TOI_MORTTAX", cookieString );
  cookieString = "" + document.MortCalc.fi_ins.value;
  putCookieVar( "TOI_MORTINS", cookieString );
  cookieString = "" + document.MortCalc.fi_pmi.value;
  putCookieVar( "TOI_MORTPMI", cookieString );
  cookieString = "" + mortFocusDPonP;
  putCookieVar( "TOI_MORTDPAYFOCUS", cookieString );
}

// ***************************
function toi_changeDwnPayP()
// ***************************
{
  // User changed the downpayment percentage on the mortgage calculator
  // Abandon any value for the downpayment amount and recalc it.
  mortFocusDPonP = 1;
  toi_recalc();
  toi_setMortCookie();
}

// *****************************
function toi_changeDwnPayA()
// *****************************
{
  // User changed the downpayment amound on the mortgage calculator
  mortFocusDPonP = 0;
  document.MortCalc.fi_dpayrate[0].selected = true;
  toi_recalc();
  toi_setMortCookie();
}

// **************************
function toi_mortcalcReset()
// **************************
{
  var i=0;
  document.MortCalc.fi_tax.value = defaultTax;
  document.MortCalc.fi_ins.value = defaultIns;

  mortIntRate = defaultRate;
  for( i=0; i < document.MortCalc.fi_intrate.options.length; i++ )
    if( document.MortCalc.fi_intrate[i].value == mortIntRate )
      document.MortCalc.fi_intrate[i].selected = true;
    else
      document.MortCalc.fi_intrate[i].selected = false;

  mortTermLength = defaultTerm;
  for( i=0; i < document.MortCalc.fi_TermLength.options.length; i++ )
    if( document.MortCalc.fi_TermLength[i].value == mortTermLength )
      document.MortCalc.fi_TermLength[i].selected = true;
    else
      document.MortCalc.fi_TermLength[i].selected = false;

  toi_recalc();
}

function toi_openPopUpWindow(daURL, daWidth, daHeight, daFeatures)
{
  popUpWindowName = "popUpWindow" + popUpWindowCount++;
  toi_closePopUpWindow();
  if (toi_openPopUpWindow.arguments.length >= 4)
     daFeatures = "," + daFeatures;
   else
     daFeatures = "";
   popUpWindow = window.open(daURL, popUpWindowName, "width=" + daWidth + ",height=" + daHeight + daFeatures);
}
function toi_closePopUpWindow()
{
  if( navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4)
    if(popUpWindow != null)
      if(!popUpWindow.closed)
        popUpWindow.close()
}


