/*

Patch standard Google Map for keyboard accessibility

(remember, accessibility isn't just about the blind ... sighted users with mobility impairments may also wish
 to use your maps, and currently the weird "keyboard access" option that gmap has is suboptimal in that it requires
 weird hacking to first "activate" the map to enable the - not exposed/announced - keyboard shortcuts, which may also
 override further page controls or conflict with assistive technologies)

Thanks to Patrick H. Lauke / www.splintered.co.uk / redux@splintered.co.uk / December 2007

expects GMap2 object as parameter

*/


function GKeyboardPatch(m) {
	var m = m.getContainer(); // GMap2 method
	var divs = m.getElementsByTagName('DIV');
	var button, span, button_style = 'width:100%;height:100%;background:transparent;border-width:0px;border-color:#fff;border-style:solid;position:absolute;top:0;left:0;cursor:pointer;overflow:hidden;padding:0;margin:0;', span_style = 'display:block;visibility:hidden;padding:0;margin:0;';
	for (var i = 0; i < divs.length; i++) {
		if ((divs[i].getAttribute('log'))||((divs[i].getAttribute('id'))&&(divs[i].getAttribute('id')!='map_magnifyingglass'))) { // should really use hasAttribute, but IE doesn't implement this method
			button = document.createElement("BUTTON");
			span = document.createElement("SPAN");
			span.appendChild(document.createTextNode(divs[i].getAttribute('title')));
			button.appendChild(span);
			 // proper W3C DOM methods for styling
			button.setAttribute('style',button_style);
			span.setAttribute('style',span_style);
			// ...and now to make it work in IE
			button.style.cssText = button_style;
			span.style.cssText = span_style;
			divs[i].appendChild(button);
		}
		if (divs[i].getAttribute('log')) {
			// override the IE opacity filter that Google annoyingly sets
			divs[i].style.filter = '';
			// should really set to 'transparent', but this messes up the map controls in IE
			divs[i].style.background = 'url(http://www.google.com/intl/en_ALL/mapfiles/transparent.png)';
		}
	}
}