// by Dmitriy Ryaboy, www.squarecog.com
// for JBEI, www.JBEI.org
YAHOO.namespace("jbei");

YAHOO.jbei.yah = function (container, getElement, transform )  {
	this.container = YAHOO.util.Dom.get(container);
	
	if (this.container == null) {
		return;
	}
	this.children = YAHOO.util.Dom.getElementsBy( function foo() { return 1; }, "a", this.container);
	this.curr_url = document.location.href;
	//get rid of index.* at the end of the line. 
	//Naive -- breaks if you pass params.
	//(or if you actually have a url that 
	//contains the string asdfq3465sf)
	var replaceRe = new RegExp ('index\.(php|html|shtml|asp|sht)$', "i");
	this.curr_url = this.curr_url.replace(replaceRe, 'asdfq3465sf');
	for (var i in this.children) {
		var childUrl = this.children[i].href;
		childUrl = childUrl.replace(replaceRe, 'asdfq3465sf');
		if (new RegExp('^'+childUrl, 'i').test(this.curr_url) ||
			new RegExp('^'+childUrl, 'i').test(this.curr_url+"asdfq3465sf")) {
			transform(getElement(this.children[i]));

		}			
	}
}

