
		function swapImages(){
			var $active = $('.ambienteList .active');
				var $next = ($('.ambienteList .active').next().length > 0) ? $('.ambienteList .active').next() : $('.ambienteList img:first');
					$active.fadeOut(300,function(){
					$active.removeClass('active');
					$next.fadeIn(300).addClass('active');
				});
		}
			
		$(document).ready(function() {

		
			jQuery.fn.fadeToggle = function(speed, easing, callback) { 
			   return this.animate({opacity: 'toggle'}, speed, easing, callback); 
			}; 			
			
			$('.details').click(function(){
				var thisElement = $(this);
				$.getJSON('/_json'+thisElement.attr('href'), function(json){
					$('.materialDetails').remove();
					thisElement.parent().prepend(json.content);
					$('.materialDetails').hide();
					$('.materialDetails').fadeToggle(400);
					$('.close').click(function(){
						$(this).parent().remove();
						return false;
					});
				});			
				return false;
			});
			
			$('.imageDetails').click(function(){
				var thisElement = $(this);
				$.getJSON('/_json'+thisElement.attr('href'), function(json){
					$('.materialDetails').remove();
					thisElement.parent().prepend(json.content);
					$('.materialDetails').hide();
					$('.materialDetails').fadeToggle(400);
					$('.close').click(function(){
						$(this).parent().remove();
						return false;
					});
				});			
				return false;
			});

			// $("img.appIcon").
			
			//$(".ambienteList img").first().one("load",function(){
			$(".ambienteList img:eq(0)").one("load",function(){
				$(this).fadeIn(300).addClass('active')				
				setInterval('swapImages()', 10000);
			})
			.each(function(){
				if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) >= 6)) 
					$(this).trigger("load");
			}); 
			
			$(".externalLink").attr("target",'_blank');
			
			$('.appIcon').each(function(i){
				$(this).removeClass('appIcon').attr('style','width:46px;height:46px;margin:0px;position:absolute;margin-left:1px;').wrap('<div class="appIcon" style="width:48px;height:48px;float:left;" />').before('<img src="templates/xuits/images/mask48.png" style="width:48px;height:48px;margin:0px;position:absolute;margin-bottom:-48px;z-index:10;" />');
			});
			
			$('#___plusone_0').css({paddingLeft: '2px', paddingTop: '4px'});
			
		});

