// Browser Detection
isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
NS4 = (document.layers) ? true : false;
IEmac = ((document.all)&&(isMac)) ? true : false;
IE4plus = (document.all) ? true : false;
IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
ver4 = (NS4 || IE4plus) ? true : false;
NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

// Body onload utility
var gSafeOnload = new Array();
var htmlStr = '';
var item = new Array();

function SafeAddOnload(f)
{
	if (IEmac && IE4){
		window.onload = SafeOnload;
		gSafeOnload[gSafeOnload.length] = f;
	}
		else if  (window.onload){
				if (window.onload != SafeOnload){
					gSafeOnload[0] = window.onload;
					window.onload = SafeOnload;
				}
		gSafeOnload[gSafeOnload.length] = f;
		}
	else
		window.onload = f;
}

function SafeOnload()
{
	for (var i=0;i<gSafeOnload.length;i++)
		gSafeOnload[i]();
}



// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"

c=0; item[c]=new Array("index.htm","","HOME PAGE","GLOSSARY,mortgage,rates,Equity,Interest,Switch,Prepayment,Variable,Open,Amortization,Closed,Conventional,Credit,Loan,calculator,Payments,Agreement,Purchase","Simple glossary of mortgage terms ");

c++; item[c]=new Array("rates.htm","","MORTGAGE RATES","mortgage,rates,Canadian,Canada,broker,banks,brokers,calculator,lowest,Ontario,Toronto,British Columbia,Vancouver,Victoria,Quebec,Montreal,Nova Scotia,Halifax,Alberta,New Brunswick,Quebec City,London,Saskatoon,Windsor,Ottawa,St. John,Charlottetown,Sydney,Moncton,Banff,Saskatchewan,free,CMHC,GE Capital,homefund,Homefund Corporation,Mike Loleski,first mortgages,second mortgages,canadian mortgages,best rates","Canadian mortgage rates - HOMEFUND.");

c++; item[c]=new Array("abc_index.htm","","MORTGAGE ABC's","TERMS,Agreement,Purchase,Sale,Amortization,Period,Appraisal,Assets,Assumption,Blended,Payments,Canada,Housing,Corporation,CMHC,Closed,Closing,Date,Conventional,Collateral,Credit,Scoring,Demand,Loan,Deposit,Equity,First,Fixed-Rate,Gross,Debt,Service,GDS.,Ratio,Guarantor,Hi-Ratio,Home,Equity,Line,of,Credit,Interest,Adjustment,Date,IAD,Mortgagee,Mortgagor,Open,Mortgage,P.I.T.,Portable,Prime,Prepayment,Penalty,Principal,Rate,Commitment,Renewal,Second,Switch,Term,Total,Debt,Service,TDS,Ratio,Variable-Rate,Vendor,Take,Back,VTB","Here is a simple glossary of mortgage terms.");
c++; item[c]=new Array("basics.htm","","MORTGAGE BASICS"," buying,house,investment,financing,mortgage,interest,homefund.com,payments,loan,property,security,debt,mortgagor,lender,mortgagee,principal,amortization,constructing,Refinancing,consolidate,Financing,renovation,equity,Secured,Line,Credit,fixed-rate  ","As almost everyone who is buying a home will need financing,they are also interested and often need guidance on what to look for a mortgage and how they can pay the least amount of interest over the term of the mortgage. ");
c++; item[c]=new Array("types.htm","","TYPES OF MORTGAGES","Pre-Approved,Conventional,High-Ration,CMHC,GE,Capital,First,Open,Closed,Fixed-Term,Adjustable,Rate,A.R.M.,Secured,Line,Credit,Equity,Multiple,Term,Convertible,All-Inclusive,A.I.M.,Bridge,Financing,Pre-Approved,qualification,homefund,guarantee,protection","What types of mortgages are out there");
c++; item[c]=new Array("rating.htm","","BUILDING A GOOD CREDIT RATING ","credit,rating,record,repayment,money,bureau,history,debt,cards,loans,report","Your credit rating is a measure of your credit-worthiness or in other words,your record of borrowing and repayment.How to build a good credit rating");

