var img_idx	=	0;
var img_arr	=	new Array();

function next() {
	setIndex(img_idx + 1);
	updateImage();
	updateControls();
}

function back() {
	setIndex(img_idx - 1);
	updateImage();
	updateControls();
}

function setIndex(value) {
	if(img_arr.length-1 < value)	img_idx	=	img_arr.length-1;
	else if(value < 0)				img_idx	=	0;
	else							img_idx	=	value;
}

function updateImage() {
	var img	=	document.getElementById("cs_image");
	img.src	=	img_arr[img_idx];
}

function init_casestudy() {
	updateControls();
}

function updateControls() {
	var next_btn	=	document.getElementById("cs_next");
	var back_btn	=	document.getElementById("cs_back");
	
	if(img_arr.length < 2) {
		next_btn.className="hide";
		back_btn.className="hide";
	} else if(img_idx == 0) {
		next_btn.className="inherit";
		back_btn.className="hide";
	} else if(img_idx == img_arr.length-1) {
		next_btn.className="hide";
		back_btn.className="inherit";
	} else {
		next_btn.className="inherit";
		back_btn.className="inherit";
	}
}