var curQASet = new Array("","");
var sCatName = '';
var oQuestionWindow = null;

//global class and objects
//Category class - to have its own set of questions and answers and a read flag to mark each pair of read question/answer
function oCategory(){
	this.questions = new Array("","","","","","","","");
	this.answers = new Array("","","","","","","","");
	this.read = new Array(false,false,false,false,false,false,false,false);
}

//Category 1: object derived from class 'oCategory'
var oCat_1 = new oCategory();
oCat_1.questions = new Array("The wine area of Cote de Nuits makes both red and white wine. But which one has made them famous?",
							 "Is Wien (Vienna) a wine reqion in Switzerland?",
							 "Is Chablis a wine reqion or a wine district?",
							 "Do you find AC Pomerol in Spain?",
							 "Do you find AC Sauternes in Bordeaux or in Burgundy?",
							 "At what latitudes are vines grown around the globe - in between 15 and 40, 30 and 50 or 20 and 60 degrees?",
							 "In what state can you find the Sub-appellations of Alder Ridge, Canoe Ridge, Zephyr Ridge and Cold Creek?",
							 "Does Colombia have a wine region called Sierra Nevada de Santa Maria?");
oCat_1.answers = new Array("Their exclusive white wines.",
						   "No, it's a wine region in Austria.",
						   "A wine district within the wine reqion of Burgundy.",
						   "No, it's in Bordeaux, France.",
						   "In Bordeaux.",
						   "In between 30 and 50, 15 degree is too cold, and 60 is too hot for vines",
						   "In Washington State, USA.",
						   "Yes.");

//Category 2: object derived from class 'oCategory'
var oCat_2 = new oCategory();
oCat_2.questions = new Array("In 1900, Georges de Latour fonded this winery in Napa Valley, What is it called?",
							 "Is the founder of the estate of Louis M. Martini situated in Napa Valley, related to the famous vermouth family, Martini?",
							 "Was it the Tuscan family form of Antinori that launched the wine Tignanello?",
							 "In 1895, the Seghesio Family planted their first Zinfandel vineyard in Sonoma County at Alexander Valley. Today the Seghesio vineyard is a collection of 400 acres of superior vineyard sites acquired over the past century. Is it still family owned by the Seghesio Family?",
							 "A small Spanish district producing highly concentrated wines of Garnacha and Carinena is taking the world by storm. Name the district and the region!",
							 "Who founded E & J Gallo Winery?",
							 "In what year was Chateau Mouton-Rothschild promoted from Second to First Growth (Premier Cru)?",
							 "What champagne house has named a champagne after a British prime minister?");
oCat_2.answers = new Array("Beaulieu Vineyards, or BV for short.",
						   "No, but the estate was founded by an Italiam immigrant in 1922.",
						   "Yes",
						   "Yes",
						   "Priorat DO in Catalonia.",
						   "The brothers Ernest and Julio Gallo.",
						   "In 1973 (June 21st).",
						   "Pol Roger, after Winston Churchill.");

//Category 3: object derived from class 'oCategory'
var oCat_3 = new oCategory();
oCat_3.questions = new Array("From what country did the founder of the Sherry bodega Pedro Domecq come?",
							 "Is Tawny a light red or brick red Port?",
							 "Does botrytis means that a wine is fortified?",
							 "In a Sherry bodega you may find the letters 'Ve' chalked on a cask. What does it mean? ",
							 "What type of fortified wine is fermented dry and then infused with herbs, spices and possibly sweetness?",
							 "How soon must a Port be bottled after having been declared as a Vintage Port?",
							 "What Port house pictures uncle Don on the label?",
							 "Is Riccadonna a dry or a sweet vermouth?");
oCat_3.answers = new Array("From Ireland and his name was Patrick Murphy.",
						   "Brick Red.",
						   "No, it means that the wine is made from noble rotted grapes. Famous examples are Sauternes and Trockenbeerenauslese.",
						   "Vinegar - and it must immediately be discarded.",
						   "Vermouth",
						   "Within 2-3 years",
						   "Sandeman",
						   "Sweet");

//Category 4: object derived from class 'oCategory'
var oCat_4 = new oCategory();
oCat_4.questions = new Array("Name the most important grapes in the French appellations of Graves, Cerons and Barsac. (1 for amateurs, 2 for professionals and 3 for connoisseurs.)",
								"What year was the first varietal-labeled Chardonnay out for sale in USA?",
								"What grape is nicknamed Zin?",
								"The Barolo, Barbaresco and Gattinara wines are all made from one grape variety. Which?",
								"Where is the grape Petit Verdot grown?",
								"What grape - along with Rondinella, Molinara and sometimes Negrara - is the most important component of the wines of Valpolicella, Italy?",
								"What Grapes are permitted for the Grand Cru wines of Alsace, France? Name one!",
								"The Durif grape has a Californian synonym. Which?");
