Hyphenator.setMinWordLength(4);
Hyphenator.setHyphenChar('&shy;');
Hyphenator.run();


var Fader = Class.create({
  initialize: function(elements, options) {
    this.elements = (typeof elements == "string") ? $$(elements) : $A(elements);
    this.options = Object.extend({ effect: Effect.Appear, 
                                   effectOptions: {
                                     delay: 5.0
                                   } },
                                 options || {});
                                 
    this.options.effectOptions['beforeStart'] = this.beforeStart.bind(this);
    this.options.effectOptions['afterFinish'] = this.afterFinish.bind(this);
    
    if(this.elements.size() <= 1) return;

    this.elements.each(function(element) {
      //element.makePositioned().absolutize();      
      //if(element != this.elements.first()) element.clonePosition(this.elements.first());
    }.bind(this));
    
    
    this.index = 0;
    this.currentElement = this.elements.first();
    this.invokeEffect();
  },
  
  beforeStart: function(effect) {    
    this.currentElement.setStyle({ zIndex: 1 });    
    this.lastElement.setStyle({ zIndex: 0 });
  },
  
  afterFinish: function(effect) {
    this.lastElement.hide()
    this.invokeEffect();
  },
  
  invokeEffect: function() {
    this.lastElement = this.currentElement;
    this.index = (this.index + 1) % this.elements.length
    this.currentElement = this.elements[this.index];
    this.options.effect(this.currentElement, this.options['effectOptions']);
  }
});



document.observe('dom:loaded', function() {
  new Fader('#headerImage > img');
  new Fader('#logo img', { effectOptions: { delay: 2.5 } });

  if(!navigator.appVersion.match(/MSIE 6/)) {
	$$('#content h2', '#content h3', '#infobar h2', '#sidebar h2').each(function(e) {
		e.addClassName("typeface-js");
		//e.addStyle("font-family: Optimer; font-weight: normal; line-height: 100%;");
	});
	
	_typeface_js.renderDocument( function(e) { e.style.visibility = 'visible' } );
  }
});