$(document).ready(readyHome);

var current_photo = 0;
var arr_photo_buttons = Array("#image_slider_btn_1", "#image_slider_btn_2", "#image_slider_btn_3", "#image_slider_btn_4");
var timer;

function readyHome() {	
	$(".image_slider_btn").click(setPhotoTo);
	startTimer();
}
function startTimer() {
	clearTimeout(timer);
	timer = setTimeout(ticker, 6000);
}
function stopTimer() {
	clearTimeout(timer);
}
function ticker() {
	startTimer();
	current_photo++;
	if(current_photo > 3) current_photo = 0;
	transitionThePhoto();
}
function setPhotoTo() {
	var num = $(this).attr("id");
	num = num.replace("image_slider_btn_","");
	num = num-1;
	clearTimeout(timer);
	//timer = setTimeout(ticker, 6000);
	current_photo = num;
	transitionThePhoto();
	$('.image_slider_timer').remove();
}
function transitionThePhoto() {
	$("#image_slider_photos").animate({ top:0-(current_photo*368)+"px" });
	for(i = 0; i < 4; i++) {
		if(i == current_photo) {
			$(arr_photo_buttons[i]).addClass("image_slider_current");
		} else {
			$(arr_photo_buttons[i]).removeClass("image_slider_current");
		}
	}
}
