$(document).ready(function(){
	
	//$('.related_post').slideUp(0);
	
	$('.related').click(function(){
		//$('.related_post').slideToggle(300);
	});
	
	$('.related_post_title').hide();
	
	
	$('.post a[href$="jpg"], .post a[href$="jpeg"], .post a[href$="png"], .post a[href$="gif"]').attr('rel','fancybox')
	$('.post a[href$="jpg"], .post a[href$="jpeg"], .post a[href$="png"], .post a[href$="gif"]').fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'changeFade'	:	'fast',
		'margin'		:	100,
		'cyclic'		:	true,
		'overlayColor'	:	'#000',
		'overlayOpacity':	0.8,
		'showNavArrows'	:	true,
		'titleShow'		:	false
	});
	
	
	
	
	
	$('.menu ul li .seta').each(function(){
		if ($(this).parent().is('.clicado') == false){
			$(this).css('width','0px');	
		}
		//$(this).css('width','0px');
		$(this).parent().mouseover(function(){
			$(this).not('.clicado').children('.seta').stop(true, true).animate({width:'10px'}, 300);
		});
		$(this).parent().mouseout(function(){
			$(this).not('.clicado').children('.seta').stop(true, true).animate({width:'0px'}, 300);
		});
	});
/*	$('.videos .conteudo #slides').cycle({
		fx: 'scrollHorz',
		timeout: 0,
		prev: '#prev',
		next: '#next'
	});
	$('#agencia #container').cycle({
		fx: 'scrollHorz',
		timeout: 0
	});
	$('#contato #container').cycle({
		fx: 'scrollHorz',
		timeout: 0
	});
	$('.areacontato .container').cycle({
		fx: 'fade',
		timeout: 0
	});
*/	
	$('.newstyle').click(function() { 
		$('#agencia #container').cycle(0); 
		return false; 
	});
	$('.newtrade').click(function() { 
		$('#agencia #container').cycle(1); 
		return false; 
	});
	$('.grupoabc').click(function() { 
		$('#agencia #container').cycle(2); 
		return false; 
	});
	$('.pessoas').click(function() { 
		$('#agencia #container').cycle(3); 
		return false; 
	});
	$('.premios').click(function() { 
		$('#agencia #container').cycle(4); 
		return false; 
	});
	$('.kombi').click(function() { 
		$('#agencia #container').cycle(5); 
		return false; 
	});
	
	$('.slide1').click(function() { 
		$('.areacontato .container').cycle(0); 
		return false; 
	});
	$('.slide2').click(function() { 
		$('.areacontato .container').cycle(1); 
		return false; 
	});
	$('.slide3').click(function() { 
		$('.areacontato .container').cycle(2); 
		return false; 
	});
	$('.slide4').click(function() { 
		//$('.areacontato .container').cycle(3); 
		
		
		return false; 
	});
	
	// form contato
	$('.iframe').fancybox({
		'hideOnContentClick': false,
		'overlayColor'	:	'#000',
		'overlayOpacity':	0.8,
		'titleShow'		:	false,
		'width'			:	736,
		'height'		:	500
	});
	
	$('.menuagencia ul li .seta').each(function(){
		
		if ($(this).parent().is('.clicado') == false){
			$(this).css('width','0px');	
		}
		
		$(this).parent().mouseover(function(){
			$(this).not('.clicado').children('.seta').stop(true, true).animate({width:'10px'}, 300);
		});
		$(this).parent().mouseout(function(){
			$(this).not('.clicado').children('.seta').stop(true, true).animate({width:'0px'}, 300);
		});
		$(this).parent().click(function(){
			
			$(this).parent().parent().children().each(function(){
				$(this).children('a.clicado').children('.seta').stop(true, true).animate({width:'0px'}, 300);
				$(this).children('a.clicado').toggleClass('clicado');
			});
			
			$(this).delay(100).toggleClass('clicado');
		});
		
	});
	
	
	
	$('#contato .item').each(function(){
		$(this).not('.clicado').children('.ponto').children('img.bt_over').hide();
		
		$(this).mouseover(function(){
			$(this).not('.clicado').children('.ponto').children('img.bt_over').stop(true,true).fadeIn(300);
		});
		$(this).mouseout(function(){
			$(this).not('.clicado').children('.ponto').children('img.bt_over').stop(true,true).fadeOut(300);
		});
		$(this).click(function(){
			$(this).parent().children().each(function(){
				if ($(this).is('.clicado')){
					$(this).children('.ponto').children('img.bt_over').stop(true,true).fadeOut(300);
					$(this).toggleClass('clicado');
				}
			});
			$(this).delay(100).toggleClass('clicado');
		});
	});
	
	
	/*$('#area_posts').jScrollPane({
			verticalGutter: 0,
			verticalDragMinHeight: 11,
			verticalDragMaxHeight: 11,
			horizontalDragMinWidth: 11,
			horizontalDragMaxWidth: 11,
			autoReinitialise: true
	});*/