c++; item[c]=new Array("finance_index.htm","","FINANCING YOUR HOME","Purchase,Price,home,budget,afford,Down,Payment,Calculate,total,gross,income,Monthly,Costs,lenders,maximum,mortgage,approve,Gross,Debt,Service,G.D.S.,Total,T.D.S.,homefund","What is a Realistic Purchase Price I Should Look At ?");
c++; item[c]=new Array("choosing.htm","","CHOOSING THE  HOME","afford,Mortgage,Pre-approved,Preparation,Closing,Insurance,agent,house,Offer,firm,condominium,MLS,RRSP,conditional ","Step by step approach to choosing the right home.");
c++; item[c]=new Array("closing.htm","","CLOSING COSTS AND ADJUSTMENTS","closing,costs,Appraisal,Fee,property,cost,G.S.T.,Home,Inspection,liability,insurance,Fire,certificate,Sales,Tax,P.S.T.,CMHC,GE,Capital,down,payment,closing,Land,Survey,Title,Legal,Disbursements,lawyer,notary,deed,registration,Transfer,Warranty,Application,Processing,high-ratio","Additional costs of the home-buying process.");
c++; item[c]=new Array("refinancing.htm","","MORTGAGE REFINANCING","Refinancing,mortgage,Consolidate,debts,First,Second,CMHC/GE,Capital,cash-back,Renovation,loan,line,credit,financing,equity,write-off,interest,taxable,income,education,APPLY,ONLINE,","Refinancing you mortgage - to your advantage. There are many reasons to why you should consider refinancing your mortgage:");
c++; item[c]=new Array("switch.htm","","MORTGAGE TRANSFER","transfer,switch,mortgage,mature,renewal,guarantee,rates,bi-weekly,reminder,specialists ","Switch to another mortgage lander - for free.At homefund.com,we can guarantee your rates up to 90 days (4 months) before your mortgage comes due.");
c++; item[c]=new Array("renewing.htm","","MORTGAGE RENEWAL","mortgage,contract,renewal,IRD,rates,penalty,lower,CASH-BACK ","You should review your mortgage on a regular basis and keep up with new products and offers that are available - they may save you a bundle.");


c++; item[c]=new Array("tips_index.htm","","TIPS & FEATURES ","tips,features,Increase,Term,mortgage,interest,Fixed,Variable,Monthly,Closed,buy,CMHC,weekly,Prepayments,Renewal,Portable ,bi-weekly,Assumable,Maturing,Amortization,Life,IRD,sell,Open,principal ,rates,Insurance ","What term should you take? Monthly,bi-weekly,or weekly payments? Are You Thinking Of Moving To Canada ?");
c++; item[c]=new Array("programs.htm","","SPECIAL PROGRAMS","Buy,Home,Down,Payment,RRSP,Buyer,Plan,HBP,First,Time,Buyers,Ontario,Ownership,Savings,Plan,OHOSP,Cash-Back,Program,All-Inclusive,Mortgage,A.I.M. ","Special programs for first time home buyers ");
c++; item[c]=new Array("offers.htm","","SPECIAL OFFERS"," home,warranty,Cash,back,programs,Interest,rate,discount,title,insurence,Interest,Rate,Discount","Free Home Warranty,Cash Back Programs,Interest Rate Discounts,Save Money with Title Insurance ");

c++; item[c]=new Array("approval_index.htm","","GET APPROVED ONLINE ","Application,Form,Mortgage,completed,name,city,online,submission,specialists,assistance,phone,referral,","Mortgage Online Application Form .");
c++; item[c]=new Array("preapproval.htm","","EXPRESS PREAPPROVAL","MORTGAGE,purchase,rates,APPROVED,guarantee,Express,Obligation,free,express,credit,rating,120,days,protection,savings,Online,phone,contact,negotiate,lenders,confident,PreApproval,lower,responsible  ","Express Pre-Approval Form A Pre-Approved Mortgage is a Free,No-Obligation service that lets you know before you go looking for your home or signing an offer to purchase.");
c++; item[c]=new Array("documents.htm","","DOCUMENTS REQUIRED","document,application,Completed, signed,lender,bureau,rating,earnings,signed,letter, employment,tax,return,assessment,financial,statement,self-employed,Offer,condition,MLS,listing,Survey,land,down,payment,savings,RRSP,equity,gift,letter, Solicitor,legal,counsel,condominium","Here is a checklist of documents and information we will need as we process your application.");
c++; item[c]=new Array("calculator.htm","","MORTGAGE CALCULATOR","Mortgage,amount,of,the,mortgage,remaining,balance,contact,homefund.com,E-mail,phone,interest,rate,amortization,period,and,payment,frequency,Calculator,monthly,payments,links,more,where,similar,friends","This mortgage calculator will assist you in calculating your monthly payments.");

