﻿

$(document).ready(function()
{
	
	// CRIA MOVIMENTO AO CLICAR NOS LINKS "VOLTAR PRO TOPO"
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
	
	
	// CONFIGURA O LIGHTBOX (FANCYBOX)
	$("a#lightbox").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titlePosition'	: 'over',
		'overlayColor'	: '#000',
		'overlayOpacity': 0.7
	});
	$("a#iframebox").fancybox({
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'overlayColor'	: '#000',
		'overlayOpacity': 0.7,
		'type':'iframe'
	});
	
	
	// EXPANDER
	$('div.perfil p').expander({
		slicePoint: 150,
		expandText: 'Ler mais',
		expandPrefix: '[...] ',
		userCollapseText: '[Fechar]'
	});
});


function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'width=600,height=500,top=40,left=40,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');");
}


function applyAutoFixed ($id)
{
	// CONTROLE DE FIXED DO BOX DE FILTROS
	$(function()
	{
		var top = $($id).offset().top - parseFloat($($id).css('marginTop').replace(/auto/, 0));
		$(window).scroll(function (event) {
		var y = $(this).scrollTop();
		
		if (y >= top) {
			$($id).addClass('fixed');
		} else {
			$($id).removeClass('fixed');
		}
	  });
	});
}


function cropBiografia ($slicePoint)
{
	if($slicePoint==undefined) $slicePoint = 120;
	
	$(function(){
		//////////////
		// EXPANDER //
		//////////////
		$('span.bio p').expander({
			slicePoint: 120,
			expandPrefix: '[...] ',
			expandText: 'Ler mais &raquo;',
			userCollapseText: '[Fechar]',
			expandSpeed: 5000,
			beforeExpand: function($thisEl) {window.location = 'perfil.php'}
		});
	});
}


function isObjectSmallerThanWindow($objectID)
{
	//alert ("window innerHeight: "+window.innerHeight);
	//alert ("$idToCheck clientHeight: "+document.getElementById($objectID).clientHeight);
	return window.innerHeight > document.getElementById($objectID).clientHeight;
}


