var default_x = "random";

function GetQuote(x) {
//   **************************************************************************
	var Quote = [
 "Activity should be a daily occurrence. Walk, run, bike or swim for a minimum total of 20 minutes a day.",
"Take a multi-vitamin",
"Protect your skin. Sun block should be applied on face, neck, arms and hands. It protects against climatic toxins too. Moisturize skin daily.",
"Eat fruits, vegetables, grains, low-fat dairy products and small amounts of protein. Avoid sweets and other processed foods.",
"Meditate or spend a minimum of five minutes daily in quiet time.",
"Find your spiritual self. Discover what inspires you, raises your level of consciousness, motivates you, and satisfies your soul.",
"Exercise your brain. Read, study, solve problems, and learn new skills. As does the body, the brain atrophies with lack of use.",
"Hug somebody.",
"Try healthier cooking methods - opt for steamed, broiled, baked, roasted, grilled, microwaved or stir-fried.",
"Add herbs and spices instead of sauces and glazes for flavor without fat.",
"Use pureed, cooked vegetables in the place of cream, butter and egg yolks to thicken soups or dressings. In baked goods, substitute pureed fruit for butter, lard or other oils.",
"Cut the amount of sugar that a recipe calls for by at least 25%.",
"Drink seven to eight glasses of water or other fluids per day. This will prevent dehydration and possibly protect against illness. ",
"Identify the best time of day to eat your biggest meal and then make sure you eat foods full of nutrients.",
"Eat with others. You're likely to eat better when a meal is also a social occasion.",
"Find ways to make food tastier. Better tasting food sparks the appetite. You can add herbs and spices, maple syrup, bacon bits and butter flavorings.",
"Try to eat slowly, sit up straight when you eat, and eat small meals frequently. This will cut down on the amount of gas you have.",
"Avoid lying down flat at least one hour after meals. This allows for proper digestion.",
"Include softer foods in your diet, such as cottage cheese, yogurt, casseroles made with ground meat or cheese, canned or very soft fruits.",
"Have regular dental check-ups.",
"Do your house-workout. Treat housecleaning as a chance to exercise, keep track of how much time you spend on your feet. The same goes for raking leaves, pruning hedges, pushing a lawn mower and other yard work.",
"Shop at the 100-yard sale. Park an extra 100 yards from the mall entrance, and take a few laps around the shopping center as you scope out the sales.",
"Laughter is the best medicine! Laughing lowers blood pressure, improves circulation, and lessens pain. A good giggle induces the brain to release endorphins, so whoop it up!",
"There is a significant decrease in self-esteem when people stop exercising. Performing cardiovascular activities or toning combined with stretching produce equal increases in self-esteem."
	];
//   **************************************************************************
	if ( x == "length" ) { return Quote.length; }
	var i = x + 0;
	if ( isNaN(i) ) { return "Non-numeric index: "+x; }
	if ( x < Quote.length) { return Quote[x]; }
	return "Invalid index: "+x; 
}
function Quote_of_the_day(x) {
	if ( (x != "random") &&  
		(x != "date") && 
		(x != "all") && 
		(x != "help")  &&
		(x != "?") 
			) {
		x = default_x;
	}
	var Len = GetQuote("length");
	if (x == "all") {
		for (var i=0; i< Len; i++) {
			document.write("*** ", i, " <br>\n", GetQuote(i), "<br><br>\n");
		}
	}
	else if (x == "date") {
		var d = new Date();
		var a = ((d.getMonth() * Len) + d.getDate()) % (Len - 1);
		document.write(GetQuote(a));
	}
	else if (x == "random") {
		var a = Math.floor(Math.random() * Len);
		document.write(GetQuote(a));
	}
	else if ((x == "help") || (x == "?")) {
		document.write("<PRE>",
"Quote_of_the_day function\n",
"\n",
"  called by &lt;SCRIPT&gt;Quote_of_the_day([value])&lt;/SCRIPT&gt;\n",
"   where 'value' is optionally \"random\", \"all\", \"date\", \"help\" or \"?\".\n",
"   If it is null or any other value, it is set to the value of a global variable\n", 
"   \"default_x\" which is currently \"", default_x, "\".\n",
"\n",
"  \"random\"      returns a different entry each time the page is refreshed.\n",
"  \"date\"        returns a different entry each day, but the same one all day,\n",
"		     based on the day of the month on the browser\'s computer.\n",
"  \"all\"         is for a maintenance or debugging page and returns a list of\n",
"		     all the entries.\n",
"  \"help\" or \"?\" are for documentation and print this text.\n",
"\n",
"\n",
"  Quote of the day calls the function GetQuote which includes an array named Quote\n",
"    containing the various daily quotes. There are currently ", GetQuote("length") ,"in the array.\n",
"    This array is defined below within the following structure:\n",
"\n",
"   **************************************************************************\n",
"   	var Quote = [\n",
"\"quote of the day 0\",\n",
"\"quote of the day 1\",\n",
"       etc.\n",
"\"quote of the day last\"\n",
"	];\n",
"   **************************************************************************\n",
"\n",
"   Note that the syntax requires:\n",
"	0) Each entry is separated from the next by a comma; the last \n",
"	entry is not followed by a comma\n",
"	1) Each entry must be enclosed in standard ascii double-quotes (\").\n",
"	If it is desired to use a quote structure within a quote of the day:\n",
"		Simon says, \"Eat less, exercise more!\"\n",
"	the double-quotes must be backslashed to be seen as data:\n",
"		\"Simon says, \\\"Eat less, exercise more!\\\"\"\n",
"	2) HTML may be included in entries and is needed for multi-line entries\n",
"	because line breaks within the entries will cause javascript errors.\n",
"	3) If for some reason it is necessary to put a backslash (\) character\n",
"	in an entry it must be backslashed the same as a double-quote:\n",
"		\"Do something cute with emoticons ;\\ ?\"\n",
"      (Goddess forbid!) would have to be like this:\n",
"		\"Do something cute with emoticons ;\\\\ ?\"\n",
"</PRE>");
	}
	else {
		var a = Math.floor(Math.random() * Len);
		document.write(GetQuote(a));
	}
}

