// droplinkfocus.js - version 1.00 2008-02-21
//
// A JavaScript class to drop the focus on links in Internet Explorer
//
// base: http://www.webaware.com.au/free/droplinkfocus/
//
// copyright © 2008 WebAware Pty Ltd
//---------------------------------------------------------------------
// Internet Explorer doesn't understand the CSS outline attributes,
// so this code drops the focus off clicked links to remove the ugly
// outline. It only does this when the browser is detected as being
// Internet Explorer (or a close clone)
//---------------------------------------------------------------------
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
//
// Full license: http://www.webaware.com.au/free/license.htm
//---------------------------------------------------------------------

// class constructor
function DropLinkFocus() {
	// hook into the page load event, so we can hook all static links when page has been loaded
	// add a hook to the document's onload event, so that our object is initialised after page load completes
	// NB: only do this if window.attachEvent is present - or in other words, only for Internet Explorer
	if (window.attachEvent) window.attachEvent("onload", DropLinkFocus.hookOnLoad);
}

// onload hook - hook all static links on the page
DropLinkFocus.hookOnLoad = function() {
	var lks = document.getElementsByTagName('a');

	for (var i in lks) {
		lks[i].onfocus = DropLinkFocus.linkOnFocus;
	}
}

// link onfocus function - drop the focus immediately
// NB: "this" is the object reference to the anchor element, not this class
DropLinkFocus.linkOnFocus = function() {
	this.hideFocus = true;
}

// kick it into action
var droplinkfocus = new DropLinkFocus();
