max_cindex = 5;
max_index = new Array(
	8
	, 20
	, 5
	, 8   
	, 4
	, 5
);
cstr = new Array(
	"2007 淀大会"
	, "2007 七大戦 馬術の部"
	, "2008 大雪の日"
	, "2008 全日本学生"
	, "2008 産大大会"
	, "2009 ７月月例"
);
index = 0;
cindex = 0;

function next() {
	if (index < max_index[cindex]) {
		index++;
	} else {
		cnext();
	}
	write();
}

function prev() {
	if (index > 0) {
		index--;
	} else {
		cprev();
		index = max_index[cindex];
	}
	write();
}

function cnext() {
	if (cindex < max_cindex) {
		cindex++;
		index = 0;
	} else {
		cindex = 0;
		index = 0;
	}
	cchange();
}

function cprev() {
	if (cindex > 0) {
		cindex--;
		index = 0;
	} else {
		cindex = max_cindex;
		index = 0;
	}
	cchange();
}

function change(c, i) {
	cindex = c;
	index = i;
	cchange();
	write();
}

function write() {
	str = 'photo/';
	if (cindex < 10) {
		str = str + '00' + cindex;
	} else if (cindex < 100) {
		str = str + '0' + cindex;
	} else {
		str = str + cindex;
	}
	if (index < 10) {
		str = str + '00' + index;
	} else if (index < 100) {
		str = str + '0' + index;
	} else {
		str = str + index;
	}
	str = str + '.jpg';
	document.images['PHOTO'].src = str;
}

function cwrite() {
	str = ' ';
	for (i=0; i <= max_cindex; i++) {
		str = str
			+ ' <input type="button" '
			+ 'id="'
//			+ cstr[i]
			+ i
			+ '" value="';
		if (i==cindex) {
			str = str
				+ '■'
				+ cstr[i]
				+ '■';
		} else {
			str = str
				+ cstr[i];
		}
		str = str
			+ '" onclick="change('
			+ i
			+ ', 0)" />';
	}
	
	return str;
}

function cchange() {
	for (i=0; i <= max_cindex; i++) {
		if (i==cindex) {
			document.forms['Buttons'].elements[i].value = 
				'■' + cstr[i] + '■';
		} else {
			document.forms['Buttons'].elements[i].value = cstr[i];
		}
	}
}
