/*******

	***	Anchor Slider by Cedric Dugas   ***
	*** Http://www.position-absolute.com ***
	
	Never have an anchor jumping your content, slide it.

	Don't forget to put an id to your anchor !
	You can use and modify this script for any project you want, but please leave this comment as credit.
	
*****/
		
jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 800
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}





	function slideSwitch()
	{
		var $active = $('#banner DIV.active'); 
		if ( $active.length == 0 ) $active = $('#banner DIV:last');
		
		// use this to pull the divs in the order they appear in the markup
		var $next =  $active.next().length ? $active.next(): $('#banner DIV:first');		  
		var $prev =  $active.prev().length ? $active.prev(): $('#banner DIV:first');

		
		var fondo = $next.find("a").attr("class");
		$active.addClass('last-active');
		
		$next
		.css({opacity: 0.0})
		.addClass('active')
		.animate({opacity: 1.0, backgroundColor: fondo}, 400, function(){$active.removeClass('active last-active')});
	}
	
	
	/*
	var interval;
	$('#banner div').hover(function() {
		interval = setInterval( "slideSwitch()", 2000 );
	},
	function() {
		clearInterval(interval);
	});*/
	
	$(document).ready(function()
	{
		$("#submenu_cursos").hide();		
		$("li.m_cursos").mouseover(function(event){$("#submenu_cursos").show();});				
		$("li.m_cursos").mouseout(function(event){$("#submenu_cursos").hide();});				
	
		$("#submenu_cursos").hover(
			function()
			{
				$(this).show();
			},
			function()
			{
				$(this).hide();
			}
		);
		
		var intervalo = setInterval( "slideSwitch()", 4000 );
		
		$("a.anchorLink").anchorAnimate()
		$('a.btn_next').click(function()
		{
			slideSwitch()
			clearInterval(intervalo);
		});
	});
	
	$(function()
	{
		//var intervalo = setInterval( "slideSwitch()", 4000 );
	});
	
	
