var SHORT_TIME = 8000;
var FULL_TIME = 20000;

var num_types = 3;
var num_trivias = 8;
var num_quotes = 9;
var num_faqs = 8;

var trivia_index;
var previous_type = "";
var font_size_open;
var font_size_close;

var trivia = new Array(num_trivias);
var trivia_answer = new Array(num_trivias);
var quote = new Array(num_quotes);
var faq = new Array(num_faqs);


trivia[0] = "Q: What is the Primary grape varietal used in the great Chiantis of Italy?";
trivia_answer[0] = "A:&nbsp;&nbsp;&nbsp;Sangiovese";
trivia[1] = "Q: What country in Europe is the Burgundy region located?";
trivia_answer[1] = "A:&nbsp;&nbsp;&nbsp;France";
trivia[2] = "Q: Which winery has been in California longer, Buena Vista or Clos Du Bois?";
trivia_answer[2] = "A:&nbsp;&nbsp;&nbsp;Buena Vista";
trivia[3] = "Q: What is the name of the valley where the first vines in California were planted?";
trivia_answer[3] = "A:&nbsp;&nbsp;&nbsp;Santa Clara Valley";
trivia[4] = "Q: What is the indent on the bottom of a bottle of wine called?";
trivia_answer[4] = "A:&nbsp;&nbsp;&nbsp;A punt";
trivia[5] = "Q: What is the grape used to produce Beaujolais-Villages?";
trivia_answer[5] = "A:&nbsp;&nbsp;&nbsp;Gamay";
trivia[6] = "Q: What is the primary grape used to produce Chianti Classico?";
trivia_answer[6] = "A:&nbsp;&nbsp;&nbsp;Sangiovese"; 
trivia[7] = "Q: In what year was the aluminum beer can introduced?";
trivia_answer[7] = "A:&nbsp;&nbsp;&nbsp;1935";


quote[0] = "\"Do not use a hatchet to remove a fly from your friend's forehead.\"";
quote[1] = "\"Wine is the most civilized thing in the world.\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Ernest Hemingway";
quote[2] = "\"My only regret in life is that I did not drink more Champagne.\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- John Maynard Keynes";
quote[3] = "\"In victory, you deserve champagne, in defeat, you need it.\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Napoleon";
quote[4] = "\"Wine is light, held together by water.\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Galileo";
quote[5] = "\"To take wine into your mouth is to savor a droplet of the river of human history.\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Clifton Fadiman";
quote[6] = "\"He was a wise man who invented beer.\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Plato";
quote[7] = "A horse walks into a bar, pulls up a stool, and orders a beer. The bartender asks, \"Why the long face?\"";
quote[8] = "A three legged dog walks into a saloon, looks around, and says, \"I'm looking for the man who shot my paw.\"";


faq[0] = "Did you know that when ordering product you can search for all imported beer from Germany?";
faq[1] = "Did you know that you can review every order you make using the order history tool?";
faq[2] = "Did you know that your order can be delivered as soon as 1 day later?";
faq[3] = "Did you know there is a 1600 year old bottle of wine on display in the Speyer Museum in Germany.";
faq[4] = "Did you know that in the middle ages wine was used as currency.";
faq[5] = "Did you know that the term \'Blanc de Noir\' refers to white wine made from red/black grapes.";
faq[6] = "Did you know that a wine glass should typically be no more than half full to allow room for swirling the wine to release its aroma.";
faq[7] = "Did you know that 7% of the entire Irish barley crop goes to the production of Guinness beer.";



function get_random_number(limit) {
   var number = -1;
   while (number < 0 || number > limit || isNaN(number)) {
      number = parseInt(Math.random()*(limit));
   }
   return number;
}

function show_trivia_answer() {
   parent.frames["quote"].document.open("text/html","replace");
   parent.frames["quote"].document.write("<html><body topmargin=\"0\" marginheight=\"0\" bgcolor=\"#FFFFFF\"><table height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"100%\" valign=\"middle\"><font face=\"Arial\" color=\"blue\">" + font_size_open + "<em>" + trivia_answer[trivia_index] + "</em>" + font_size_close + "</font></td></tr></table></body></html>");
   parent.frames["quote"].document.close();
   setTimeout("start()", SHORT_TIME);
}

function show_trivia() {
   trivia_index = get_random_number(num_trivias);
   parent.frames["quote"].document.open("text/html","replace");
   parent.frames["quote"].document.write("<html><body topmargin=\"0\" marginheight=\"0\" bgcolor=\"#FFFFFF\"><table height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"100%\" valign=\"middle\"><font face=\"Arial\" color=\"blue\">" + font_size_open + "<em>" + trivia[trivia_index] + "</em>" + font_size_close + "</font></td></tr></table></body></html>");
   parent.frames["quote"].document.close();
   setTimeout("show_trivia_answer()", FULL_TIME);
}

function show_quote() {
   var index = get_random_number(num_quotes);
   parent.frames["quote"].document.open("text/html","replace");
   parent.frames["quote"].document.write("<html><body topmargin=\"0\" marginheight=\"0\" bgcolor=\"#FFFFFF\"><table height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"100%\" valign=\"middle\"><font face=\"Arial\" color=\"blue\">" + font_size_open + "<em>" + quote[index] + "</em>" + font_size_close + "</font></td></tr></table></body></html>");
   parent.frames["quote"].document.close();
   setTimeout("start()", FULL_TIME);
}

function show_faq() {
   var index = get_random_number(num_faqs);
   parent.frames["quote"].document.open("text/html","replace");
   parent.frames["quote"].document.write("<html><body topmargin=\"0\" marginheight=\"0\" bgcolor=\"#FFFFFF\"><table height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"100%\" valign=\"middle\"><font face=\"Arial\" color=\"blue\">" + font_size_open + "<em>" + faq[index] + "</em>" + font_size_close + "</font></td></tr></table></body></html>");
   parent.frames["quote"].document.close();
   setTimeout("start()", FULL_TIME);
}

function start() {
   type = get_random_number(num_types);
   while (type == previous_type) {
      type = get_random_number(num_types);
   }
   previous_type = type;
         
   if (type == 0)
      show_trivia();
   else if (type == 1)
      show_quote();
   else if (type == 2)
      show_faq();
}

if (resolution == 640) {
   font_size_open = "<small><small>";
   font_size_close = "</small></small>";
}
else {
   font_size_open = "<small>";
   font_size_close = "</small>";
}
