
/*
  * Summary:	Attaches an event to the object passed in
  *			Script written by Christian Heilmann at http://www.onlinetools.org/articles/unobtrusivejavascript/chapter4.html
  * Parameters: 	Object to attach event to | type of event to attach | function call
  * Return: 		Boolean indicating success or failure
  */
function addEvent(obj, evType, fn){ 
	if (obj.addEventListener){ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} 
	else if (obj.attachEvent){ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	}
	else { 
		return false; 
	} 
}

/*
 Suckerfish script - gives :focus support to IE 6- 
*/
sfFocus = function() {
	var sfEls = document.getElementsByTagName("INPUT");

	for (var i=0; i<sfEls.length; i++) {
		/*var fcs = function() {this.className+=" sffocus";};
		var blur = function() {this.className=this.className.replace(new RegExp(" sffocus\\b"), "");}
		addEvent(sfEls[i], 'focus', fcs);
		addEvent(sfEls[i], 'blur', blur);
		unfortunately the below overwrites other events. 
		*/
		
		sfEls[i].onfocus=function() {
			this.className+=" sffocus";
		}
		sfEls[i].onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
		}
	}
	
	//extra code for the search box
	var searchtxt = document.getElementById("search-site");
	if (searchtxt == null) return;
		searchtxt.onfocus=function() {
			this.className+=" sffocus";
			if (this.value == 'search the site...') this.value='';
		}
		searchtxt.onblur=function() {
			this.className=this.className.replace(new RegExp(" sffocus\\b"), "");
			if (this.value.length<1) this.value='search the site...';
		}
	
}

//This is IE-only (not necessary for better browsers)
if (window.attachEvent) window.attachEvent("onload", sfFocus);


