var debug;
var pane_width = 0;
var stream_height = 0;
var go_fwd_flag = false;
var m_left_t;
var dbg = 0;


$(document).ready(function(){
	
	pane_width = ($(".person:first-child").outerWidth() + 10) * $(".person").length
	$(".scroll-stream").css({
		width : ($(".person:first-child").outerWidth() + 10) * $(".person").length + "px",
		marginTop: stream_height * -2
	})
	stream_height = $("#scroll-pane").outerHeight();
	$(".scroll-stram").clone().prependTo("#scroll-pane");
	
	$(".controll-button").height(210)
	$(".scroll-stream .person, .scroll-stream .person *").bind('mouseover', function(e){
		$("img", this).fadeTo(1, .5)
	})
	$(".scroll-stream .person ").bind('mouseout', function(){
		$("img",this).fadeTo(1, 1, function(){$(this).css('filter','');})
	})
	$(".fwd-btn").bind('mouseover', function(){
		debug = $(".scroll-stream").css("left")
		setTimeout("goleft()", 25)
	})
	$(".fwd-btn").live('mouseout', function(){
		clearTimeout(m_left_t)
	})
	$(".bck-btn").bind('mouseover', function(){
		//debug = $("#scroll-stream").css("left")
		setTimeout("goright()", 25)
	})
	$(".bck-btn").live('mouseout', function(){
		clearTimeout(m_left_t)
	})
	$(".scroll-stream").bind('mouseover', function(){
		clearTimeout(m_left_t)
	})
	$("#scroll-pane").bind('mouseout', function(){
		clearTimeout(m_left_t)
	})
	$("#scroll-pane").width($("#scroll-pane").parent().width() - 80)
	$(document).bind('resize', function(){
		$("#scroll-pane").width($("#scroll-pane").parent().width() - 80)
	})
})
function goleft()
{
	if($("#scroll-pane").scrollLeft() >= 1640)
	{
		new_man = $(".scroll-stream a:first-child").clone()
		$(".scroll-stream a:first-child").remove()
		//$(".scroll-stream a:last-child").clone().prependTo(".scroll-stream")
		$(".scroll-stream").append(new_man)
		$("#scroll-pane").scrollLeft($("#scroll-pane").scrollLeft() - $(".scroll-stream a:last-child").outerWidth()-12+6)
		m_left_t = setTimeout("goleft()", 1)
	}
	else
	{
		$("#scroll-pane").scrollLeft($("#scroll-pane").scrollLeft() + 6)
		dbg = $("#scroll-pane").scrollLeft();
		m_left_t = setTimeout("goleft()", 20)
	}
}
function goright()
{
	if($("#scroll-pane").scrollLeft() <= 0)
	{
		new_man = $(".scroll-stream a:last-child").clone()
		$(".scroll-stream a:last-child").remove()
		$(".scroll-stream").prepend(new_man)
		$("#scroll-pane").scrollLeft($("#scroll-pane").scrollLeft() + $(".scroll-stream a:first-child").outerWidth())
	}
	else
	{
		$("#scroll-pane").scrollLeft($("#scroll-pane").scrollLeft() - 6)
		
	}
	m_left_t = setTimeout("goright()", 20)
}
