jQuery(function($){
	/*
	HOME
	*/
	if( $('#home-banner').length ){
		$('#home-banner ul')
			.before('<div id="home-banner-nav">')
			.cycle({	
				fx: 'scrollLeft',
				speed: 2000,
				timeout: 10000,
				pager:  '#home-banner-nav',
				pause: 1,
				pauseOnPagerHover: 1
			});
	}
	
	/*
	PAGE
	*/
	$('.galeria')
		.each(function(){
			var firstImageHref = $(this).find('li:first-child a').attr('href');
			$(this)
				.append('<div class="galeria-image-area"></div>')
				.find('.galeria-image-area').append('<img src="'+firstImageHref+'" />');
		})
		.find('a').click(function(e){
			e.preventDefault();
			var imageHref = $(this).attr('href');
			$(this).parents('.galeria').find('.galeria-image-area').empty().append('<img src="'+imageHref+'" />');
		});	
	
	$('.conteudo-lateral-tiulos li').toggle(function(){
		var index = $(this).index();
		$('.conteudo-lateral-tiulos li').children('div').remove();
		$('.conteudo-lateral-textos > div').eq(index).clone().appendTo($(this));
	},function(){		
		$(this).children('div').remove();
	});
	
	/*
	CLIPPING IMPRENSA
	*/
	var 
		currentClipping	= window.location.href.split("#")[1],
		currentClippingIndex = currentClipping ? $('#'+currentClipping+'').index() + 1 : 1;	
	
	$('#clipping-imprensa-page').waterwheelCarousel({
		startingItem: currentClippingIndex,
		startingWaveSeparation: 0,
		centerOffset: 30,
		startingItemSeparation: 187,
		itemSeparationFactor: .7,
		itemDecreaseFactor: .75,
		opacityDecreaseFactor: 1,
		flankingItems: 2,
		movedToCenter: function($newCenterItem){
			$newCenterItem.find('.carousel-image-desc').show();
		},
		movingFromCenter: function($removedCenterItem){
			$removedCenterItem.find('.carousel-image-desc').hide();
		},
		clickedCenter: function($clicked){
			var html, 
				largeimage = $clicked.attr('largeImg'), 
				fullimage = $clicked.attr('fullImg'), 
				thumbimage = $clicked.find('img').attr('src'), 
				fonte = $clicked.find('h3').text(), 
				title = $clicked.find('h2').text(), 
				data = $clicked.find('small').text();
			
			html = '<div id="lightbox"></div><div id="lightbox-content">';	
			html += '<div id="lightbox-topbar"><div class="left"><strong>'+ fonte +'</strong> '+ title +' - '+ data +'</div><div class="right">';
			html += '<a href="#" onclick="window.print()" class="btn-print">Imprimir</a>';
			html += '<iframe src="http://www.facebook.com/plugins/like.php?app_id=271488832877471&amp;href='+ largeimage +'&amp;send=false&amp;layout=button_count&amp;width=90&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>';
			html += '<a href="http://twitter.com/share" class="twitter-share-button" data-url="'+ largeimage +'" data-text="'+ fonte +' - '+ title +' - '+ data +'" data-count="none" data-lang="pt">Tweetar</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
			html += '</div></div>';
			html += '<div>';
			html += '<img src="'+ fullimage +'" width="100%"  />';
			//html += '<div id="lightbox-thumbimage"><a href="'+ fullimage +'"><img src="'+ thumbimage +'" /></a></div>';
			//html += '<div id="lightbox-largeimage"><a href="'+ fullimage +'"><img src="'+ largeimage +'" /></a></div>';
			html += '</div></div>';
			
			$('body').prepend(html);
		}
	});	
	$('#lightbox').live('click', function(){ $('#lightbox, #lightbox-content').remove(); });
	/*$('#lightbox-largeimage a, #lightbox-thumbimage a').live('click', function(e){
		e.preventDefault();		
		
		$('#lightbox-wrap').remove()
		$('#lightbox-content').append('<img src="'+ $(this).attr('href') +'" width="100%" />');		
	});*/
	
	
	/*
	DEPOIMENTOS
	*/
	$('#depoimentos-nav ul').simplecarousel({
		size: 7,
		scroll: 4
	});
	
	
	/*
	SERVICOS
	*/
	$('#servico-page li')
		.find('h2').hide()
		.end().hover(function(){
			$(this).find('h2').fadeIn();
		},function(){
			$(this).find('h2').fadeOut();
		});
});