c++; item[c]=new Array("why_index.htm","","WHY HOMEFUND","refinancing,lender,mortgage,interest,rate,service,free,fees,buy,house,refinance,renew,pre-approve,secure,online,form,call ","Speak to a full-time,professional mortgage specialist at homefund.com,who is on top of the market. We are constantly updated on any interest rate changes,as well as new products being introduced. And best of all,the service is free! We earn our fees from the lender.");
c++; item[c]=new Array("aboutus.htm","","ABOUT US","about,author,contact,email,who","Contact details and general information about HOMEFUND site and what the site is about.");
c++; item[c]=new Array("referral.htm","","REFERRAL FORM","REFERRAL,PROGRAM, FORM,friends,advice,real,estate,mortgage ","This program is designed to make it as simple as possible for you to refer your friends that need Hassle-Free advice on real estate or mortgage information.");
c++; item[c]=new Array("binder.htm","","ORDER HOME BINDER","cheque,money,order,Home,Maintenance,Tips,Procedures,Scheduled,Maintenance,Section,Improvement,Costs,Documents,reference,cheque,money ","This is an 'All You Will Ever Need binder' professionally prepared,customised and imprinted,and is given to our clients at closing. ");
c++; item[c]=new Array("solutions.htm","","FINANCING SOLUTIONS","FINANCING,SOLUTIONS,limits, self-employed,commissioned,contract,work,commercial,industrial,property,FREE,mortgage,analysis,apply,online,call,bankruptcy ","Homefund.com provides you with a FREE mortgage analysis and best of all,you'll know just how much you qualify for usually within a 24 hour period.");


c++; item[c]=new Array("links_index.htm","","LINKS ","Homefund,Website,locate,important,on-line,information,area,service,LINKS,Search,SERVICES,PREFERRED,PROFESSIONALS ","Links: Helpful services and preferred professionals");
c++; item[c]=new Array("professionals.htm","","PREFERRED PROFESSIONALS ","property,appraisers,health,medicine,homes,for,sale,automobiles,music,sport,fitness,appliances,home,inspectors,lawyers,realtors,search,utility,reliable,service,providers, individually,committed,PREFERRED,PROFESSIONALS","Search utility for reliable service providers who have individually committed to provide quality service to current,past,and future clients at reasonable prices. ");
c++; item[c]=new Array("services.htm","","SITES TO INFORM & ENTERTAIN YOU","Coupons,Online,Government,Entertainment,Travel,Adventure,mortgages,mutual,funds,stocks,Food,Fun,Weather,Finance,Investment,Computers,Traffic,National,International,Toronto,News,homefund,recommend,SITES,INFORM,ENTERTAIN,YOU,links,more,where,similar,friends","Links to my favourite sites which I find interesting. Other friends sites which have similar interests to my own.");

c++; item[c]=new Array("partner_index.htm","","THE PARTNER POINTS PROGRAM "," referral,membership,card,Online,catalogue,toll-free,call,phone,Referral,Form,get,mortgage,Refer,friend,prize,launch,earn,valuable,Partner,Points,homefund.com,Partner,Points,Program,clients,","Become a Referring Partner and earn valuable Partner Points to win terrific prizes. Your first successful referral gets you in the prize category.");
c++; item[c]=new Array("login.htm","","LOGIN","login","");
c++; item[c]=new Array("become_member.htm","","BECOME A PARTNER POINTS MEMBER ","user,name,password,BECOME,PARTNER,POINTS,MEMBER,homefund,toll-free,call,Fill,form,address,email,change,address ","Become a parter points member..Fill the online form !");
c++; item[c]=new Array("example.htm","","SAMPLE PRIZES","member,item,clock,farmlight,Partner,Points,you,earn, redeem,prizes,SAMPLE  ","As a member of Partner Points you earn valuable points that are redeemable for prizes. ");
c++; item[c]=new Array("disclaimer.htm","","DISCLAIMER","Guarantee,SIGN,Err,Human,DISCLAIMER,Availability,Getting,Damaged,Missing,Shipments,Goods  ","Disclaimer");

c++; item[c]=new Array("tools.htm","","TOOLS AND RESOURCES ","download,appropriate,document,Free,No-Obligation,service,mortgage,payments,Forms,Express,Preapprroval,Loan,Calculators,Mortgage,Checklist ","We put numerous tools and resources at your fingertips.");
c++; item[c]=new Array("forms.htm","","IMPORTANT FORMS","Moving,Check,List ,Gift,Letter,CMHC,Price,Ceilings,Application,mortgage,loan,completing,loan,application,IMPORTANT,FORMS,HomeFund,Corporation,strive,make,loan,application,process "," For your convenience we have provided a number of forms to help you during the application process.");
c++; item[c]=new Array("checklist.htm","","MORTGAGE APPLICATION CHECKLIST","checklist,what,recent,Number,dependents,Bank,statements,Personal,Assets,bankruptcy,cars,stocks,debts,loans,Liabilities,Employment,History,Information,land,survey,complete,signed,sales,agreement ,mortgage,financial,employment,information,APPLICATION,CHECKLIST ","This checklist shows you what you'll need before you complete your mortgage application,so make sure to print out this page.");
c++; item[c]=new Array("palm.htm","","PALM PILOT CALCULATOR","Homefund,PalmPilot,Application,wireless,calculate,mortgage,payment,download,Free,HotSync ","You can now use your regular or wireless Palm to calculate your mortgage payments. Please follow these easy steps to download Homefund application to your Palm device.");


