$(document).ready(function() {
	$( "#slideshow" ).uberbox({ speed: 10000, auto: true, thumber: "#slideshow-thumbs", transition: { fx: "fade", speed: "slow" } } );
	
	var scrollAmount = 82;
		scrollSpeed = 400;
	
	if( $( "#slideshow ul.uberbox-slides li" ).length > 3 ) {
		$( "#scroll" ).show();
	}

	$( "#scroll-down" ).click( function() {
		var elem = $('#slideshow-thumbs-rapper');
		var targetOffset = elem.scrollTop() + scrollAmount;
		elem.animate({scrollTop: targetOffset}, scrollSpeed);		
	});
	$( "#scroll-up" ).click( function() {
		var elem = $('#slideshow-thumbs-rapper');
		var targetOffset = elem.scrollTop() - scrollAmount;
		elem.animate({scrollTop: targetOffset}, scrollSpeed);		
	});

	$( "#trustee-list li" ).bind("mouseenter",function(){
		$( this ).find( '.trustee-info-window' ).show().animate({
			marginTop: '120',
			opacity: 1
		}, 200 );

	}).bind("mouseleave", function(){
		$( this ).find( '.trustee-info-window' ).hide();
		$( this ).find( '.trustee-info-window' ).css( "marginTop", "110px" );

	});

	// for phones / touch screens
	$( "#trustee-list li" ).bind("click",function(){
		console.log(  $( this ).find( '.info-window' ).is( ":hidden" ) );
		if( $( this ).find( '.trustee-info-window' ).is( ":hidden" ) ) {
			$( this ).find( '.trustee-info-window' ).show().animate({
				marginTop: '120',
				opacity: 1
			}, 200 );
		} else {
			$( this ).find( '.trustee-info-window' ).show().animate({
				marginTop: '110',
				opacity: 0
			}, 200 ).hide();
		}
	});

	$("a.fancybox").fancybox({
		'titlePosition'	: 'over',
		'overlayOpacity' : 0.6
	});
});
