$(document).ready(function(){
		$("a[rel=external]").attr('target','_blank');
	});

// Footer sempre no rodapé - BUGANDO TODO O SCRIPT NO IE6
$(document).ready(function(){
		positionFooter(); 
		function positionFooter(){
			var padding_top = $("footer").css("padding-top").replace("px", "");
			var page_height = $(document.body).height() - padding_top;
			var window_height = $(window).height();
			var difference = window_height - page_height;
			if (difference < 0) 
				difference = 0;
	 
			$("footer").css({
				padding: difference + "px 0 0 0"
			})
		}
		$(window)
			.resize(positionFooter)
	});


// MAIS INFORMACOES
$(document).ready(function(){
		$('#maisInfo').hide();
		$("a.btMais").click(function () {
		$("#maisInfo").slideToggle("slow");
		});    
	});

// SUBMENU
$(document).ready(function(){ 
        $("ul.sf-menu").superfish({ 
            animation: {height:'show'},   // slide-down effect without fade-in 
            delay:     500,
			autoArrows: false
        }); 
    }); 

// ADIONAR DINAMICAMENTE A SETA DO SUBMENU
$(document).ready(function(){ 
		$("#main .chmd2 nav ul li ul").append('<li class="arrow"><img src="img/arrow.png" /></li>');
		return false;
	}); 


// SLIDES
$(document).ready(function() {
	//rotation speed and timer
		var speed = 8000;
		var run = setInterval('rotate()', speed);	
		var stop = clearInterval('rotate()', speed);
		
		//grab the width and calculate left value
		var item_width = $('#slides').outerWidth(); 
		var left_value = item_width * (-1); 	
		
		//set the default item to the correct position 
		$('#slides').css({'left' : left_value});

		jQuery('#prev').click(function() {
				jQuery('#slides').fadeOut(2000, function() {
					//move the last item and put it as first item
					jQuery('.slide:first, .slide2:first').before(jQuery('.slide:last, .slide2:last'));
					jQuery('#slides').fadeIn(2000);
					setButtonText();
	 
				});
	 
			//cancel the link behavior
			return false;
		}); 
	 
		//if user clicked on next button
		jQuery('#next').click(function() {
				jQuery('#slides').fadeOut(2000, function() {
					//move the last item and put it as first item
					jQuery('.slide:last, .slide2:last').after(jQuery('.slide:first, .slide2:first'));
					jQuery('#slides').fadeIn(2000);
					setButtonText();
					
			});

			//cancel the link behavior
			return false; 

		});     

//funcao para pausar a sequencia quando clicar em um dos botoes (reinicar timer)
		jQuery('#next, #prev').hover(
			function() {
				clearInterval(run);
			},  
			function() {
			run = setInterval('rotate()', speed);	
		}
		  );  
  
	});  


	function rotate() {
		jQuery('#next').click();
	}

	function stop() {
		jQuery('#next').click(stop);
	}

	function setButtonText()
	{
		jQuery('#prev').attr('title',jQuery('.slide:last .title').html());
		jQuery('#next').attr('title',jQuery('.slide:nth-child(2) .title').html());
	}


// alterar imagens com fade
$(document).ready(function() {
	$(".tab_content").hide();
	$(".tab_content:first").show(); 
	$("ul.tabs li").mouseover(function() {
		$(".tab_content").hide(); 
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
});

// ir ao topo
$(document).ready(function() {
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });

});


// carosel
jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        vertical: true,
        scroll: 1
    });
});



