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_33/equation_33_4.png' alt='Flashcard Image' /></p> \
","\
<p><strong>GAUSS&#8217; LAW</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_5.png' alt='Flashcard Image' /></p> \
","\
<p><strong>GAUSS&#8217; LAW FOR MAGNETISM</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_6.png' alt='Flashcard Image' /></p> \
","\
<p><strong>FARADAY&#8217;S LAW</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_7.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MAXWELL-AMP&#200;RE&#8217;S LAW</strong></p> \
");

CreateFlashcard("\
<p>For axial, cylindrically symmetric electric flux</p> \
<p><img src='../../_images/_flashcards/_ch_33/equation_33_4c.png' alt='Flashcard Image' /></p> \
","\
<p><strong>INDUCED MAGNETIC FIELD</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_8.png' alt='Flashcard Image' /></p> \
","\
<p><strong>SPEED OF ELECTROMAGNETIC WAVE</strong></p> \
");

CreateFlashcard("\
<p>Distance for one wave oscillation.</p> \
","\
<p><strong>WAVELENGTH &#955;</strong></p> \
");

CreateFlashcard("\
<p>Number of wave oscillations per second.</p> \
","\
<p><strong>FREQUENCY <i>f</i></strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_10.png' alt='Flashcard Image' /></p> \
","\
<p><strong>WAVELENGTH/FREQUENCY SPEED RELATION</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_12.png' alt='Flashcard Image' /></p> \
","\
<p><strong>MAGNETIC FIELD OF WAVE</strong></p> \
");

CreateFlashcard("\
<p>For an unpolarized incident intensity <i>I<sub>0</sub></i></p> \
<p><img src='../../_images/_flashcards/_ch_33/equation_33_15a.png' alt='Flashcard Image' /></p> \
<p>for a polarized incident intensity <i>I<sub>0</sub></i> (Malus&#8217; Law)</p> \
<p><img src='../../_images/_flashcards/_ch_33/equation_33_15b.png' alt='Flashcard Image' /></p> \
","\
<p><strong>TRANSMITTED INTENSITY THROUGH A POLARIZER</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_17.png' alt='Flashcard Image' /></p> \
","\
<p><strong>ENERGY DENSITY IN ELECTROMAGNETIC WAVE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_24.png' alt='Flashcard Image' /></p> \
","\
<p><strong>TIME-AVERAGE ENERGY FLUX (INTENSITY) IN A PLANE WAVE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_23.png' alt='Flashcard Image' /></p> \
","\
<p><strong>POYNTING VECTOR S (propagation direction)</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_26.png' alt='Flashcard Image' /></p> \
","\
<p><strong>ENERGY FLUX <i>S</i> IN TERMS OF POWER <i>P</i> FOR SPHERICAL WAVE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_27.png' alt='Flashcard Image' /></p> \
","\
<p><strong>PRESSURE OF ELECTROMAGNETIC WAVE</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_33.png' alt='Flashcard Image' /></p> \
","\
<p><strong>WAVE EQUATION</strong></p> \
");

CreateFlashcard("\
<p><img src='../../_images/_flashcards/_ch_33/equation_33_34.png' alt='Flashcard Image' /></p> \
","\
<p><strong>HARMONIC TRAVELING WAVE SOLUTIONS OF THE WAVE EQUATION</strong></p> \
");

SetFlashcardsTotalNumber();