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>Electro-optical systems that largely compensate for image distortion caused by Earth's atmosphere.</p> \
","\
<p><strong>adaptive optics</strong></p> \
");

CreateFlashcard("\
<p>The clear diameter of a telescope's objective lens or primary mirror.</p> \
","\
<p><strong>aperture</strong></p> \
");

CreateFlashcard("\
<p>A measurement of the degree to which Earth's atmosphere degrades the resolution of a telescope's view of astronomical objects.</p> \
","\
<p><strong>astronomical seeing</strong></p> \
");

CreateFlashcard("\
<p>A region of the electromagnetic spectrum in which radiation is able to penetrate a planet's atmosphere.</p> \
","\
<p><strong>atmospheric window</strong></p> \
");

CreateFlashcard("\
<p>A common type of solid-state detector of electromagnetic radiation that transforms the intensity of light directly into electric signals.</p> \
","\
<p><strong>charge-coupled device (CCD)</strong></p> \
");

CreateFlashcard("\
<p>A state in which the amplitudes of two intersecting waves reinforce one another.</p> \
","\
<p><strong>constructive interference</strong></p> \
");

CreateFlashcard("\
<p>A state in which the amplitudes of two intersecting waves cancel one another. </p> \
","\
<p><strong>destructive interference</strong></p> \
");

CreateFlashcard("\
<p>The spreading of a wave after it passes through an opening or past the edge of an object.</p> \
","\
<p><strong>diffraction</strong></p> \
");

CreateFlashcard("\
<p>The limit of a telescope's angular resolution caused by diffraction.</p> \
","\
<p><strong>diffraction limit</strong></p> \
");

CreateFlashcard("\
<p>The separation of rays of light into their component wavelengths.</p> \
","\
<p><strong>dispersion</strong></p> \
");

CreateFlashcard("\
<p>A spacecraft that first approaches and then continues on past a planet or moon. </p> \
","\
<p><strong>flyby</strong></p> \
");

CreateFlashcard("\
<p>The optical distance between a telescope's objective lens or primary mirror and the plane (called the focal plane) on which the light from a distant object is focused.</p> \
","\
<p><strong>focal length</strong></p> \
");

CreateFlashcard("\
<p>A <i>diffraction</i>  grating. An optical surface containing many narrow, closely and equally spaced parallel grooves or slits that create <i>dispersion</i>  of reflected or transmitted light.</p> \
","\
<p><strong>grating</strong></p> \
");

CreateFlashcard("\
<p>The time interval over which photons are collected and added up in a detecting device.</p> \
","\
<p><strong>integration time</strong></p> \
");

CreateFlashcard("\
<p>The interaction of two sets of waves producing high and low intensity, depending on whether their amplitudes reinforce or cancel. </p> \
","\
<p><strong>interference</strong></p> \
");

CreateFlashcard("\
<p>A group or array of separate but linked optical or radio telescopes whose overall separation determines the angular resolution of the system.</p> \
","\
<p><strong>interferometer</strong></p> \
");

CreateFlashcard("\
<p>The basic unit of flux density. Units: W/m<sup>2</sup>/Hz.</p> \
","\
<p><strong>jansky</strong></p> \
");

CreateFlashcard("\
<p>An instrumented spacecraft designed to land on a planet or moon. </p> \
","\
<p><strong>lander</strong></p> \
");

CreateFlashcard("\
<p>A spacecraft placed in orbit around a planet or moon. </p> \
","\
<p><strong>orbiter</strong></p> \
");

CreateFlashcard("\
<p>The smallest picture element in a digital image array.</p> \
","\
<p><strong>pixel</strong></p> \
");

CreateFlashcard("\
<p>The principal optical mirror in a reflecting telescope, which determines the telescope's light-gathering power and resolution.</p> \
","\
<p><strong>primary mirror</strong></p> \
");

CreateFlashcard("\
<p>The fraction of photons falling on a detector that actually produces a response in the detector.</p> \
","\
<p><strong>quantum efficiency</strong></p> \
");

CreateFlashcard("\
<p>An instrument for detecting and measuring radio-frequency emissions from celestial sources.</p> \
","\
<p><strong>radio telescope</strong></p> \
");

CreateFlashcard("\
<p>(a) A beam of electromagnetic radiation. (b) A bright streak emanating from a young impact crater.</p> \
","\
<p><strong>ray</strong></p> \
");

CreateFlashcard("\
<p>A telescope that uses mirrors for collecting and focusing incoming electromagnetic radiation to form an image in their focal planes. </p> \
","\
<p><strong>reflecting telescope</strong></p> \
");

CreateFlashcard("\
<p>The redirection of a beam of light incident on the surface between two media having different refractive indices. </p> \
","\
<p><strong>reflection</strong></p> \
");

CreateFlashcard("\
<p>A telescope that uses objective lenses to collect and focus light.</p> \
","\
<p><strong>refracting telescope</strong></p> \
");

CreateFlashcard("\
<p>The ability of a telescope to separate two point sources of light. </p> \
","\
<p><strong>resolution</strong></p> \
");

CreateFlashcard("\
<p>A remotely controlled instrumented vehicle designed to traverse and explore the surface of a terrestrial planet or moon. </p> \
","\
<p><strong>rover</strong></p> \
");

CreateFlashcard("\
<p>A small mirror placed on the optical axis of a reflecting telescope that returns the beam back through a small hole in the primary mirror, thereby shortening the mechanical length of the telescope.</p> \
","\
<p><strong>secondary mirror</strong></p> \
");

CreateFlashcard("\
<p>A device that spreads out the light from an object into its component wavelengths.</p> \
","\
<p><strong>spectrograph</strong></p> \
");

CreateFlashcard("\
<p>The amount of electromagnetic radiation emitted or reflected per unit area.</p> \
","\
<p><strong>surface brightness</strong></p> \
");

CreateFlashcard("\
<p>The imaginary surface of an electromagnetic wave, either plane or spherical, oriented perpendicular to the direction of travel.</p> \
","\
<p><strong>wave front</strong></p> \
");

SetFlashcardsTotalNumber();