//  JavaScript Library for TaroTutor

deal = new Array();
female = Math.floor(Math.random()*6);   // let 1 out of 6 querents be male

// querent characteristic databases
var dbQuerAge = new Array();
dbQuerAge[0] = " teenaged";
dbQuerAge[1] = " young";
dbQuerAge[2] = ", early middleaged";
dbQuerAge[3] = ", late middleaged";
dbQuerAge[4] = " elderly";

var dbQuerDress = new Array();
dbQuerDress[0] = "frugally/shabbily";
dbQuerDress[1] = "frugally but neatly";
dbQuerDress[2] = "expensively but sloppily";
dbQuerDress[3] = "expensively and neatly";
dbQuerDress[4] = "in an eccentric manner";
dbQuerDress[5] = "in a flamboyant style";
dbQuerDress[6] = "tastelessly";

var dbQuerMien = new Array();
dbQuerMien[0] = "an aristocratic";
dbQuerMien[1] = "a poorly educated";
dbQuerMien[2] = "an uneducated";
dbQuerMien[3] = "a well educated";
dbQuerMien[4] = "an educated";

var dbQuerEnergy = new Array();
dbQuerEnergy[0] = "a confident";
dbQuerEnergy[1] = "a self-conscious";
dbQuerEnergy[2] = "a shy";
dbQuerEnergy[3] = "an energetic";
dbQuerEnergy[4] = "an enthusiastic";
dbQuerEnergy[5] = "a lethargic";
dbQuerEnergy[6] = "an arrogant";
dbQuerEnergy[7] = "an introspective";
dbQuerEnergy[8] = "a garrulous";
dbQuerEnergy[9] = "a skeptical";

// question database
var dbQuestion = new Array();
dbQuestion[0] = "an item or object of some kind";
dbQuestion[1] = "a place or location, perhaps involving travel";
dbQuestion[2] = "an unborn child";
dbQuestion[3] = "career concerns";
dbQuestion[4] = "a personal relationship";
dbQuestion[5] = "a business relationship";
dbQuestion[6] = "a news or other current affairs topic";
dbQuestion[7] = "a recent disappointment";
dbQuestion[8] = "financial concerns";
dbQuestion[9] = "property-related issues";
dbQuestion[10] = "the death of a loved one";
dbQuestion[11] = "a decision to be made";
dbQuestion[12] = "feelings of depression";
dbQuestion[12] = "an upcoming challenge to be faced";

function choose(db) {
	var x = Math.floor(Math.random()*db.length);
	return db[x];
}

function describeQuerent(question) {
    document.write('<p class="reading">The querent is ' + choose(dbQuerEnergy) + choose(dbQuerAge) + ' ' + (female?"female":"male") + ', dressed ' + choose(dbQuerDress) + ', with ' + choose(dbQuerMien) + ' style of speech. </p>');
    if (question) document.write('<p class="reading">' + (female?"Her":"His") + ' question pertains to ' + choose(dbQuestion) + '.</p><p class="reading">' + (female?"She":"He") + ' is presented with the following:</p>');
    else document.write('<p class="reading">' + (female?"She":"He") + ' arranges the symbols as follows:</p>');
}

function dealCards(type, count, corners, shuffle) {
    var target;
    for (i=0; i<count; i++) deal[i] = 0;
    document.write('<table align="center" cellpadding="10"><tr>');
    for (i=1; i<=3; i++) {
        while (deal[target = Math.floor(Math.random()*count)]);
        if (!shuffle) deal[target] = 1;
        document.write('<td><div id="card"><img src="tutor/' + type + target + '.jpg" width="158" border="' + corners + '" />');
        if (corners) document.write('<div id="card-tl"></div><div id="card-tr"></div><div id="card-bl"></div><div id="card-br"></div>');
        document.write('</div></td>');
    }
    document.write('</tr></table>');
}

window.onload = function checkRefresh() {   // go to "spread" anchor on page refresh
    if (window.location.search=="?refresh") location.href = "#spread";
}


