// Copyright (c) 2007 Jason Garber
// 
// Uses script.aculo.us and Prototype to make the links fade in and out

LinkFade = Class.create();
LinkFade.prototype = {
  initialize:function(element, hoverColor, normalColor) {
    this.element = $(element);
    this.hoverColor = hoverColor;
		this.normalColor = normalColor;
		this.originalBackground = Element.getStyle(this.element, 'background-color');
    if (!this.originalBackground) {
      this.originalBackground = "transparent";
    }

    this.mouseoverListener = this.enterHover.bindAsEventListener(this);
    this.mouseoutListener = this.leaveHover.bindAsEventListener(this);

    Event.observe(this.element, 'mouseover', this.mouseoverListener);
    Event.observe(this.element, 'mouseout', this.mouseoutListener);
  },
  enterHover: function() {
		this.element.style.backgroundColor = this.hoverColor;
		if (this.leave_hover_effect) { this.leave_hover_effect.cancel(); }
/*		if (this.enter_hover_effect) return;*/
/*		this.enter_hover_effect = new Effect.Highlight(this.element, { 
			startcolor:this.normalColor, 
			endcolor:this.hoverColor, 
			restorecolor:this.hoverColor, 
			duration: 5 });*/
  },
  leaveHover: function() {
/*		if (this.effect) { this.effect.cancel(); }*/
		this.leave_hover_effect = new Effect.Highlight(this.element, { 
			startcolor:this.hoverColor, 
			endcolor:this.normalColor, 
			restorecolor:this.originalBackground, 
			duration: 0.25 });
  }
}

