// register callbacks to show and hide ajax activity indicators automatically
Ajax.Responders.register({
  onCreate: function() {
    if($('activity') && Ajax.activeRequestCount>0)
      Effect.Appear('activity',{duration:0.5,queue:'end'});
  },
  onComplete: function() {
    if($('activity') && Ajax.activeRequestCount==0)
      Effect.Fade('activity',{duration:0.5,queue:'end'});
  }
});
// fade flash messages automatically
Event.observe(window, 'load', function() { 
  $A(document.getElementsByClassName('alert')).each(function(o) {
    o.opacity = 100.0
    Effect.Fade(o, {delay: 5.0})
  });
});
// set onmouseover/onmouseout properties for gallery headers
// var Nubbins = {
//   /* Monitored region elements */
//   regions: [],
//   
//   /* Target elements -> monitored region element */
//   targets: [],
//   
//   /* Event observer handle */
//   observer: false,
// 
//   /* We also need to keep track of the active nubbin
//    * and the target we're currently hovering over. */
//   activeNubbin: false,
//   activeTarget: false,
//   activeElement: false,
//   
//   /* Seconds to wait before showing or hiding nubbins */
//   delay: 0.45,
//   
//   
//   start: function() {
//     if (!this.observer) {
//       this.observer = this.onMouseMovement.bind(this);
//       Event.observe(document, 'mouseover', this.observer, true);
//     }
//   },
//   
//   stop: function() {
//     if (this.observer) {
//       Event.stopObserving(document, 'mouseover', this.observer);
//       delete this.observer;
//     }
//   },
//   
//   addRegion: function(region, target, force) {
//     if (!this.hasLoaded && !force) {
//       return Event.observe(window, 'load', function() {
//         this.addRegion(region, target, true);
//       }.bind(this));
//     }
//         
//     region = $(region);
//     target = $(target || region);
//     
//     this.regions.push(region);
//     this.targets.push(target);
//   },
//   
//   onMouseMovement: function(event) {
//     if (!this.observer) return;
//     var element = this.activeElement = Event.element(event);
//     var elementInfo = this.getElementInfo(element);
// 
//     if (elementInfo.nubbin) {
//       this.triggerNubbinAppearance(elementInfo.nubbin, elementInfo.target);
//       
//     } else if (this.activeNubbin) {
//       this.triggerNubbinDeparture();
//     }
//   },
// 
//   getElementInfo: function(element) {
//     var info = {};
//     
//     if (info.target = this.findTargetForElement(element)) 
//       if (info.region = this.findRegionForTarget(info.target))
//         info.nubbin = this.findNubbinForRegion(info.region);
//     
//     return info;
//   },
// 
//   findTargetForElement: function(element) {
//     return this.targets.find(function(target) {
//       return element == target || (element.childOf && element.childOf(target));
//     });
//   },
//   
//   findRegionForTarget: function(target) {
//     return this.regions[this.targets.indexOf(target)];
//   },
//   
//   findNubbinForRegion: function(region) {
//     return region.down('ul.nubbin');
//   },
//   
//   setActiveNubbin: function(nubbin) {
//     if (this.activeNubbin == nubbin) return;
//     if (this.activeNubbin) this.unsetActiveNubbin();
//     this.activeNubbin = nubbin;
//     nubbin.up('h3.nubbin_title').addClassName('hover');
//   },
// 
//   unsetActiveNubbin: function() {
//     if (this.activeNubbin) {
//       this.activeNubbin.up('h3.nubbin_title').removeClassName('hover');
//       this.activeNubbin = false;
//       this.unsetActiveTarget();
//     }
//   },
//   
//   unsetActiveTarget: function() {
//     this.activeTarget = false;
//     this.cancelTriggers();
//   },
//   
//   triggerNubbinAppearance: function(nubbin, target) {
//     var delay = this.delay;
//     
//     if (this.activeTarget) {
//       if (this.activeTarget == target) return;
//       delay = 0;
//     }
//     
//     this.cancelTriggers();
//     this.activeTarget = target;
//     
//     this.nubbinAppearanceTrigger = function() {
//       if (target == this.activeTarget)
//         this.setActiveNubbin(nubbin);
//     }.bind(this).timeout(delay);
//   },
//   
//   triggerNubbinDeparture: function() {
//     var nubbin = this.activeNubbin, target = this.activeTarget, trigger;
// 
//     if (!this.nubbinDepartureTrigger || 
//         this.nubbinDepartureTrigger.target != target) {
//       
//       this.cancelTriggers();
//         
//       this.nubbinDepartureTrigger = function() {
//         this.nubbinDepartureTrigger = false;
//         if (target != this.activeTarget || 
//           !this.elementIsActiveNubbin(this.activeElement))
//             this.unsetActiveNubbin();
//             
//       }.bind(this).timeout(this.delay);
//       
//       this.nubbinDepartureTrigger.target = target;
//     }
//   },
//   
//   elementIsActiveNubbin: function(element) {
//     var activeNubbin = this.activeNubbin;
//     return element == activeNubbin || element.childOf(activeNubbin);
//   },
//   
//   cancelTriggers: function() {
//     if (this.nubbinAppearanceTrigger) {
//       this.nubbinAppearanceTrigger.cancel();
//       this.nubbinAppearanceTrigger = false;
//     }
//     
//     if (this.nubbinDepartureTrigger) {
//       this.nubbinDepartureTrigger.cancel();
//       this.nubbinDepartureTrigger = false;
//     }
//   }
// }
// Event.observe(window, 'load', function() {
//   Nubbins.hasLoaded = true;
//   Nubbins.start();
// });
// helper function to integrate SlideShowPro with Lightbox 
function LightboxDelegate(url,caption) {
	var objLink = document.createElement('a');
	objLink.setAttribute('href',url);
	objLink.setAttribute('rel','lightbox');
	objLink.setAttribute('title',caption);
	Lightbox.prototype.start(objLink);
}
// helper functions for hover effects on backdrop packages page
function go_to_pic(pic_id) {
  c_id = $('current_pic').value;
  if(pic_id == c_id) return false;
  _current_pic = $("pic_"+c_id);
  new Element.hide(_current_pic);
  new Effect.Appear("pic_"+pic_id);
  move_class('pic_select_'+c_id,'pic_select_'+pic_id,"current");
  $('current_pic').value = pic_id;
}
function move_class(from,to,class_name){
  Element.removeClassName(from,class_name);
  Element.addClassName(to,class_name);
}
window.onload = function() {
	current_pic = $('current_pic')
	if(current_pic) current_pic.value = 2; //Firefox oddness
}
