var pos_left = 0;
var active_dot_id = 1;
var img_src_act = "modules/home/frontend/byblos/images/slider/dot_active.png";
var img_src_nrm = "modules/home/frontend/byblos/images/slider/dot.png";
		
function slider(new_dot_id){
	
	if(new_dot_id)
	{
		clearTimeout(timeout);
		new_dot_id = new_dot_id.charAt(3);
		var left_position =  0 - (new_dot_id)*332 + 332;
		$(".slider").stop(true, false).animate({"left": left_position}, 1400);

		$(".dot").each(function(){
								$(this).attr("src", img_src_nrm);
								});
		$("#dot" + new_dot_id).attr("src", img_src_act);
		
		timeout = setTimeout(function(){
						slider();
					}, 5000);
	}
	else
	{
		var pos = $('.slider').position();
		if(pos.left <= -950)
		{
			pos_left=0;
			active_dot_id = 1;
			last_dot_id = 4;
		}
		else
		{
			pos_left -= 332;
			last_dot_id = active_dot_id;
			active_dot_id += 1;
		}
		
		$(".slider").animate({"left": pos_left}, 1400);
		
		$(".dot").each(function(){
								$(this).attr("src", img_src_nrm);
								});
		$("#dot" + active_dot_id).attr("src", img_src_act);
		
		timeout = setTimeout(function(){
						slider();
					}, 5000);
	}
}