window.addEvent('load', function() {
	var Tips1 = new Tips($$('.tooltip'), {
		initialize:function(){
			this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 300, wait: false}).set(0);
		},
		onShow: function(toolTip) {
			this.fx.start(1);
		},
		onHide: function(toolTip) {
			this.fx.start(0);
		}
	});
});
var FormToolTips = new Class({
	initialize: function(formElements) {
		var show = this.show;
		var hide = this.hide;
		formElements.each(function(tipster) {
			tipster.addEvent('focus', function() {
				show(tipster);
			}).addEvent('blur', function() {
				hide(tipster);
			});
		});
		$$('*.form-tooltip').each(function(tip) {
			var theTop = tip.getParent().getCoordinates().bottom - tip.getParent().getCoordinates().top;
			theTop = theTop+50;
			var theLeft = tip.getParent().getCoordinates().left;
			theLeft = theLeft-50;
			tip.setStyles({
				'display':'none',
				'left':200,
				'bottom':theTop
			});
			tip.adopt(new Element('img',{
				'properties':{
					'width':195,
					'height':23,
					'src':'/system/modules/com.candg.mortgages.toolsuite/resources/images/bg_tooltip_bottom.png'
				}
			}));
		});

	},
	show: function(tipster) {
		if($(tipster.getProperty('name')+'Help') != null && $(tipster.getProperty('name')+'Help').getStyle('opacity') < 0.5) {
			this.fx = new Fx.Style($(tipster.getProperty('name')+'Help'), 'opacity', {duration: 500, wait: false, onStart:function() {
				$(tipster.getProperty('name')+'Help').setStyle('display','block');
			}}).set(0);
		
			this.fx.start(1);
		}
	},
	hide: function(tipster) {
		if($(tipster.getProperty('name')+'Help') != null && $(tipster.getProperty('name')+'Help').getStyle('opacity') > 0.5) {
			this.fx = new Fx.Style($(tipster.getProperty('name')+'Help'), 'opacity', {duration: 500, wait: false, onComplete:function() {
				$(tipster.getProperty('name')+'Help').setStyle('display','none');
			}}).set(1);
			this.fx.start(0);
		}
	}
});
window.addEvent('load', function() {
	/* Form Help Tooltips Display */
	new FormToolTips($$('.tool-suite select, .tool-suite input'));
});