oCat_4.answers = new Array("Cabernet Sauvignon, Cabernet Franc, Merlot, Semillon, Sauvignon Blanc.",
						   "In 1936 - a Pinot Chardonnay from Ernest Wente in Livermore, California, USA.",
						   "Zinfandel.",
						   "Nebbiolo.",
						   "In California, USA, the Medoc, France and Chile.",
						   "Corvina.",
						   "Riesling, Muscat, Gewurztraminer and Pinot Gris (also labelled Tokay-Pinot Gris).",
						   "Petite Syrah.");

//Category 5: object derived from class 'oCategory'
var oCat_5 = new oCategory();
oCat_5.questions = new Array("How does James Bond prefer his Dry Martini?",
							 "Where is Smirnoff (red label) vodka made - in Russia or England?",
							 "In what American bourbon based long drink is whole sprigs of mint or crushed mint a crucial element?",
							 "What do the three letters D.O.M. stands for in Benedictine D.O.M.",
							 "Which is the most peaty/smoky whisky - Irish or Scotch?",
							 "What are the main spirit ingredients in the drink Alexander?",
							 "Is the production of tequila restricted to the Mexican town of Tequila?",
							 "What drink do you get if you add Galliano to a Screwdriver?");
oCat_5.answers = new Array("'Shaken, not stirred.'",
						   "In England",
						   "Mint Julep.",
						   "Deo Optimo Maximo.",
						   "Scotch",
						   "Equal parts of cognac and creme de cacao liqueur.",
						   "No, it may be made anywhere within the state of Jalisco (and in certain villages in the state of Nayarit, Michoacan, Guanajuato and Tamaulipas).",
						   "Harvey Wallbanger");

//Category 6: object derived from class 'oCategory'
var oCat_6 = new oCategory();
oCat_6.questions = new Array("What does residual sugar mean?",
							 "What is aroma?",
							 "Is a vintner a wine merchant or a person who grows grapes?",
							 "What is varietal wine?",
							 "What is balling and brix (USA)?",
							 "What is Appellation d'Origine Controlee?",
							 "In Australia <i>Chablis</i> has a special meaning. Is it a term for late harvested Chardonnay grapes?",
							 "What is a spritzer?");
oCat_6.answers = new Array("The natural grape sugar left in a wine after fermentation, measured in percent or grams.",
						   "The particular smell of the grape used in a wine, giving it its varietal character.",
						   "Both.",
						   "A wine made from, and named after, the dominant grape variety used (minimum 75%).",
						   "Two systems for measuring the sugar contents of grapes or must, indicating the potential alcohol by volume.",
						   "French legal designation, guaranteeing a wine's origin and production methods. Abbreviated os AOC or AC.",
						   "No, it is a term for early harvested Chardonnay grapes.",
						   "It's a common name for a mixture of white wine and fizzy water that is usually drunk as an aperitif.");

//Category 7: object derived from class 'oCategory'
var oCat_7 = new oCategory();
oCat_7.questions = new Array("Chance:","Chance:","Chance:","Chance:","Chance:","Chance:","Chance:","Chance:","Chance:");
oCat_7.answers = new Array("The newly elected president/prime minister/ governor in your country/state has proclaimed prohibition. Immediately return all your category cards.",
						   "Ms. Amoah must return her grape card or skip one turn.",
						   "You are unable to sell your wine because all your customer have cash flow problems. Immediately return one chateau/producer card.",
						   "Choose an optional category card.",
						   "Ms. Amoah may go three steps forward.",
						   "Bootleggers are at work again! Immediately return your spirits card.",
						   "This card gives you one opportunity to invalidate a chance card, which is to the advantage of one of your opponents.",
						   "The Enchanter has given your wines a favorable review. Pick up a grape card.");
/* -------------------------------- GLOBALS */

/* generate random question answers and display in popup window */
function popQuestion(srcCategory){
	var curQASetIndex = 0;
	sCatName = 'oCat_' + srcCategory.split('_')[1];
	var bNotRead = true;
	
	for(var forIndex=0;forIndex < 8;forIndex++)
		if(eval(sCatName + '.read')[forIndex] == false)
			break;

	if(forIndex < 8){
		do{
			curQASetIndex = getRandom();
			
			if(eval(sCatName + '.read')[curQASetIndex] != true){
				eval(sCatName + '.read')[curQASetIndex] = true;
				bNotRead = false;
			}
		}while(bNotRead == true)
	
		curQASet = new Array(eval(sCatName + '.questions[' + curQASetIndex + ']'),eval(sCatName + '.answers[' + curQASetIndex + ']'));
		oQuestionWindow = window.open('game_ans.htm','queWindow','width=675,height=225,scrollbar=no,status=yes,toolbar=no,top=0,left=162');
	}else
		oQuestionWindow = window.open('game_lastans.htm','queWindow','width=675,height=205,scrollbar=no,status=yes,toolbar=no,top=0,left=162');

	oQuestionWindow.focus();
}

function getRandom(){
	return Math.round((Math.random()*100)%7);
}