
var t;
var inscroll;
inscroll = false

function slide(source){
	if(!inscroll){
		inscroll = true;
		
	//clearTimeout(t);
	var move = "-=" + move_amount + "px";
	
	if ($("#main_cluster_scroll").css("left") == (-(slide_count * move_amount) + "px")) move="0px";
	$("#main_cluster_scroll").animate({"left": move}, "slow",  function() {
 	inscroll = false;});
		
	if(source == "auto"){
	t=setTimeout('slide("auto")', time);
	}
	
		
	}
}

function reverse_slide(source){
	if(!inscroll){
		inscroll = true;
	//clearTimeout(t);
	move =  "+=" + move_amount + "px";
	if ($("#main_cluster_scroll").css("left") == "0px") move = -(slide_count * move_amount) + "px" ;
     $("#main_cluster_scroll").animate({"left": move}, "slow",  function() {
 	inscroll = false;});
	 if(source == "auto"){
	 	t=setTimeout('slide("auto")', time);
	 }
	}
}

function init() {
	$(".cluster_control_right").attr("onclick", "call_slide('right');");
	$(".cluster_control_left").attr("onclick", "call_slide('left');");
	$("#home_main_cluster").bind("mouseenter", function(event){
but_show();
});
	$("#home_main_cluster").bind("mouseleave", function(event){
but_hide();
});
	//$("#home_main_cluster div").attr("onmouseover", "but_show();");
	//$("#home_main_cluster div").attr("onmouseout", "but_hide();");

	t=setTimeout('slide("auto")', time);
}

function but_show(){
	clearTimeout(t);
	$(".cluster_control_right").fadeIn("fast");
	$(".cluster_control_left").fadeIn("fast");
}

function but_hide(){
	t=setTimeout('slide("auto")', time);
	$(".cluster_control_right").fadeOut("fast");
	$(".cluster_control_left").fadeOut("fast");
}

function call_slide(dirc){
	if (!inscroll){
		if(dirc == "right"){
			slide("mouse");
		}else{
			reverse_slide("mouse");
		}
	}
}
