var arrFlashcards = new Array(); //this is the master array
var arrFlashcardsDisplayOrder = new Array();
var currFlashcard = -1; //index of the arrFlashcardsDisplayOrder array
var viewFirst; //0: Definition, 1: Term

function CreateFlashcard(definitionHTML, termHTML) {
	arrFlashcards[arrFlashcards.length] = Array(definitionHTML, termHTML)
}

function SetFlashcardsTotalNumber() {
	document.getElementById("TotalFlashcards").innerHTML = arrFlashcards.length;
}

function DisplayFlashcard(FlashcardIndex) {
	displayBtnNavigator();
	document.getElementById("innercardContentTop").innerHTML = arrFlashcards[arrFlashcardsDisplayOrder[FlashcardIndex]][0];
	document.getElementById("innercardContentMiddle").innerHTML = arrFlashcards[arrFlashcardsDisplayOrder[FlashcardIndex]][1];
	showhideTab(viewFirst);
	myAccordion.showThisHideOpen(viewFirst);
}

function hideBtnNavigator() {
	document.getElementById("tb_leftColumn").className = "hide";
	document.getElementById("tb_rightColumn").className = "hide";
}

function displayBtnNavigator() {
	if(currFlashcard!=-1) {
		document.getElementById("tb_leftColumn").className = (currFlashcard==0)?"hide":"show";
		document.getElementById("tb_rightColumn").className = (currFlashcard==arrFlashcards.length-1)?"hide":"show";
	}
}

function showhideTab(flag) {
	document.getElementById("tb_innercardContentTop").style.display = (flag==0)?"":"none";
	document.getElementById("tb_cardContentMiddle").style.display = (flag==0)?"none":"";
}

function showFlashcards() {
	currFlashcard = 0;
	viewFirst = (document.frmFlashcards.viewfirst[0].checked)?0:1;
	genFlashcardsDisplayOrder();
	DisplayFlashcard(currFlashcard);
}

function navigateFlashcards(FStep) {
	currFlashcard += FStep;
	DisplayFlashcard(currFlashcard);
}

function genFlashcardsDisplayOrder() {
	var i;	
	for(i=0;i<arrFlashcards.length;i++) arrFlashcardsDisplayOrder[i]=i;
	if(document.frmFlashcards.randomize[0].checked) randomizeArray(arrFlashcardsDisplayOrder);
}

function randomizeArray(o){
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};


CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_1.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MOMENTUM OF A PARTICLE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_4.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MOMENTUM OF A SYSTEM OF PARTICLES</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_13.png' alt='Flashcard Image' /></p> \
","\
<p><strong>RATE OF CHANGE OF MOMENTUM</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_12.png' alt='Flashcard Image' /></p> \
","\
<p><strong>CONSERVATION OF MOMENTUM</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_18.png' alt='Flashcard Image' /></p> \
","\
<p><strong>CENTER OF MASS</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_25.png' alt='Flashcard Image' /></p> \
","\
<p><strong>CENTER OF MASS OF CONTINUOUS DISTRIBUTION OF MASS</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_37.png' alt='Flashcard Image' /></p> \
","\
<p><strong>VELOCITY OF THE CENTER OF MASS</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_39.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MOMENTUM OF A SYSTEM OF PARTICLES</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_40.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MOTION OF THE CENTER OF MASS</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_33.png' alt='Flashcard Image' /></p> \
","\
<p><strong>GRAVITATIONAL POTENTIAL ENERGY OF A SYSTEM OF PARTICLES</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_10/equation_10_42.png' alt='Flashcard Image' /></p> \
","\
<p><strong>KINETIC ENERGY OF A SYSTEM OF PARTICLES</strong></p> \
");

SetFlashcardsTotalNumber();