/*
Part of BizDir by Diego Massanti
*/

BizDir.PublicUI = new Class({
	initialize: function() {
		if ($('rubros-list')) {
			$('rubros-list').getChildren('li').each(function(item, index) {
			item.set('morph', {duration: 'short', transition: 'Quad'});
				item.addEvent('mouseover', function(e) {
					//item.setStyle('cursor', 'pointer');
					item.morph('.highlighted-item');
					item.getChildren('a').each(function(i2){
					//	i2.morph('.white');
					});
				}.bind(this));
				item.addEvent('mouseleave', function(e) {
					item.morph('.normal-item');
					item.getChildren('a').each(function(i2){
						i2.morph('.blue');
					});
				}.bind(this));
				item.addEvent('click', function(e) {
					//window.location = e.target.getChildren('a').get('href');
				});
			});
		}
		
		if ($('flashMessage')) {
			this.flashAndHide($('flashMessage'), true);
		}
	},
	
	flashAndHide: function(e, hide) {
		
		if ($(e)) {

			var flashes = 5;
			var hl = function() {
				e.highlight();
				flashes--;

				if (flashes == 0) {
					flashFunction = $clear(flashFunction);
					if (hide == true ) {
						var slideOut = function() { this.slide('out');}
						var sof = slideOut.delay(5000, e);
					}
				}
			}

		var flashFunction = hl.periodical(500, this);
		
		}
	}
});

window.addEvent('domready', function() {
	var UI = new BizDir.PublicUI();
});
