//Start of FindInPage object, by Ivan Peters (ivan@ivanpeters.com)
function FindInPage(theWin) {
	//Public Properties
	this.BrowserOK = (parseFloat(navigator.appVersion) >= 4);
	this.Win = (theWin) ? theWin : window;
	//Public Methods
	this.Find = FIPFind;
	this.FindNext = FIPFindNext;
	
	//Private Properties
	this.Rng = null;
	this.ToFind = "";
	this.UseRange = (document.all) ? true : false;
	//Private Methods
	this.FindInRange = FIPFindInRange;
	this.NSFind = FIPNSFind;
}
function FIPFindInRange() {
	if (this.Rng != null) {
		if (this.Rng.findText(this.ToFind)) {
			this.Rng.select(); 
			this.Rng.scrollIntoView();
		} else {
			this.Rng = null;
			this.ToFind = "";
			alert("Not Found!");
		}
	}
}
function FIPNSFind() {
	if (this.Win.find(this.ToFind) == false) {
		this.ToFind = "";
		alert("Not Found!");
	}
}
function FIPFind(txt) {
	this.ToFind = txt;
	if (this.BrowserOK && (this.ToFind != "")) {
		if (this.UseRange) {
			this.Rng = this.Win.document.body.createTextRange();
			this.FindInRange();
		} else {
			this.NSFind();
		}
	}
}
function FIPFindNext() {
	if (this.BrowserOK && (this.ToFind != "")) {
		if (this.UseRange && (this.Rng != null)) {
			this.Rng.moveEnd("textedit");
			this.Rng.moveStart("word");
			this.FindInRange();
		} else {
			this.NSFind();
		}
	}
}
//End of FindInPage object

var Searcher = new FindInPage();
function doFind() {
	var textToFind = document.forms[0].toFind.value;
	Searcher.Find(textToFind);
}
function doFindNext() {
	Searcher.FindNext();
}
