var CertusNiceties = Class.create({
  initialize: function(){
    if($('definition') && !$("page_1")){
      this.repositionDefinitionBox($('definition'));
    }
    if($('page_title_text')){
     this.animatePageTitle();
    }

    if($('banner') && !Prototype.Browser.IE){
       this.rotateGears();
     }
    
    return;
  },
  
  animatePageTitle : function(){
    
    // Reduce font-size until it is only one line (39px height)
    var targetHeight = 39;
    while ($('page_title_header').getHeight() > targetHeight){
      $('page_title_header').setStyle({fontSize: (parseInt($('page_title_header').getStyle('fontSize')) - 1) + 'px'});
      Cufon.set('fontFamily', 'Myriad Pro').replace('h1');
    }

    //get the header text height 
    var textHeight = parseInt($('page_title_header').getStyle('height'));
    var stripHeight = textHeight + 48 ;
    var textPosY = stripHeight/2 - textHeight/2;
    $('page_title').setStyle("height:"+stripHeight+"px;")
    $('page_title_header').setStyle("top:"+textPosY+"px;")
     $('page_title').morph('top:'+ (481 - stripHeight)+'px; height:'+stripHeight+'px; overflow:hidden;',{duration:.5, position:'parallel', delay:1}); 
     $('page_title_text').morph('top:'+ (481 - stripHeight)+'px; height:'+stripHeight+'px;',{duration:.5, position:'parallel', delay:1});
     $('page_title_header').morph('padding:0; right:20px;',{duration:.5, position:'parallel', delay:1}); 
     $('page_title').morph('opacity:.7;',{duration:5});
  },
  rotateGears : function(){
    t = this;
    var rot = 0.00
    t.interval = setInterval(function(){
      rot +=0.001;
      $('large_gear').transform({ rotation: rot});
    },50);
  },
  repositionDefinitionBox : function(defbox){
    
    $('intro').insert({top: defbox} );
  }
});

// Global DOM onload
document.observe("dom:loaded", function() {
  var s = new CertusNiceties();
  var c = new Common();
  Shadowbox.init();
  
});

// Global Window onload
Event.observe(window, 'load', function(){ });

