function uo(id) { // IE5 support
	if(document.all) { return document.all.id; }
	else { return document.getElementById(id); }
}

function toggle(x,icon) {// Show Hide Content
   var targetDiv = document.getElementById('topicListCategory-' + x);
if(targetDiv.style.display == 'block') {
 // Currently showing, so hide
    targetDiv.style.display = 'none';
    icon.style.background = 'url(images/Plus.gif) no-repeat 0px 1px';
} else {
 // Currently hiding, so show
 targetDiv.style.display = 'block';
 icon.style.background = 'url(images/Minus.gif) no-repeat 0px 1px';
}
}

function expandAll(topiclist) {
	//Populate the array with all the page tags
	var allPageTags=document.getElementsByTagName("div");
	//Cycle through the tags using a for loop
	for (i=0; i<allPageTags.length; i++) {
	//Pick out the tags with our class name
		if (allPageTags[i].className=='topiclist') {
			//Manipulate this in whatever way you want
			allPageTags[i].style.display='block';
			}
		}
	var allPageTags=document.getElementsByTagName("a");
	//Cycle through the tags using a for loop
	for (i=0; i<allPageTags.length; i++) {
	//Pick out the tags with our class name
		if (allPageTags[i].className=='expander') {
			allPageTags[i].style.background='url(images/Minus.gif) no-repeat 0px 1px';
			}
		}
}

function collapseAll(topiclist) {
	var allPageTags=document.getElementsByTagName("div");
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className=='topiclist') {
			allPageTags[i].style.display='none';
			}
		}
	var allPageTags=document.getElementsByTagName("a");
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className=='expander') {
			allPageTags[i].style.background='url(images/Plus.gif) no-repeat 0px 1px';
			}
		}
}

function toTop() {
   window.location= "#top";
}
function reply() {
   window.location= "Reply.htm";
}
function goBack() {
   window.location= "history.back";
}
function Topic() {
   window.location= "Topic.htm";
}
function Thread() {
   window.location= "Thread.htm";
}
function CreateThread() {
   window.location= "CreatePost.htm";
}
function joinChallenge() {
   window.location= "CompDetails.htm";
}
function update() {
   window.location= "ActionPlan.htm";
}
function results() {
   window.location= "Results.htm";
}
function update() {
   window.location= "MyActionPlan.htm";
}

function explaination(x) {// Show explaination
   var targetDiv = document.getElementById('exp-' + x);
if(targetDiv.style.display == 'block') {
 // Currently showing, so hide
    targetDiv.style.display = 'none';
} else {
 // Currently hiding, so show
 targetDiv.style.display = 'block';
}
}

function ShowAll() {
	var allPageTags = document.getElementsByTagName("p");
	for (i = 0; i < allPageTags.length; i++)
	{
		if (allPageTags[i].className == 'explaination')
		{
			currentDisplay = allPageTags[i].style.display;
			if(currentDisplay == 'block') {
			allPageTags[i].style.display = 'none';
		}
		else {
			allPageTags[i].style.display = 'block';
		}
		}
	}
} 

function validateNumber(field, msg, min, max) {
return true;
if (!min) { min = 0 }
if (!max) { max = 99000 }

if ((parseInt(field.value) != field.value) ||  
field.value < min || field.value > max) {
alert(msg);
field.focus();
field.select();
return false;
}

return true;
}


//Validation for Eco-calculator
var thanks="\nThanks!"

function validate(x) {
var alertMsg="Please enter values for the following questions:\n\n"

//checks questions for valid answers and adds to the alert Box
if (x.Q1.selectedIndex=="0"){alertMsg+="Q1\n";}
for (i= 2; i < 13; i++) {
	var Question=eval("x.Q"+i+".value");
	if (isNaN(Question)==true || Question<0 || Question==""){alertMsg+="Q"+i+"\n";}
	}
if (x.greenpower[0].checked==false && x.Q13.value=="") {alertMsg+="Q13\n";}

// checks if there's errors
var error = alertMsg.indexOf("Q");
if (error>0){	
	var Question = alertMsg.charAt(error+1);
	var Question = eval("x.Q"+Question);
	Question.focus();
	window.alert(alertMsg+thanks);
	return false;
	}
else {return true}
}