var Application = (function () {

	var HEIGHT = 660;

    function decorateLabels()
    {
        $$('label').each(function(l) {
            if ("" != l.accessKey) {
                l.cleanWhitespace();
                if (l.firstChild && l.firstChild.tagName)
                    return;
                var index = l.innerHTML.toUpperCase().indexOf(l.accessKey.toUpperCase());
                if (-1 != index) {
                    l.update(l.innerHTML.substr(0, index) + '<span class="accesskey">' +
                        l.innerHTML.charAt(index) + '</span>' +
                        l.innerHTML.substr(index + 1));
                }
            }
        });
    } // decorateLabels
    
    function focusFirstElement()
    {
        $$('form').each(function(form) {
            if (!form.hasClassName('skip_focus')) {
                form.focusFirstElement();
                throw $break;
            }
        });
    } // focusFirstElement
    
	function center() {
		if(undefined != window.innerHeight) {
			var marginTop = (window.innerHeight - HEIGHT) / 2;
			if( 0 < marginTop )
				$('body').style.marginTop = marginTop + 'px';
		}
	} // center
    
    function init()
    {
        decorateLabels();
        focusFirstElement();
    } // init
    
    return {
        'init': init
    }

})();

Event.observe(window, 'load', Application.init);