var fl_rotatorInterval = false;
var fl_rotatorPos = 0;
jQuery(document).ready(function(){
	
	jQuery('#photoSlider .linksBox a').each(function(i,obj){
		
		jQuery(obj).click(function(){
			var id = jQuery(this).attr('elemid');
			fl_activateElement(id, true)
			return false;
		})
	})
	
	window.fl_rotatorInterval = setInterval( fl_rotatorNext, 9000 ); /*3000*/
});

function fl_rotatorNext()
{
    try 
    {
	window.fl_rotatorPos++;
	var nextElement 	 = window.fl_rotatorPos;
	var elementLength 	 = fl_tems.length - 1 ;
		nextElement 	 = ( nextElement > elementLength )? 0 : nextElement;
	window.fl_rotatorPos = nextElement
	fl_activateElement(fl_tems[nextElement])
    } catch(e) {;}
}

function fl_activateElement(id, isUserClick)
{
	if(isUserClick && window.fl_rotatorInterval)
	{

		clearTimeout(window.fl_rotatorInterval)
	}
	jQuery("#photoSlider .linksBox li a[class='active']").removeClass('active')
	jQuery("#fl_link"+id).addClass('active');
	
	jQuery("#photoSlider .anonsBox div:visible").hide();
	jQuery("#fl_anons"+id).show();
	
	// jQuery("#photoSlider .imageBox img:visible").hide()
	// 	jQuery("#fl_pic"+id).show();
	
	jQuery("#photoSlider .imageBox img:visible").fadeOut('fast')
	jQuery("#fl_pic"+id).fadeIn('fast');
	
	
}