var side = true;
var out = true;
var scrol = true;
var inb = true;
var obj;
var descr, h, num, max, gallery_width;
var ff = false;
  
function scroll() {
	if (out && scrol) {
		if (side) {
			obj.scrollLeft += 1;
		} else {
			obj.scrollLeft -= 1;
		}
		$("#staff_about").css("display", "none");
		
		max = width - gallery_width;
		if (obj.scrollLeft >= max)
			side=false;
		if (obj.scrollLeft <= 0)
			side = true;
	}
}

function shown() {
	$("#staff_about").children("img.flag").attr("src", $(t).children("img.flag").attr("src") );
	$("#staff_about").children("span.country").html( '('+$(t).children("span.country").html()+')' );
	$("#staff_about").children("span.name").html( $(t).children("span.name").html() );
	$("#staff_about").children("span.type").html( $(t).children("span.type").html() );

	l = 0;
	var o = $("#inner-gallery > ul").children("li").children("a");
	for (i = 0; i < o.length; i++) {
		if (t == o[i])
			l = i * 60;
	}
	l = l - obj.scrollLeft + 5;
	val = new String(l + "px");
	$("#staff_about").css("left", val);
	$("#staff_about").show(500);
	out = false;
}
  
$(document).ready(function(){
	obj = $("#gallery").get(0);
	h = obj;
	jQuery.each(jQuery.browser, function(i, val) {
		if($.browser.mozilla || $.browser.safari)
			ff = true;
	});

	num = 58; // количество участников оркестра
	width = num * 60;

	gallery_width = parseInt($("#gallery").css("width"));
	$("#inner-gallery").css("width", width + 50);

	var timer = setInterval("scroll();",5);
	$("#staff").mouseenter(function(){out=false;});
	$("#staff").mouseleave(function(){out=true;});

	$(".unit").mouseenter(function(){
		t = this;
		if (!ff)
			shown();
		else
			setTimeout("shown()",1);
	});
	  
	$(".unit").mouseleave(function(){
		$("#staff_about").css("display", "none");
	});
});
