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>The sums of the external forces and of the external torques on a rigid body are zero.</p> \
<p><img src='../../_images/_flashcards/_ch_14/equation_14_1.png' alt='Flashcard Image' /></p> \
","\
<p><strong>STATIC EQUILIBRIUM</strong></p> \
");

CreateFlashcard("\
<p>Gravity effectively acts at the center of mass.</p> \
","\
<p><strong>TORQUE DUE TO GRAVITY</strong></p> \
");

CreateFlashcard("\
<p>To eliminate an unknown force, evaluate torques about the point where that force acts (or about another point where the force has zero moment arm).</p> \
","\
<p><strong>STATICS CALCULATION TECHNIQUE</strong></p> \
");

CreateFlashcard("\
<p>An arrangement of several pulleys that provides a mechanical advantage (equal to the ratio of the distance moved where the force is applied to the distance moved by the load).</p> \
","\
<p><strong>BLOCK AND TACKLE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_14/equation_14_15.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MECHANICAL ADVANTAGE OF LEVER</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_14/equation_14_21.png' alt='Flashcard Image' /></p> \
","\
<p><strong>PRESSURE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_14/equation_14_18.png' alt='Flashcard Image' /></p> \
","\
<p><strong>DEFORMATIONS OF ELASTIC MATERIAL</strong></p> \
");

SetFlashcardsTotalNumber();