var currentQuestion;
var answerWindow;
var numOfQuestions = 8;

var triviaQ = new Array();

triviaQ[0] = "Which uses less water...";
triviaQ[1] = "Older faucets emit the same amount of water as newer ones.";
triviaQ[2] = "Storing water in the refrigerator is a conservation method.";
triviaQ[3] = "You can conserve more water by planting in the...";
triviaQ[4] = "Watering your lawn uses less water in the...";
triviaQ[5] = "Using a broom to clean off your driveway instead of a hose saves you...";
triviaQ[6] = "To save water on watering your lawn you should cut the grass...";
triviaQ[7] = "Improve water penetration in your lawn by...";

var triviaC = new Array();

triviaC[0] = new Array("5 minute shower","Bath");
triviaC[1] = new Array("True","False");
triviaC[2] = new Array("True","False");
triviaC[3] = new Array("Spring/Fall","Summer/Winter");
triviaC[4] = new Array("Mid-day","Early mornings and evenings");
triviaC[5] = new Array("40 gallons of water","80 gallons of water");
triviaC[6] = new Array("On the shortest setting","At least three inches high");
triviaC[7] = new Array("Aerating","Alternating the sprinkler direction");

var triviaA = new Array();

triviaA[0] = new Array(1,"A five minute shower only uses 25 gallons of water while a bath can use anywhere from 30 to 50 gallons of water depending on the tub. Showers could use even less if a flow constrictor is attached to the nozzle.");
triviaA[1] = new Array(2,"False. Newer faucets are rated at 2.5 gallons per minute, whereas older ones (aerators) are significantly greater.");
triviaA[2] = new Array(1,"True. If your water is already chilled, you won't need to let the tap run when you need cold water.");
triviaA[3] = new Array(1,"The watering requirements are lower in the Spring and Fall.");
triviaA[4] = new Array(2,"Early mornings and evenings. The lower the temperature, the less evaporation will occur and your lawn will retain the water longer.");
triviaA[5] = new Array(2,"80 gallons is the average amount of water used out of a hose to clean off a driveway.");
triviaA[6] = new Array(2,"At least three inches high. Closely cut grass makes the roots work harder and thus requires more water.");
triviaA[7] = new Array(1,"Aerating will allow the water to reach the roots easier and requires less to do so.");


function randomTrivia() {
	var tmp = window.location.search.substring(1);
	
	if (tmp=="")
		currentQuestion=0;
	else {
		if (tmp.substring(0,2)!="cq")
			currentQuestion=0;
		else {
			tmp2 = tmp.substring(3);
			currentQuestion= tmp2 - 0;
		}
	}
	
	document.write(triviaQ[currentQuestion]+"<BR><BR>");
	document.write("<FORM NAME=triviaForm>");
	document.write("<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>");
	document.write("	<TR><TD VALIGN=middle ALIGN=center WIDTH=20 background=\"images/spacer.gif\"><INPUT TYPE=radio NAME=triv VALUE=1 onClick=\"checkAnswer("+currentQuestion+",1)\"></TD>");
	document.write("		<TD VALIGN=top WIDTH=150 CLASS=trivia background=\"images/spacer.gif\">"+triviaC[currentQuestion][0]+"</TD></TR>");
	document.write("	<TR><TD VALIGN=middle ALIGN=center WIDTH=20 background=\"images/spacer.gif\"><INPUT TYPE=radio NAME=triv VALUE=2 onClick=\"checkAnswer("+currentQuestion+",2)\"></TD>");
	document.write("		<TD VALIGN=top WIDTH=150 CLASS=trivia background=\"images/spacer.gif\">"+triviaC[currentQuestion][1]+"</TD></TR>");
	document.write("</TABLE>");
	document.write("</FORM>");
	document.triviaForm.reset();
	currentQuestion++;
}

function checkAnswer(num,ans) {
	document.triviaForm.reset();
	answerWindow=window.open("","","menubar=no,scrollbars=no,status=no,width=300,height=300,screenX=50,screenY=50,top=50,left=50");
	answerWindow.document.write('<HTML><HEAD><TITLE>Test Your H2O Knowledge</TITLE><LINK REL="Stylesheet" MEDIA="screen" HREF="main.css"><SCRIPT LANGUAGE="JavaScript1.2"><!-- currentQuestion='+currentQuestion+'; //--></SCRIPT></HEAD><BODY BGCOLOR=white topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>');
	answerWindow.document.write('<IMG SRC="images/spacer.gif" WIDTH=20 HEIGHT=1><IMG SRC="images/logo_small.gif"><BR CLEAR=all><BR>');
	answerWindow.document.write('<CENTER><TABLE CELLPADDING=0 CELLSPAING=0 BORDER=0><TR><TD VALIGN=top WIDTH=240 CLASS="bodyCopy">');
	if (triviaA[num][0]==ans) {
		answerWindow.document.write("<B>Correct.</B><BR><BR>");
	}
	else {
		answerWindow.document.write("<B>Incorrect.</B><BR><BR>");
	}
	answerWindow.document.write('<B>Answer:</B> '+triviaA[num][1]+'<BR><BR>');
	answerWindow.document.write('</TD></TR></TABLE></CENTER></BODY></HTML>');
	var tmp1 = window.location.href;
	var ind = tmp1.indexOf('?');
	if (ind!=-1) {
		tmp1 = tmp1.substring(0,ind);
	}
	if (currentQuestion==8) currentQuestion=0;
	tmp = tmp1 + "?cq=" + currentQuestion;
	window.location.href(tmp);
}