c++; item[c]=new Array("search.htm","","SEARCH","search","Search engine to help you navigate the site.");
c++; item[c]=new Array("contact.htm","","CONTACTS","CONTACT,US,form,fax,write,email,toll,call,free,homefund ","You may contact homefund.com by either filling out the form below. You can also call us at 416-410-2886 or toll free outside the 416 area code at 1-888-588-6666.");

function search() {
	var formObj = GetFormObj();
	txt = formObj.searchval.value.split(" ");
	fnd = new Array(); 
	total=0;
	htmlStr = '';
		for (i = 0; i < item.length; i++) {
		fnd[i] = 0; 
		order = new Array(0,4,2,3,1);
		for (j = 0; j < order.length; j++)
		for (k = 0; k < txt.length; k++)
		if (item[i][order[j]].toLowerCase().indexOf(txt[k].toLowerCase()) > -1 && txt[k] != "") fnd[i] += (j+1);
		}
	for (i = 0; i < fnd.length; i++) {
		n = 0; 
		w = -1;
		for (j = 0;j < fnd.length; j++)
		if (fnd[j] > n) { n = fnd[j]; w = j; };
		if (w > -1) total += show(w,this,n,total);
		fnd[w] = 0;
		}
	//htmlStr = htmlStr +'<BR><BR>'
   	//htmlStr = htmlStr +'<br><br>&nbsp;Please enter a keyword or phrase below.'
	//htmlStr = htmlStr +'<DIV ID=formlayer name=formlayer  STYLE=\"position:relative; WIDTH=100px; HEIGHT=100px\">'
	htmlStr = htmlStr +'<form name="search_form" action="javascript:search();" method="POST">'
	htmlStr = htmlStr +'<br><INPUT TYPE="text" NAME="searchval" SIZE=35 MAXLENGTH="35">'
	htmlStr = htmlStr +'<input type=image src="images/find.gif" value=Submit hspace=2 align=absmiddle alt=Submit border=0 width="39" height="17">'
	//htmlStr = htmlStr +'</FORM>'
	//htmlStr = htmlStr +'</DIV>'         
	htmlStr = '<center><table border=1 cellspacing=5 width=100%><tr><td bgcolor=#99CCFF class=normaltext><b>SEARCH RESULTS: Total found: '+total+',sorted by relevance.</b></td></tr>' + htmlStr + '</table>';
	UpdateForm();
	}

function show(which,wind,num,total) {
	link = item[which][1] + item[which][0];
	htmlStr += '<tr><td class=normaltext><a href='+link+'><b>'+item[which][2]+'</b></a> Score: '+num+'<br>';
	htmlStr += item[which][4] + '<br></td></tr>';
	//wind.document.write(line);
	return 1;
	}


function GetFormObj()
{
	var returnObj = null;

	if (IE4plus){
		returnObj =  document.search_form;
	}
		else if (NS4){
			returnObj =  document.formlayer.document.search_form;
		}
			else if (NS6){
				returnObj =  document.getElementById("search_form");
			}	
	return returnObj;
}



function UpdateForm()
{
	var htmlStrNew = htmlStr;

	if (IE4plus){
		document.all.formlayer.innerHTML = htmlStrNew;
	}
	else if (NS4){
		document.formlayer.document.open();
		document.formlayer.document.write(htmlStrNew);
		document.formlayer.document.close();
	}
	else if (NS6){
		document.getElementById("formlayer").innerHTML = htmlStrNew;
	}
}

function IncludeForm()
{
	var htmlStr = GetFormHTML();

	if (IE4plus || NS6){
		document.write('<DIV ID=formlayer name=formlayer  STYLE="position:relative; WIDTH=400px; HEIGHT=50px">' + htmlStr + '</DIV>');
	}
	else if (NS4){
		// Because NS needs floating layers,we need a placeholder graphic to force anything
		// below the layer content to leave whitespace for the layer.  The position of this
		// graphic is also used in determining the position of the layer.
		document.write('<img name="formlocation" border="0" width="400" height="200" src="images/spacer.gif">');
	}

}

//
// Netscape 4.x Ineptness
//
function HandleOnload()
{
	if (NS4){
		var width = document.formlocation.width;
		var height = document.formlocation.height;

		nL=new Layer(width);
		nL.name = "formlayer";
		nL.left=document.formlocation.x;
		nL.top=document.formlocation.y;
		nL.bgColor = "white";
		nL.clip.width=width;
		nL.clip.height=height;
		nL.document.open();
		nL.document.write(GetFormHTML());
		nL.document.close();
		nL.visibility = 'show';

		document.formlayer = nL;
	}
}

function HandleResize()
{
	location.reload();
	return false;
}

if (NS4){
	SafeAddOnload(HandleOnload);
	window.captureEvents(Event.RESIZE);
	window.onresize = HandleResize;
}

