// JavaScript Document

var tipArray = [
	["Save Water Indoors", "indiv_indoorTips.html", "waterSense_partner_clear.gif",
	 	[
			 ["Fix that leak.", 
			  	["Tip #1: Read your water meter before and after a two-hour period when no water is being used. If the meter does not read exactly the same, you probably have a leak.", 
				 "Tip #2: Faucets can drip at a rate of one drop per second, wasting more than 3,000 gallons of water a year.", 
				 "Tip #3: Toilets can leak at a rate of 200 gallons a day, which can add up to 73,050 gallons of water a year. To find out if you have a leak, place a drop of food coloring in the tank. If the color shows in the bowl without flushing, you have a leak."], "3"
			 ],
			 ["Give your shower power.", 
			  	["Tip #4: Taking a five-minute shower uses 10 to 25 gallons of water. Install a water saving showerhead to reduce the flow.", 
				 "Tip #5: A full bath tub requires about 70 gallons of water. Place a stopper in the drain immediately and adjust the temperature as you fill the tub to limit waste."], "2"
			 ],
			 ["Turn it off.", 
			  	["Tip #6: The average bathroom faucet flows at a rate of two gallons per minute. Turning off the tap while brushing your teeth saves up to eight gallons of water per day, 240 gallons a month, 2,880 gallons a year."], "1"
			 ],
			 ["Make It a Full Load!", 
			  	["Tip #7: The average washing machine uses about 41 gallons of water per load. High-efficiency washing machines use less than 28 gallons of water per load.", 
				 "Tip #8: Wash only full loads of laundry or use the appropriate load size selection on the washing machine to save water."], "2" 
			 ],
			 ["Don't flush your money down the drain.", 
			  	["Tip #9: If your toilet was made before 1993, you probably have an inefficient model that uses at least 3.5 gallons per flush. Installing a new toilet could save a family of four more than $90 on their water bill annually."], "1"
			 ],
		 ], "5"
	 ],
	
	["Save Water Outdoors", "indiv_outdoorTips.html", "watersmart_clear.gif",
		[ 
			["Water efficiently.",
				["Tip #10: Target water to plants that show signs of moisture stress. Plants will turn a gray-green color or wilt when they need water.",
				"Tip #11: Water the root zone of the plant instead of the foliage. This saves water and reduces diseases.",
				"Tip #12: Water at night or in early morning to avoid losing water to evaporation.",
				"Tip #13: Water deeply. Light, frequent watering causes shallow rooting and increases the need for water.",
				"Tip #14: Use drip irrigation and micro-sprays when possible. They use 30 to 50 percent less water than sprinklers.",
				"Tip #15: In-ground system users should have a regular system audit performed by a professional who will inspect for leaks and other problems and recommend new water-saving equipment."], "6"
			],
			["Put the &quot;right&quot; plants in the &quot;right&quot; places.",
				["Tip #16: Select plants carefully. Read the plant tag, it tells you the amount of sunlight and water the plants needs as well as the recommended soil conditions.",
				"Tip #17: Plants that require partial shade do best on eastern exposures where they are shaded from the hot afternoon sun.",
				"Tip #18: Consider the slope and drainage patterns of the site. Plant moisture-loving plants at the base of slopes where they can take advantage of natural drainage.",
				"Tip #19: Group plants in the landscape according to their water need: high, medium or low. This will result in more efficient irrigation."], "4"
			],
			["Add organic matter to the soil.",
				["Tip #20: Organic matter, such as compost, improves the water and nutrient-holding capacity of the soil, adds valuable micro-organisms that aid in nutrient uptake by plants, reduces soil erosion and filters and buffers potential pollutants.",
				"Tip #21: Apply three inches of organic matter to the soil surface and incorporate it into the soil 12 inches deep.",
				"Tip #22: Add organic matter uniformly across the planting area."], "3"
			],
			["Mulch.",
				["Tip #23: Mulch holds moisture in the soil.",
				"Tip #24: Apply pine straw, shredded hardwood or bark mulch three inches deep: two bales of pine straw cover approximately 100 square feet; 14, 2-cubic feet bags of mulch cover 100 square feet.",
				"Tip #25: Apply mulch under the entire canopy of the plant."], "3"
			],
			["Harvest water from alternative sources and use it to irrigate plants.",
				["Tip #26: Collect water in rain barrels or cisterns.",
				"Tip #27: For each inch of rainfall, six gallons of water can be harvested per square foot of roof area.",
				"Tip #28: Air-conditioner condensation and dehumidifiers are also sources of irrigation water."], "3"
			],
			["Know the rules",
				["Tip #29: Contact your local water utility to find out about outdoor water use restrictions in your area."], "1"
			]
		], "6"
	]
];


function generateRandomTip(section,heading,tip) {
	
		randomSection = Math.floor(Math.random() * 2);
		
		sectionHeading = tipArray[randomSection][0];
		sectionLink = tipArray[randomSection][1];
		imageLink = tipArray[randomSection][2];
		sectionCount = tipArray[randomSection][4];
		
		randomHeading = Math.floor(Math.random() * sectionCount);
		tipHeading = tipArray[randomSection][3][randomHeading][0];
		tipCount = tipArray[randomSection][3][randomHeading][2];
		
		randomTip = Math.floor(Math.random() * tipCount);
		tipContent = tipArray[randomSection][3][randomHeading][1][randomTip];

		/* used for debugging purposes:		
	
		return	'randomSection = ' + randomSection + '<br />' + 
				'randomHeading = ' + randomHeading + '<br />' + 
				'randomTip = ' + randomTip + '<br /><br />' +
				
				*/
				
		return	'<h3>' + sectionHeading + '</h3>' +
				'<p><strong>' + tipHeading + '</strong><br />' +
				tipContent + '</p>' +
				'<p><a href="http://www.conservewatergeorgia.net/documents/' + sectionLink + '">See more tips</a></p>' +
				'<p align="center"><a href="http://www.conservewatergeorgia.net/documents/' + sectionLink + '">' + 
				'<img src="http://www.conservewatergeorgia.net/images/' + imageLink + '" align="center" border="0" /></a></p>';
				
}