/*	$('.arearolagem').jScrollPane({
			verticalGutter: 10,
			showArrows: true,
			verticalDragMinHeight: 11,
			verticalDragMaxHeight: 11,
			horizontalDragMinWidth: 11,
			horizontalDragMaxWidth: 11,
			autoReinitialise: true
	});
	$('#rolagem').jScrollPane({
			verticalGutter: 10,
			showArrows: true,
			verticalDragMinHeight: 11,
			verticalDragMaxHeight: 11,
			horizontalDragMinWidth: 11,
			horizontalDragMaxWidth: 11,
			autoReinitialise: true
	});
	
	  $('.twittertexto').resizefont({
		  maxsize:30,
		  minsize:12,
		  orientation:'both',
		  fontkit:false
	  });
*/	
	/*$('.tweet').each(function(){
		var alturaBox = Number($(this).css('height').replace('px',''));
		var alturaTitulo = Number($(this).children('.cont').height());
		var posicao = Number((( alturaBox / 2 ) - (alturaTitulo / 2)));
		$(this).children('.cont').css('margin-top',posicao);
	});*/
		
	$('.single img').each(function(index){
		if ($(this).attr('width') > 394){
			$(this).attr('width', 394);
			$(this).attr('height', null);
		}
	});
	
	$('.over').hide();
	$('.foto_mapa').hover(function(){
		$(this).children('a').children('.over').stop(true,true).fadeIn(300);
	},function(){
		$(this).children('a').children('.over').stop(true,true).fadeOut(300);
	});
	
	
	$('.aviso').each(function(){
		$(this).hide()
	});
	
	$('#formcontato .enviar').click(function(){
		$('#formcontato').submit();
	});
	
	$('#formcontato').submit(function() {
		
		linkForm = $('#logo').children('a').children('img').attr('src');
		linkForm = linkForm.substr(0, linkForm.indexOf('images/logo.png')) + 'php/mail_contato.php';
		
		$.post(linkForm, $("#formcontato").serialize(), function(data) {
			
			//alert(data);
			
			$("#formcontato").fadeOut(300).delay(3000).fadeIn(300);
			$(".formcontato .aviso").delay(300).fadeIn(300).delay(2400).fadeOut(300);
			
			setTimeout(function(){
				$(".campo input, .campo textarea").each(function(){
					$(this).val('');
				});
			}, 300);
			
		});
		return false;
	});
	
	
	
	$('#formcurriculo .enviar').click(function(){
		$('#formcurriculo').submit();
	});
	
	$('#formcurriculo').submit(function() {
		
		linkForm = $('#logo').children('a').children('img').attr('src');
		linkForm = linkForm.substr(0, linkForm.indexOf('images/logo.png')) + 'php/mail_curriculo.php';
		
		$.post(linkForm, $("#formcurriculo").serialize(), function(data) {
			
			$("#formcurriculo").fadeOut(300).delay(3000).fadeIn(300);
			$(".formcurriculo .aviso").delay(300).fadeIn(300).delay(2400).fadeOut(300);
			
			setTimeout(function(){
				$(".campo input, .campo textarea").each(function(){
					$(this).val('');
				});
			}, 300);
			
		});
		return false;
	});
	
	
	$('.post .texto').children('p:has(img)').css('margin' , '0 0 15px 0');
	
});
