
function mini_directory()
{
	var width = 0;
	$('.mini_directory').each(function()
	{
		if($(this).hasClass('vertical'))
		{
			return;
		}
		
		$(this).find('.person').each(function()
		{
			var person = $(this);
			
			if(person.position().left > width)
			{
				width = person.position().left + person.width();
			}
		});
		
		$(this).find('.people_overflow').css('width',width);
	});
	
	
	
	
	$('.mini_directory .previous').click(function()
	{
		var dir = $(this).parent('.mini_directory');
		
		if(dir.hasClass('vertical'))
		{
			var change = dir.find('.people').height();
			var top = dir.find('.people_position').scrollTop();
			top -= change;
			
			if(top < 0)
			{
				top = 0;
			}
			
			dir.find('.people_position').animate({scrollTop: top+"px"}, 1000);
		}
		else
		{
			var change = dir.find('.people').width();
			var left = dir.find('.people_position').scrollLeft();
			left -= change;
			
			if( left < 0)
			{
				left = 0;
			}
			
			dir.find('.people_position').animate({scrollLeft: left+"px"}, 1000);
		}
		
	});
	
	$('.mini_directory .next').click(function()
	{
		var dir = $(this).parent('.mini_directory');
		
		
		if(dir.hasClass('vertical'))
		{
			var change = dir.find('.people').height();
			var top = dir.find('.people_position').scrollTop();
			
			
			dir.find('.people_position').animate({scrollTop: top+change+"px"}, 1000);
		}
		else
		{
			var change = dir.find('.people').width();
			var left = dir.find('.people_position').scrollLeft();
			
			
			dir.find('.people_position').animate({scrollLeft: left+change+"px"}, 1000);
		}
		
	});
}

var last_activity = 0;
var ad_refract_minutes = 1;

function delete_entry(id)
{
	TC.call("objects/remove", {id: id}, function(result)
	{
		if(result.ok == true)
		{
			$('#object_'+id).fadeOut();
		}
	});
}

$(document).ready(function()
{

	window.setInterval(function()
	{
		var ts = Math.round((new Date()).getTime() / 1000);
		if(ts - last_activity < (ad_refract_minutes * 60))
		{
			if(typeof console.log != 'undefined')
			{
				console.log("Refreshing iframes.");
			}

			last_activity = 0;
			$('.iframe_ad').each(function()
			{
				$(this).after($(this).clone());
				$(this).remove();
			});
		}
		
	}, (60*ad_refract_minutes) * 1000);
	
	$(document).mousemove(function()
	{
		last_activity = Math.round((new Date()).getTime() / 1000);
	});
	

	mini_directory();
});

$(document).ready(function()
{
	mini_directory();
});

