var VenueFeatures = Class.create({		
  initialize: function(){
  
    // -- Visual tweaks --
    // If there are any features...
    $$('#venue_features .venue_feature').each(function(e){
  
      // Show feature corners only if there are some features
      $$('#venue_features .corner').invoke('setStyle',{display:'block'})
  
      // Pad the 2nd and/or 3rd feature in the top row (if there's only 1 or 2)
      $(3 - $$('#venue_features .venue_feature').length).times(function(e){
        $$('#venue_features .venue_feature').last().insert({
          after : '<div class="venue_feature first_row"><h3>&nbsp;</h3></div>'
        })
      })
  
      // Don't actually loop
      throw $break
    })


    // -- IE fixes --    
    // Set some classnames as an alternative hook to CSS 3 selectors
    $$('#venue_features .venue_feature:nth-of-type(3n+1)').invoke('addClassName','first_column')
    $$('#venue_features .venue_feature:nth-of-type(1), #venue_features .venue_feature:nth-of-type(2), #venue_features .venue_feature:nth-of-type(3)').invoke('addClassName','first_row')
    
    // IE6/7 is being ridiculous and needs these corners "touched" to make them visible
    //$$('#venue_features .corner').invoke('setStyle',{zoom:1}) 
    $$('.corner').invoke('setStyle',{zoom:1})

    // IE6/7 isn't properly floating the features in the "table"
    // In each row of 3, find the max height and set all divs to that height
    $$('#venue_features .venue_feature').eachSlice(3).each(function(row){
      var row_height = row.collect(function(div) { return div.getHeight() }).max() +'px'
      row.invoke('setStyle', {height:row_height})
    })
  }
})



// Global DOM onload
document.observe("dom:loaded", function() {

  var c = new Common()
  
  if (!$('nterchange')) {
    c.external_links()
    c.randomize()
    
    new Tabs('#main .tab')
    new Carousel('#home_gallery', { delay: 4 })
    new Carousel('#event_ticker', { delay: 0, duration: 2, slides_container: 'ul.events', number_per_page_for_padding: 4, transition: 'up', slides_easing: 'linear' })
    new Carousel('#gallery', { delay: 6 })
    new Carousel('#venue_gallery', { delay: 6, pointer_navigation: 'active' })
    
    new VenueFeatures()    
  }
  
  
  if ($('nterchange')) {    
    $$('.randomize').invoke('removeClassName','randomize')
    
    // Add edit page button beside page title
    $$('img[alt=Edit Page]').each(function(img){
      img.setStyle({margin:0});
      $$('#page_title').invoke('insert',{before:img.up('div').innerHTML});            
    })
  }
  
});

// Global Window Onload
Event.observe(window, 'load', function() { 

  // These are replaced with cufon
  $$('.home #content h2').invoke('setStyle',{visibility:'visible'})
  $$('#content h1').invoke('setStyle',{visibility:'visible'})

});