$(document).ready(		
	function() {
		startThing();
	}
);

var theCntr = 0;
var totalItems;
var prevBtn_1;
var prevBtn_2;

function startThing() {
	
	totalItems = images.length;	
	
	for (var i=1;i<=totalItems;i++) {
		$("#menu_right").find(".item_"+i).hover(function () {	
			var n = $(this).attr('class');	
			theCntr = Number(n.substring(5))-1
			changeImage(theCntr);
			changeBtn(theCntr);
			clearInterval(showInt);
			startTimer();
		})
	}
	changeImage(0);
	changeBtn(0);
	startTimer ();
}

function changeImage (wO) {	
	$("#window_left").find("img").attr('src',images[wO])	
}

function changeBtn (wO) {
	var id = wO+1;
	$("#menu_right").find(".item_"+id).find('h1').css('color','#EBAE29')
	$("#menu_right").find(".item_"+id).find('h2').css('color','#EBAE29')
	
	if (prevBtn_1) {
		prevBtn_1.css('color','#333333')
		prevBtn_2.css('color','#333333')
	}
	
	prevBtn_1 = $("#menu_right").find(".item_"+id).find('h1');
	prevBtn_2 = $("#menu_right").find(".item_"+id).find('h2');
}



function goNext() {
	theCntr++;
	if (theCntr == totalItems) theCntr = 0;
	
	changeImage(theCntr);
	changeBtn(theCntr);
}

var showInt;
function startTimer () {
	showInt = setInterval (goNext,5000);
}

