var Icon = {
	elements : null,
	
	init : function() {
        $(document).ready(Icon._init);
    },
    
    _init : function () {
		Icon.elements = $('#icoFacilities div');
		
		if (!Icon.elements) return;
		
		//console.log(Icon.elements);
		Icon.elements.each(function(index) {
			$(this).css({'position' : 'relative', 'overflow' : 'hidden'});
			$(this).empty();
			
			$('<span></span>').addClass('image').css({'position' : 'absolute', 'top' : '118px', 'left' :'0px'}).appendTo($(this));
			$('<span></span>').addClass('text').css({'position' : 'absolute', 'top' : '118px', 'left' :'0px'}).appendTo($(this));
			
			$(this).mouseover(function() {
				var image = $(this).children('span.image');
				var text = $(this).children('span.text');
				
				$(image).animate({'top' : 0}, { queue:false, duration:300 });
				$(text).animate({'top' : 0}, { queue:false, duration:500 });
			});
			
			$(this).mouseout(function() {
				var image = $(this).children('span.image');
				var text = $(this).children('span.text');
				
				$(image).animate({'top' : 118}, { queue:false, duration:300 });
				$(text).animate({'top' : 118}, { queue:false, duration:500 });
			});
			
			/*
			$(this).mouseover(function() {
				var current = $(this).children('span');
				
				if (!current.hasClass('back')) {
					$(this).children('span').flip({ 
						direction: 'lr', 
						bgColor: '#000000',
						color: '#521439' ,
						speed : 300,
						onBefore : function() {
							current.addClass('back');
						}
					}); 
				}
			});
			
			$(this).mouseout(function() {
				var current = $(this).children('span');
				
				if (current.hasClass('back')) {
					$(this).children('span').flip({ 
						direction: 'rl', 
						color: '#521439' ,
						bgColor: '#000000',
						speed : 300,
						onBefore : function() {
							current.removeClass('back');
						}
					}); 
				}
			});
			*/
		});
	},
	onMouseEnter : function() {
		this.rollOver.fade('toggle');
	},
	onMouseLeave : function() {
		this.rollOver.fade('toggle');
	}
}

Icon.init();
