function fireWhenReady(){
    /*
     * For the site itself
     */
    function fadeImgToLiBg(el){
        var a = el.getElement('a');
        if($chk(a.getProperty('href'))){
           var i = a.getElement('img');
           i.store('enter_duration', this.enter_duration);
           i.store('leave_duration', this.leave_duration);
           el.setStyle('background', 'url('+i.get('src')+') '+this.x+' '+this.y+' no-repeat');

           el.onclick=function(){ document.location = this.href; };
           el.addEvent('mouseenter', function(){
               this.set('tween', this.retrieve('enter_duration'));
               this.fade('out');
           }.bind(i));
           el.addEvent('mouseleave', function(){
               this.set('tween', this.retrieve('leave_duration'));
               this.fade('in');
           }.bind(i));
        }
        if($chk(this['fn']) && typeof(this['fn'])=='function') this.fn(el, a);

    }

    primary_nav_settings = new Hash({
        'x': 0,
        'y': '-69px',
        'enter_duration': {'duration': 'short'},
        'leave_duration': {'duration': 'normal'},
        'fn': function(el){
            if(!$(document.body).hasClass('projects') && el.hasClass('projects')){
                  var ul = el.getElement('ul');
                  ul.setStyle('display', 'block');
                  ul.setStyle('height', 0);
                  el.addEvent('mouseenter', function(){
                        this.set('morph', {'duration': 'normal', 'link': 'cancel'});
                        this.morph('.subnav_over');
                  }.bind(ul));
                  el.addEvent('mouseleave', function(){
                        this.set('morph', {'duration': 'long', 'link': 'cancel'});
                        this.morph('.subnav_out');
                  }.bind(ul));
            }
        }
    });
    home_projects_settings = new Hash(primary_nav_settings).extend({
      'y':'0',
      'fn':''
    });
    projects_subnav_settings = new Hash(home_projects_settings).extend({
      'x': '-121px',
        'enter_duration': {'duration': 100},
        'leave_duration': {'duration': 300},
        'fn': function(el, a){
           // Yay IE6
           if(document.all){
              if(el.getParents().length >= 7){
                 if(!$chk(el.hasClass('in')) && !$chk(el.hasClass('on'))){
                    a.setStyle('margin-left', ((parseInt(this.x)*2)+1)+'px');
                 }
              }
           }
        }
      });

    $$('#navigation > ul > li').each(fadeImgToLiBg.bind(primary_nav_settings));
    $$('#navigation > ul > li li').each(fadeImgToLiBg.bind(projects_subnav_settings));
    $$('body.home #copy ul.projects li').each(fadeImgToLiBg.bind(home_projects_settings));

    // Open these links in new windows
    $$('a[rel~=external]').each(function(el){
      el.onclick=function(){ return false; }
      el.addEvent('click', function(){ open(this.href, '_blank'); });
    });

    // Awards page menu
    awards_arrow_over = new Asset.image('/images/down-blue.gif');
    awards_arrow_out = new Asset.image('/images/right-blue.gif');
    awards_anchors = $$('$body.awards #misc a[href|=#section]');
    awards = $$('body.awards');
    if(awards[0]){
        awards = $('misc');
        awards_list = awards.getElement('ul');
        //var p_h = awards.getCoordinates().height;
        var l_h = awards_list.getCoordinates().height;
        //var h = (p_h > l_h)? p_h - l_h : p_h;
        awards_list.store('height', l_h);
        awards_list.setStyles({
            'height': 0,
            'visibility': 'visible'
        });
        awards_list.set('morph', {'duration': 'normal', 'link': 'cancel'});
        awards.addEvent('mouseenter', function(){
            this.setStyle('background', 'url('+awards_arrow_over.src+') top right no-repeat');
            awards_list.morph({
            'height': awards_list.retrieve('height'),
            'border-color': '#666',
            'padding-top': '3px'
            });
        });
        awards.addEvent('mouseleave', function(){
            this.setStyle('background', 'url('+awards_arrow_out.src+') top right no-repeat');
            awards_list.morph('.award_out');
        });
    }

    // Implement SmoothScroll on 'Top' links and Awards page menu
    internal_links = $$('a.totop').extend(awards_anchors);
    smooth_scrolls = new SmoothScroll({ links: internal_links}, Window);

}

script_styles = new Asset.css('/css/script.css');
window.addEvent('domready', fireWhenReady);
