var numPages = 0;
var currPageNdx = 0;

function initSets() {
	if (currSet) {$(currSet).toggleClass('select',false);}
	$(nextSet).toggleClass('select',true);
	currSet = nextSet;
}

function changeSetState(elt, state) {
	if (elt.id != $(currSet).attr('id')) {$(elt).toggleClass('select', state);}
	$('#info').text(state ? descArr[elt.id] : '');
}

function initBoxes() {
	var innerHTML = '';
	
	for (i=0; i<numPages; i++) {
		innerHTML += '<a href="" id="sub' + i + '" class="arrC"></a>';
	}

	$('#boxes').html(innerHTML);

	$('#boxes a').each(
		function(ndx) {
			$(this).removeAttr('href').click(function(){showPage(ndx);});
		}
	).slice(0, 1).toggleClass('boxSel', true);
}

function showPage(posn) {
	$('#multipage').find('tr:eq(' + currPageNdx + ')').toggleClass('show', false);
	$('#boxes #sub' + currPageNdx).toggleClass('boxSel', false);
	
	switch(posn) {
		case '-':
			currPageNdx = (currPageNdx == 0) ? numPages-1 : currPageNdx-1;
			break;
		case '+':
			currPageNdx = (currPageNdx == numPages-1) ? 0 : currPageNdx+1;
			break;
		default:
			currPageNdx = posn;
			break;
	}
	
	$('#boxes #sub' + currPageNdx).toggleClass('boxSel', true);
	$('#multipage').find('tr:eq(' + currPageNdx + ')').toggleClass('show', true);	
}

$(document).ready(function () {
	numPages = $('#multipage tr').length;

	$('#menu_about').toggleClass('select', true);

	$('#navSubs a.arrL').removeAttr('href').click(function(){showPage('-');});
	$('#navSubs a.arrR').removeAttr('href').click(function(){showPage('+');});
	
	$('#multipage').find('tr:eq(' + currPageNdx + ')').toggleClass('show', true);
	
	initBoxes();
});