GoldmanSachs.HighlightBox = new Class({
	options : {
		swapImg: false,
		swapCSS: true,
		showTxtColor: '#000000',
		showBgColor: '#ffffff',
		hideTxtColor: '#ffffff',
		hideBgColor: '#000',
		transitionDuration: 150,
		allowBGTransition: true,
		allowTxtTransition: true,
		disableLinks: false
	},
	initialize : function(el, options){
		this.element = el;
		this.setOptions(options);
		this.elementTxt = (this.element.getElements('a')[0])? this.element.getElements('a')[0]: this.element;
		
		if (this.options.swapImg) {
			var i = el.getElements('img')[0];
			var onI = new Asset.image(i.src.substr(0, i.src.lastIndexOf(".")) + '_on' + i.src.substr(i.src.lastIndexOf("."), 4));
			this.img = i;
			this.img.onSrc = onI.src;
			this.img.offSrc = i.src;
		}
		this.bgTrans = new Fx.Style(this.element, 'background-color', {wait: false, duration: this.options.transitionDuration,fps:40})
		this.textTrans = new Fx.Style(this.elementTxt, 'color', {wait: false, duration: this.options.transitionDuration,fps:40})
		
		if (this.options.disableLinks == true) {
			this.elementTxt.onclick = function (event) {
				var evt = new Event(event);
				evt.preventDefault();
			}
		}
		
		this.element.addEvent('mouseenter', this.doShow.bind(this));
		this.element.addEvent('mouseleave', this.doHide.bind(this));
	},
	doShow : function () {
		if (this.options.swapCSS) {
			if(this.options.allowBGTransition == true) {
				this.bgTrans.start(this.options.hideBgColor, this.options.showBgColor);	
			}
			if( this.options.allowTxtTransition == true) {
				this.textTrans.start(this.options.hideTxtColor, this.options.showTxtColor);
			}
		}
		if (this.options.swapImg) {this.img.src = this.img.onSrc;}
	},
	doHide : function () {
		if (this.options.swapCSS) {
			if( this.options.allowBGTransition == true) {
				this.bgTrans.start(this.options.showBgColor, this.options.hideBgColor);
			}
			if( this.options.allowTxtTransition == true) {
				this.textTrans.start(this.options.showTxtColor, this.options.hideTxtColor);
			}
		}
		if (this.options.swapImg) {this.img.src = this.img.offSrc;}
	} 
});
GoldmanSachs.HighlightBox.implement(new Options);
