Window.onDomReady(function() {
    var blanks = $ES('a.blank');
    blanks.forEach(function(link) {
        link.onclick = function() {
            var popup = open(this.href, "RideMyBike", "height=480px,width=640px,menubar=no,toolbar=no,scrollbars=yes");
            popup.focus();
            return false;
        }
    });
    
    var news = $ES('a.new');
    news.forEach(function(link) {
        link.onclick = function() {
            var popup = open(this.href, "RideMyBike_Window");
            popup.focus();
            return false;
        }
    });
	
	var links = $ES('a.help');
	links.forEach(function(link) {
		link.onmouseover = function(e) {
			var tooltip = $('tooltip');
			tooltip.appendChild(document.createTextNode(this.title));
			tooltip.style.display = "block";
			
			if (!e) var e = window.event;
			if (e.pageX || e.pageY) {
				posx = e.pageX;
				posy = e.pageY;
			}else if (e.clientX || e.clientY) {
				posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
			}
			
			tooltip.style.top = posy + 3 + "px";
			tooltip.style.left = posx + 3 + "px";
			this.title = "";
		}
		link.onmouseout = function() {
			var tooltip = $('tooltip');
			this.title = tooltip.firstChild.nodeValue;
			tooltip.removeChild(tooltip.firstChild);
			tooltip.style.display = "none";
		}
	});
    
    var selects = $ES('input.selectAll', 'textarea.selectAll');
    selects.forEach(function(thing) {
        thing.onfocus = function() {
            this.select();
        }
    });
    
    if(getfocus) {
        if($(getfocus)) {
            var element = $(getfocus);
            element.focus();
        }
    }
});

var getfocus = false;