if (typeof ARL == 'undefined' || !ARL) ARL = {};
Object.extend(ARL, {
    images : '/arlimages/',
    PopUp: {
        style : {
            'popup' : [
              '',
              'scrollbars=yes,resizable=yes,status=yes,toolbar=yes,'
                + 'location=yes,menubar=yes'
            ],
            'legalese' : [
              'legalese',
              'width=250,height=250,scrollbars=yes,resizable=yes,status=yes,'
                + 'toolbar=yes,location=yes,menubar=yes'
            ]
        },
        pop : function(link) {
            var targ = link.target || link.className || 'popup';
            var styles = $H(ARL.PopUp.style).keys();
            targ = styles.detect( function(s){ if (s == targ) return true; } );
            if (!targ) targ = 'popup';
            var attr = ARL.PopUp.style[targ];
            var newWin = window.open(link.href, targ, attr);
            newWin.focus();
            return false;
        },
        init : function() {
            $$('a.popup').each( function(link) {
                link.onclick = function(){ ARL.PopUp.pop(link) }
            });
        }
    },
    isIE : (   !window.opera
            && navigator.userAgent.indexOf('MSIE') != -1 ),
    startup : function() {
        ARL.PopUp.init();

        //cache search button images
        ['green','purple','orange'].each( function(color){
            var img = new Image;
            img.src = ARL.images + 'search-' + color + '-v2.png';
        });
        var form = $$('#searchForm form')[0];
        var searchFld = $('q');
        var searchBtn = $('sa');
        if (form && searchFld) {
        
            /* same behaviors for these, except for search field reset:
               typing in field, and clicking/submitting form */
            searchFld.onfocus = function() {
                searchFld.style.backgroundColor = '#ffc';
                searchFld.style.color = '#000';
                searchFld.style.borderColor = '#fff';
                searchBtn.src = ARL.images + 'search-green-v2.png';
                if (searchFld.value == 'Search ARL') searchFld.value = '';
            };
            searchBtn.onclick = form.onsubmit = function() {
                searchBtn.src = ARL.images + 'search-green-v2.png';
                searchFld.style.backgroundColor = '#fff';
                searchFld.style.color = '#000';
                searchFld.style.borderColor = '#fff';
            };
            
            /* button click */
            searchBtn.onfocus = searchBtn.onmousedown = function() {
                searchBtn.src = ARL.images + 'search-purple-v2.png';
                searchFld.style.backgroundColor = '#ffc';
                searchFld.style.color = '#000';
                searchFld.style.borderColor = '#fff';
            };

             /* going out of the field or lifting off the button */
            searchBtn.onmouseup = searchBtn.onblur = searchFld.onblur = function() {
                searchFld.style.backgroundColor = '#fff';
                searchFld.style.color = '#99f';
                searchFld.style.borderColor = '#fff';
                searchBtn.src = ARL.images + 'search-orange-v2.png';
                if (searchFld.value == '') searchFld.value = 'Search ARL';
            };
      }
    }
});
BM.onDOM.addEvent(ARL.startup);
