window.initPulsables = function (pulsables){
	pulsables.each(function(pulsable){
		pulsable.pulse = function (start, end) {
			end = this.retrieve('highlight:original', this.getStyle('color'));
			end = (end == 'transparent') ? '#fff' : end;
			var tween = this.get('tween');
			tween.start('color', start || '#ffff88', end).chain(function(){
				this.setStyle('color', this.retrieve('highlight:original'));
				tween.callChain();
			}.bind(this));
			return this;
		}
	});
	return pulsables;
}
// Initialize elements that should pulse any targets they contain on mouseenter
// pulseContainers - Array of elements that might contain elements to pulse.
// pulseTargets - Array of elements to pulse, defaults to contained elements with PulseTargetText class.
window.initPulseContainers = function(pulseContainers, pulseTargets) {
	pulseContainers.each(function(pulseContainer) {
		var pulseFunnel = pulseContainer.getElement('.PulseFunnel');
		pulseContainer.targets = window.initPulsables(pulseTargets || pulseFunnel ?pulseFunnel.getElements('.PulseTargetText') :pulseContainer.getElements('.PulseTargetText'));
		pulseContainer.addEvent('mouseenter', function (){
			this.targets.each(function(target){target.pulse();});
		});
	});
	return pulseContainers;
}

window.addEvent('domready', function() {
	window.initPulsables($$('.Pulsable'));	// Initialize elements that should be able to pulse on request.
	window.initPulseContainers($$('.PulseContainer'));
});
