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>A flat, rotating disk of gas and dust surrounding a condensed mass, such as a young stellar object, a forming planet, or a collapsed star in a binary pair.</p> \
","\
<p><strong>accretion disk</strong></p> \
");

CreateFlashcard("\
<p>A He<sup>4</sup> nucleus consisting of two protons and two neutrons. </p> \
","\
<p><strong>alpha particle</strong></p> \
");

CreateFlashcard("\
<p>In the H-R diagram, a separate ''branch'' that goes from the horizontal branch toward higher luminosities and lower temperatures.</p> \
","\
<p><strong>asymptotic giant branch (AGB)</strong></p> \
");

CreateFlashcard("\
<p>The upper limit on the mass of an object supported by electron degeneracy pressure&#151;approximately 1.4 <i>M</i><img src=\"../../_images/symbol_sun.png\" alt=\"Sun Symbol\" \>.</p> \
","\
<p><strong>Chandrasekhar limit</strong></p> \
");

CreateFlashcard("\
<p>Describes the state of material compressed to the point where electron density reaches the limit imposed by the rules of quantum mechanics.</p> \
","\
<p><strong>electron degenerate</strong></p> \
");

CreateFlashcard("\
<p>The runaway explosive burning of helium in the degenerate helium core of a <i>red giant</i> star.</p> \
","\
<p><strong>helium flash</strong></p> \
");

CreateFlashcard("\
<p>A region on the H-R diagram defined by stars burning helium to carbon in a stable core.</p> \
","\
<p><strong>horizontal branch</strong></p> \
");

CreateFlashcard("\
<p>Fusion of hydrogen in a shell surrounding a stellar core that may be either degenerate or fusing more massive elements.</p> \
","\
<p><strong>hydrogen shell burning</strong></p> \
");

CreateFlashcard("\
<p>A star with a main sequence mass of less than about 3 <i>M</i><img src=\"../../_images/symbol_sun.png\" alt=\"Sun Symbol\" \>.</p> \
","\
<p><strong>low-mass star</strong></p> \
");

CreateFlashcard("\
<p>The amount of time a star spends on the main sequence, fusing hydrogen into helium in its core.</p> \
","\
<p><strong>main sequence lifetime</strong></p> \
");

CreateFlashcard("\
<p>The transfer of mass from one member of a binary star system to its companion. Occurs when one of the stars evolves to the point that it overfills its <i>Roche lobe</i>, so that its outer layers are pulled toward its binary companion.</p> \
","\
<p><strong>mass transfer</strong></p> \
");

CreateFlashcard("\
<p>A stellar explosion that results from runaway <i>nuclear fusion</i> in a layer of material on the surface of a white dwarf in a binary system.</p> \
","\
<p><strong>nova</strong></p> \
");

CreateFlashcard("\
<p>The expanding shell of material ejected by a dying AGB star.</p> \
","\
<p><strong>planetary nebula</strong></p> \
");

CreateFlashcard("\
<p>A region on the H-R diagram defined by low-mass stars evolving from the main sequence toward the <i>horizontal branch</i>.</p> \
","\
<p><strong>red giant branch</strong></p> \
");

CreateFlashcard("\
<p>The hourglass or figure eight&ndash;shaped volume of space surrounding two stars, which constrains material that is gravitationally bound by one or the other.</p> \
","\
<p><strong>Roche lobe</strong></p> \
");

CreateFlashcard("\
<p>The loss of mass from the outermost parts of a star's atmosphere during the course of its evolution.</p> \
","\
<p><strong>stellar mass loss</strong></p> \
");

CreateFlashcard("\
<p>A giant star smaller and lower in luminosity than normal giant stars of the same spectral type. </p> \
","\
<p><strong>subgiant</strong></p> \
");

CreateFlashcard("\
<p>A region of the H-R diagram defined by stars that have left the main sequence but have not yet reached the <i>red giant branch</i>.</p> \
","\
<p><strong>subgiant branch</strong></p> \
");

CreateFlashcard("\
<p>The nuclear fusion reaction that combines three helium nuclei, or ''alpha particles,'' together into a single nucleus of carbon. </p> \
","\
<p><strong>triple-alpha process</strong></p> \
");

CreateFlashcard("\
<p>A supernova explosion in which no trace of hydrogen is seen in the ejected material. Most supernovae of this type are thought to be the result of runaway carbon burning in a white dwarf star onto which material is being deposited by a binary companion.</p> \
","\
<p><strong>Type I supernova</strong></p> \
");

CreateFlashcard("\
<p>The stellar remnant left at the end of the evolution of a low-mass star. It typically has a mass of 0.6 <i>M</i><img src=\"../../_images/symbol_sun.png\" alt=\"Sun Symbol\" \>, and a radius about that of Earth: it is made of nonburning, electron degenerate carbon.</p> \
","\
<p><strong>white dwarf</strong></p> \
");

SetFlashcardsTotalNumber();