
//=============================================================
// MOTION DESTAQUE
//=============================================================

window.onload = destaque;

////////////////////////DESCIDA DO DESTAQUE

function destaque()
{
	mouseEvent();
}

/////////////////////////MOUSE EVENT

function mouseEvent()
{	
	////////////////////////SHARE
	$('.share').mouseover(function() {
		$(this).stop().animate({ 
			marginTop: '1px',
			marginBoton: '5px'
		}, {
			duration: 150,
			easing: 'easeOutBounce' 
		});
	});
	$('.share').mouseout(function() {
		$(this).stop().animate({ 
			marginTop: '5px',
			marginBoton: '0px'
		}, {
			duration: 70,
			easing: 'easeOutBounce' 
		});
	});
	
	
	////////////////////////BTNS
	$('.btn_esq').mouseover(function() {
		$('.seta_esquerda').stop().animate({ 
			left: '7px'
		}, {
			duration: 250,
			easing: 'easeOutBack' 
		});
	});
	
	$('.btn_esq').mouseout(function() {
		$('.seta_esquerda').stop().animate({ 
			left: '13px'
		}, {
			duration: 250,
			easing: 'easeOutBack' 
		});
	});
	
	$('.btn_dir').mouseover(function() {
		$('.seta_direita').stop().animate({ 
			right: '9px'
		}, {
			duration: 250,
			easing: 'easeOutBack' 
		});
		$('.seta_direita_enviar').stop().animate({ 
			right: '-85px'
		}, {
			duration: 250,
			easing: 'easeOutBack' 
		});
	});
	
	$('.btn_dir').mouseout(function() {
		$('.seta_direita').stop().animate({ 
			right: '16px'
		}, {
			duration: 250,
			easing: 'easeOutBack' 
		});
		$('.seta_direita_enviar').stop().animate({ 
			right: '-80px'
		}, {
			duration: 250,
			easing: 'easeOutBack' 
		});
	});
	
	
}

////////////////////////DESTAQUE CLICK

function destaqueClick() 
{
	$('#tabela_expand').animate({ 
		height: '300px'
	}, {
		duration: 0,
		easing: 'easeOutCirc' 
	});  
	
	$('.destaque_falso').animate({ 
		height: '300px'
	}, {
		duration: 300,
		easing: 'easeOutCirc' 
	});
	
	
};	


//=============================================================
// CARREGADO PÁGINA INDEX
//=============================================================

var nArray = new Array;

function pushIndexView( nIndex ) 
{
	nArray.push( nIndex );	
}

function indexView() 
{
	window.setTimeout( "visibleDisplayObj( '" + 'midia_' + nArray[ 0 ] + "' )" , 1000 * ( 3 ) );
	window.setTimeout( "visibleDisplayObj( '" + 'midia_' + nArray[ 1 ] + "' )" , 1000 * ( 3.5 ) );
	
	//
	scrollViewIndex();
}

function scrollViewIndex( )
{	
	window.onscroll = scrollEvent;
	function scrollEvent() 
	{	
		for(var i = 1; i < nArray.length; i++)
		{
			if( elementInViewport( document.getElementById( 'midia_'+ nArray[ i ] ) ) == true ) 
			{
				window.setTimeout( "visibleDisplayObj( '" + 'midia_' + nArray[ i + 1 ] + "' )" , 1000 * ( 0 ) );
			}
		}
	}
}

//=============================================================
// CARREGADO PÁGINA VOZES
//=============================================================

var nFotos = 0;

function numFotos( _nFotos ) 
{
	nFotos = _nFotos;

	//Carrega as 6 primeiras imagens Destaque Interno  
	window.setTimeout( "vozesFlash()", 1000 * 1.5 );
	
	//Carregar o restante baseado na view port do browser
	scrollViewVoz();
}

///
function vozesFlash() 
{
	//Fotos
	for(var i = 2; i < 8; i++)
	{
		var _delay = 'delay_' + i.toString();
		window.setTimeout( "visibleDisplayObj( '" + _delay + "' )" , 1000 * ( i/2.5 ) );
	}
};



function scrollViewVoz( )
{	
	window.onscroll = scrollEvent;
	function scrollEvent() 
	{	
		for(var i = 1; i < nFotos + 2; i++)
		{
			var _fotoMargem = 'foto_margem_' + i.toString();

			if( elementInViewport( document.getElementById( _fotoMargem ) ) == true ) 
			{
				var _delay = 'delay_' + String( i + 1 ) ;
					
				//Carregas os flash que estão visiveis view do browser; 
				visibleDisplayObj( _delay );
			}
		}	
	}
}


//=============================================================
// SCROLL VIEW ELEMENT VISIBLE
//=============================================================

function elementInViewport( el ) 
{
  var top = el.offsetTop;
  var left = el.offsetLeft;
  var width = el.offsetWidth;
  var height = el.offsetHeight;

  while( el.offsetParent ) {
	el = el.offsetParent;
	top += el.offsetTop;
	left += el.offsetLeft;
  }

  return (
	top >= window.pageYOffset &&
	left >= window.pageXOffset &&
	( top + height ) <= ( window.pageYOffset + window.innerHeight ) &&
	( left + width ) <= ( window.pageXOffset + window.innerWidth )
  );
}


//=============================================================
// SCROLL VIEW INVISIBLE
//=============================================================

function visibleDisplayObj( nome )
{	
	if( document.getElementById( nome ).style.display != "inherit" ) 
	document.getElementById( nome ).style.display = "inherit";
}
	
	

