
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) { //v3.0

  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); 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 resetme(){
	
	document.EmailFRM.submit();
	
	document.EmailFRM.Name.value=""; // reset input type=text
	document.EmailFRM.Email.value=""; // reset input type=text
	document.EmailFRM.DayPhone.value=""; // reset input type=text
	document.EmailFRM.NightPhone.value=""; // reset input type=text
	document.EmailFRM.Comments.value=""; // reset input type=text	
	document.EmailFRM.Interest.selectedIndex=-1; // reset select	
	
}

var irate, mi, cmi, years, tprinc, princ, paym, cpaym, osp,v,downp,downr,comp;
function calcPaym(cdn){
   tprinc = round2d(parseFloat(document.smpc.tprinc.value));
   downp = .01*parseFloat(document.smpc.downp.value);
   downr = ceil2d(downp*tprinc);
   princ = tprinc-downr;

   document.smpc.princ.value = fmt2d(princ,0);
   document.smpc.downr.value = fmt2d(downr,0);

   if(cdn)comp="Canadian"; else comp="U.S";
   document.smpc.comp.value = comp;

   irate = .01*parseFloat(document.smpc.percent.value);
   years=parseFloat(document.smpc.years.value);
   term = parseFloat(document.smpc.term.value);
   if(term > years)term=years;

   if (term==0 || years==0||irate<.0001||princ<1)
   {alert("values must be numeric");}
   else
   {
       if(cdn)mi = Math.pow(1+ irate/2,1/6)
       else   mi = 1+(irate/12);
       v = 1/mi;
       paym = ceil2d(princ*(mi-1)/(1-Math.pow(mi,-(years*12))));
       osp = (princ-(v*paym*(1-Math.pow(v,12*term)))/(1-v))/Math.pow(v,12*term);
       if(osp<0)osp = 0;

       document.smpc.paym.value=fmt2d(paym,0);
       document.smpc.owed.value = fmt2d(osp,0);
   }
}
function round2d(n){return(.01* Math.round(100*n));}
function floor2d(n){return(.01* Math.floor(100*n));}
function ceil2d(n){return(.01* Math.ceil(100*n));}
// format number n as string width w with 2 decimal places
function fmt2d(n,w)
{
   var work,dp,sl,dl;

   work = ""+floor2d(n); // force only 2 decimals
   sl=work.length;

   if(-1 == (dp = work.indexOf(".")))work=work+".00";
   else if(3 > sl-dp)work = work+".00".substring(sl-dp,3);
   sl = work.length;
   if(0 != w && w !=sl)
      if(w<sl){work = "*";for(sl=1;sl<w;sl++)work=work+"*";}
      else for(;sl<w;sl++)work=" "+work;
   return work;
}

function LargeImage(ImageToUse, WinWidth, WinHeight, Folder){

			myWindow = window.open("", "tinyWindow", 'width=' + WinWidth + ',height=' + WinHeight)	
			myWindow.document.write("<html><head><title>Enlarged Image</title></head><body><TABLE WIDTH=559 BORDER=0 CELLPADDING=0 CELLSPACING=0>")
			myWindow.document.write("<TR><TD COLSPAN=3><a class='norm' href=\"javascript:window.close();\"><IMG SRC='PictureBookimages/ChannelsScrapBookTemplate_0.gif' border='0' WIDTH=559 HEIGHT=34></TD>")
			myWindow.document.write("</TR><TR><TD><IMG SRC='PictureBookimages/ChannelsScrapBookTemplat-02.gif' WIDTH=91 HEIGHT=284></TD>") 
			myWindow.document.write("<TD><a class='norm' href=\"javascript:window.close();\"><IMG SRC='images/" + Folder + "/" + ImageToUse + ".jpg' alt='Click to Close' border='0' WIDTH=379 HEIGHT=284></TD>") 
			myWindow.document.write("<TD><IMG SRC='PictureBookimages/ChannelsScrapBookTemplat-04.gif' WIDTH=89 HEIGHT=284></TD>") 
			myWindow.document.write("</TR><TR><TD COLSPAN=3><IMG SRC='PictureBookimages/ChannelsScrapBookTemplat-05.gif' WIDTH=559 HEIGHT=42></TD>")
			myWindow.document.write("</TR></TABLE></body></html>")
		}

		

