// <20050729> FFS: sfFocus() now uses attachEvent to allow retention
//            of previous event handlers (e.g., an input textbox that should
//            show calendar control and change background color onfocus).
//            This approach requires that the class-changing functions if sfFocue()
//            refer to the source element as <c>event.srcElement</c>
//						instead of <c>this</c>, because IE's attachEvent method is very broken.
//            Fortunately, focus does not "bubble" (unlike hover), so the inability
//						to identify the actual calling element is less critical.
function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):
				((document.getElementById(parentId)==null)?null:document.getElementById(parentId).getElementsByTagName(tag));
			if (sfEls!=null)
				type(sfEls);
		});
	}
}

sfHover = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

sfFocus = function(sfEls) {
	for (var i=0; i<sfEls.length; i++) {
		var el = sfEls[i];
		el.attachEvent("onfocus", function() {
				event.srcElement.className+=" sffocus";
			});
		el.attachEvent("onblur", function() {
				event.srcElement.className = event.srcElement.className.replace(new RegExp(" sffocus\\b"), "");
			});	
	}
}

suckerfish(sfHover, "LI", "nav");
suckerfish(sfHover, "LI", "nav_sub");
suckerfish(sfFocus, "INPUT");
suckerfish(sfFocus, "TEXTAREA");
suckerfish(sfFocus, "SELECT");
