var FancyFonts = Class.create({
  initialize: function(){
    Cufon.set('fontFamily', 'vagrounded').replace('#nav > ul > li > a')('#main h2');
    Cufon('#sidebar_form h2', {fontFamily: 'Smile',textShadow: '2px 1px #666'});
    Cufon('#main h1', {fontFamily: 'Smile',textShadow: '2px 1px #4E7ED0'});
    Cufon('#whitefooter h2', {fontFamily: 'Smile',textShadow: '2px 1px #ddd'});    
    Cufon('.callout h2', {fontFamily: 'Smile',textShadow: '2px 1px #4E7ED0'});
    Cufon('.carousel h2', {fontFamily: 'Smile',textShadow: '2px 1px #222'});
    Cufon('.carousel h3', {fontFamily: 'Smile',textShadow: '2px 1px #222'});
    return;

  }
  
});

// Hover Behaviour for Nav etc.
var HoverBehavior = Class.create();
HoverBehavior.prototype = {
  initialize: function() {
    $A(document.styleSheets).each( function(stylesheet) {
      $A(stylesheet.rules).each( function(rule) {
        if( rule.selectorText.match(/:hover/i) ) {
          stylesheet.addRule( rule.selectorText.replace(/:hover/ig, '.hover'), rule.style.cssText );
        }
      });
    });

    $A(arguments).each( function(arg) {
      $$(arg).each( function(tag) {
        Event.observe(tag, 'mouseenter', function() { Element.addClassName(tag, 'hover'); }, true);
        Event.observe(tag, 'mouseleave', function() { Element.removeClassName(tag, 'hover'); }, true);
      });
    });
  }
};

var NavigationEnhancements = Class.create();
NavigationEnhancements.prototype = {
  initialize : function() {
    //DISABLE TITLES TOOLTIPS ON NAV HOVER
    $$("#nav li a").each(function(tag){
      tag.old_title = tag.title
      Event.observe(tag, 'mouseover', function() { tag.title="" }, true);
      Event.observe(tag, 'mouseout', function() { tag.title=tag.old_title }, true);
    })
  }
}


// Global DOM onload
document.observe("dom:loaded", function() {
  new FancyFonts();
  new NavigationEnhancements();
  if(Prototype.Browser.IE){
    var navHover = new HoverBehavior("#nav li");
  }
  
  if($('accordion_container')){
     new Page_Accordion("accordion_container");
  }  
  if($('home_carousel')){
    var my_glider = new Glider('home_carousel', {duration:0.5});
    $$('.controls a')[0].addClassName('active')
    // new Carousel('#home_carousel', {transition: 'left', number_per_page_for_padding: 1} )
    // new Carousel('#home_carousel', { number_per_page_for_padding: 1, transition: 'up', slides_easing: 'linear' })
  }
  
});

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