function redirectLink(newLink) {
	newWindow = window.open(newLink[newLink.selectedIndex].value,"","toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes");
}

function writeTopNav(section,screenWidth) {
	var expandto = screenWidth - 740;
	if (expandto < 50) expandto=50;

	if (section==1) {
		document.write('<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n');
		document.write('	<TR>\n');
		document.write('		<TD WIDTH="40" BACKGROUND="images/spacer.gif">&nbsp;</TD>\n');
		document.write('		<TD WIDTH="700" HEIGHT="70" BGCOLOR="white" VALIGN="bottom">\n');
		document.write('			<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
		document.write('				<TR>\n');
		document.write('					<TD VALIGN="bottom" WIDTH="230" ALIGN="center"><IMG SRC="images/logo_big.gif"></TD>\n');
		document.write('					<TD VALIGN="bottom" ALIGN="right" WIDTH="470">\n');
		document.write('					<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
		document.write('						<TR>\n');
		document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><FONT COLOR="#3399FF">Home</FONT></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="11"><IMG SRC="images/down_arrow.gif"></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="faq.html">FAQ</A></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="70" CLASS="topnav" ALIGN="center"><A HREF="register.php">Register</A></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="tips.html">Tips</A></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="game.html">Game</A></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="20"><IMG SRC="images/spacer.gif"></TD>\n');
		document.write('						</TR>\n');
		document.write('					</TABLE>\n');
		document.write('					</TD>\n');
		document.write('				<TR>\n');
		document.write('			</TABLE>\n');
		document.write('		</TD>\n');
		document.write('		<TD WIDTH='+expandto+' BACKGROUND="images/spacer.gif">&nbsp;</TD>\n');
		document.write('	</TR>\n');
		document.write('	<TR>\n');
		document.write('		<TD WIDTH="40" BGCOLOR="#3399FF" VALIGN="top"><IMG SRC="images/spacer.gif" HEIGHT="1" WIDTH="1"></TD>\n');
		document.write('		<TD WIDTH="700" BGCOLOR="white" VALIGN="top">\n');
		document.write('			<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
		document.write('				<TR>\n');
		document.write('					<TD VALIGN="top" HEIGHT="170" WIDTH="230"><IMG SRC="images/water_meter.jpg"></TD>\n');
		document.write('					<TD VALIGN="top" HEIGHT="170" WIDTH="470"><IMG SRC="images/save_water.gif"></TD>\n');
		document.write('				<TR>\n');
		document.write('			</TABLE>\n');
		document.write('		</TD>\n');
		document.write('		<TD WIDTH='+expandto+' BGCOLOR=#3399FF><IMG SRC="images/spacer.gif" HEIGHT=1 WIDTH=1></TD>\n');
		document.write('	</TR>\n');
	}
	else {
		document.write('<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n');
		document.write('	<TR>\n');
		document.write('		<TD WIDTH="40" BACKGROUND="images/spacer.gif">&nbsp;</TD>\n');
		document.write('		<TD WIDTH="700" HEIGHT="40" BGCOLOR="white" VALIGN="bottom">\n');
		document.write('			<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
		document.write('				<TR>\n');
		document.write('					<TD VALIGN="bottom" WIDTH="230" ALIGN="center"><IMG SRC="images/logo_small.gif"></TD>\n');
		document.write('					<TD VALIGN="bottom" ALIGN="right" WIDTH="470">\n');
		document.write('					<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
		document.write('						<TR>\n');
		document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="index.html">Home</A></TD>\n');
		document.write('							<TD VALIGN="top" WIDTH="11"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		if (section==2) {
			document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="faq.html"><FONT COLOR="#3399FF">FAQ</FONT></A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/down_arrow.gif"></TD>\n');
		}
		else {
			document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="faq.html">FAQ</A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		}
		if (section==3) {
			document.write('							<TD VALIGN="top" WIDTH="70" CLASS="topnav" ALIGN="center"><A HREF="register.php"><FONT COLOR="#3399FF">Register</FONT></A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/down_arrow.gif"></TD>\n');
		}
		else {
			document.write('							<TD VALIGN="top" WIDTH="70" CLASS="topnav" ALIGN="center"><A HREF="register.php">Register</A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		}
		if (section==5) {
			document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="tips.html"><FONT COLOR="#3399FF">Tips</FONT></A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/down_arrow.gif"></TD>\n');
		}
		else {
			document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="tips.html">Tips</A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		}
		if (section==4) {
			document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="game.html"><FONT COLOR="#3399FF">Game</FONT></A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/down_arrow.gif"></TD>\n');
		}
		else {
			document.write('							<TD VALIGN="top" WIDTH="50" CLASS="topnav" ALIGN="center"><A HREF="game.html">Game</A></TD>\n');
			document.write('							<TD VALIGN="top" WIDTH="9"><IMG SRC="images/nav_blueline.gif"></TD>\n');
		}
		document.write('							<TD VALIGN="top" WIDTH="20"><IMG SRC="images/spacer.gif"></TD>\n');
		document.write('						</TR>\n');
		document.write('					</TABLE>\n');
		document.write('					</TD>\n');
		document.write('				<TR>\n');
		document.write('			</TABLE>\n');
		document.write('		</TD>\n');
		document.write('		<TD WIDTH='+expandto+' BACKGROUND="images/spacer.gif">&nbsp;</TD>\n');
		document.write('	</TR>\n');
		document.write('	<TR>\n');
		document.write('		<TD WIDTH="40" BGCOLOR="#3399FF" VALIGN="top"><IMG SRC="images/spacer.gif" HEIGHT="1" WIDTH="1"></TD>\n');
		document.write('		<TD WIDTH="700" BGCOLOR="white" VALIGN="top">\n');
		document.write('			<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
		document.write('				<TR>\n');
		document.write('					<TD VALIGN="top" HEIGHT="60" WIDTH="230"><IMG SRC="images/water_ripples.jpg"></TD>\n');
		document.write('					<TD VALIGN="top" HEIGHT="60" WIDTH="470"><IMG SRC="images/save_water_small.gif"></TD>\n');
		document.write('				<TR>\n');
		document.write('			</TABLE>\n');
		document.write('		</TD>\n');
		document.write('		<TD WIDTH='+expandto+' BGCOLOR=#3399FF><IMG SRC="images/spacer.gif" HEIGHT=1 WIDTH=1></TD>\n');
		document.write('	</TR>\n');
	}
	document.write('	<TR>\n');
	document.write('		<TD WIDTH="40" BACKGROUND="images/spacer.gif"><IMG SRC="images/spacer.gif"></TD>\n');
	document.write('		<TD WIDTH="700" BGCOLOR="white" VALIGN="top">\n');
	document.write('			<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
	document.write('				<TR>\n');
	document.write('					<TD VALIGN="top" WIDTH="229">\n');
	document.write('						<BR>\n');
	document.write('						<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n');
	document.write('							<TR>\n');
	document.write('								<TD VALIGN="top" WIDTH="10"><IMG SRC="images/spacer.gif" WIDTH="10" HEIGHT="1"></TD>\n');
	document.write('								<TD VALIGN="top" WIDTH="210">\n');
	document.write('									<IMG SRC="images/register_top.jpg"><BR CLEAR="all">\n');
	document.write('									<IMG SRC="images/register_animated.gif">\n');
	document.write('								</TD>\n');
	document.write('								<TD VALIGN="top" WIDTH="9"><IMG SRC="images/spacer.gif" WIDTH="9" HEIGHT="1"></TD>\n');
	document.write('							</TR>\n');
	document.write('						</TABLE>\n');
	document.write('						<BR>\n');
	document.write('						<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0">\n');
	document.write('							<TR>\n');
	document.write('								<TD VALIGN="top" WIDTH="10"><IMG SRC="images/spacer.gif" WIDTH="10" HEIGHT="1"></TD>\n');
	document.write('								<TD VALIGN="top" WIDTH="210" HEIGHT="190" BACKGROUND="images/trivia_back.jpg" ALIGN="center">\n');
	document.write('									<IMG SRC="images/spacer.gif" HEIGHT=60 WIDTH=1><BR CLEAR=all>\n');
	document.write('									<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0">\n');
	document.write('										<TR><TD VALIGN="top" WIDTH="170" CLASS="trivia" background="images/spacer.gif">\n');
	randomTrivia();
	document.write('										</TD></TR>\n');
	document.write('									</TABLE>\n');
	document.write('								</TD>\n');
	document.write('								<TD VALIGN="top" WIDTH="9"><IMG SRC="images/spacer.gif" WIDTH="9" HEIGHT="1"></TD>\n');
	document.write('							</TR>\n');
	document.write('						</TABLE>\n');
	if (section==1) {
		document.write('<div class="testimonials">\n');
		document.write('<h3>Customer Testimonial</h3>\n');
		document.write('<blockquote>&ldquo;It is an excellent program. I try to encourage everyone to sign up. We\'ve reduced our annual water bill by 30%!&rdquo;</blockquote>\n');
		document.write('<cite>Warren W.<br>family of 4 in Cloverdale</cite>\n');
		document.write('</div>\n');
	}
	if (section==2) {
		document.write('<div class="testimonials">\n');
		document.write('<h3>Customer Testimonials</h3>\n');
		document.write('<blockquote>&ldquo;We have found savings on our water bill. I would highly recommend the Program to other families.&rdquo;</blockquote>\n');
		document.write('<cite>Paul R.<br>family of 5 in South Surrey</cite>\n');
		document.write('<blockquote>&ldquo;Great system! We have noticed savings on our water bills.&rdquo;</blockquote>\n');
		document.write('<cite>David D.<br>family of 4 in South Surrey</cite>\n');
		document.write('</div>\n');
	}
	if (section==3) {
		document.write('<div class="testimonials">\n');
		document.write('<h3>Customer Testimonial</h3>\n');
		document.write('<blockquote>&ldquo;The installation technician was very pleasant and knowledgeable. The Program has been well thought out &mdash; I should have signed up sooner! I would recommend the Program to others.&rdquo;</blockquote>\n');
		document.write('<cite>Judy K.<br>Guildford</cite>\n');
		document.write('</div>\n');
	}
	if (section!=1) {
		document.write('						<CENTER><FORM><SELECT NAME="links" CLASS="bodyCopy" onChange="redirectLink(this.form.links.options)">\n');
		document.write('							<OPTION SELECTED CLASS="bodyCopy">Water Conservation Links</OPTION>\n');
		document.write('							<OPTION VALUE="http://www.waterinfo.org" CLASS="bodyCopy">- www.waterinfo.org</OPTION>\n');
		document.write('							<OPTION VALUE="http://www.waterwiser.org" CLASS="bodyCopy">- www.waterwiser.org</OPTION>\n');
		document.write('							<OPTION VALUE="http://www.savingwater.org" CLASS="bodyCopy">- www.savingwater.org</OPTION>\n');
		document.write('							<OPTION VALUE="http://www.ec.gc.ca/water/en/info/pubs/fs/e_FSA3.htm" CLASS="bodyCopy">- Environment Canada</OPTION>\n');
		document.write('							<OPTION VALUE="http://www.epa.gov/ow/" CLASS="bodyCopy">- EPA Office of Water</OPTION>\n');
		document.write('						</SELECT></FORM></CENTER>\n');
	}
	document.write('					</TD>\n');
	document.write('					<TD VALIGN="top" BACKGROUND="images/dashed_line.gif" WIDTH="1"><IMG SRC="images/spacer.gif" WIDTH="1" HEIGHT="1"></TD>\n');
	document.write('					<TD VALIGN="top" WIDTH="30"><IMG SRC="images/spacer.gif"></TD>\n');
	document.write('					<TD VALIGN="top" WIDTH="410" CLASS="bodyCopy">\n');
}

function writeBottomNav(screenWidth) {
	var expandto = screenWidth - 740;
	if (expandto < 50) expandto=50;

	document.write('					</TD>\n');
	document.write('					<TD VALIGN="top" WIDTH="30"><IMG SRC="images/spacer.gif"></TD>\n');
	document.write('				</TR>\n');
	document.write('				<TR>\n');
	document.write('					<TD VALIGN="top" COLSPAN="5" BGCOLOR="white" ALIGN="center" CLASS="tinyText">\n');
	document.write('						<BR><IMG SRC="images/logos_small.gif"><BR CLEAR=all><BR><A HREF="privacy.html">privacy statement</A> | <A HREF="http://www.bcgas.com/bcgas/corporate/about+bc+gas/inc+overview/bcg+services/default.htm">affiliates</A> | <A HREF="register.php">register</A> | <A HREF="mailto:support@surreywatermeter.com">site support</A> | <A HREF="mailto:info@surreywatermeter.com">contact us</A><BR CLEAR="all">\n');
	document.write('						<IMG SRC="images/spacer.gif" HEIGHT="5" WIDTH="1"><BR CLEAR="all">\n');
	document.write('						&copy; 2003 Corix Utilities - All rights reserved<BR CLEAR="all">\n');
	document.write('						<IMG SRC="images/spacer.gif" HEIGHT="5" WIDTH="1"><BR CLEAR="all">\n');
	document.write('					</TD>\n');
	document.write('				</TR>\n');
	document.write('			</TABLE>\n');
	document.write('		</TD>\n');
	document.write('		<TD WIDTH='+expandto+' BACKGROUND="images/spacer.gif">&nbsp;</TD>\n');
	document.write('	</TR>\n');
	document.write('</TABLE>\n');
}
