// Copyright 2006-2007 http://javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 


///////////////////////////////////////////////
///////////  TEST SCRIPT //////////////////////
///////////////////////////////////////////////


var points = new Array(0,0,0,0,0);
var total   = 0;
var percent = 0;
var barWidth = 200;
var color = "green";
 
function updatePoints(arr,val) {
 	if (!val) val = 0;
 	val = parseFloat(val);
 	points[arr] = val;
	updateTotal();
}
 
function updateTotal() {
 	var sum = 0;
 	for (var i=0; i<points.length; i++) 
 	{ 
 		sum = sum + points[i]; 
 	} 
   	total = sum; 
	setColor(total); 
	document.getElementById("total").innerHTML = total;
  	document.getElementById("bar").style.width = (total < barWidth) ? ((total)+"px") : ((barWidth)+"px");
  	document.getElementById("bar").style.background = color;
 }
 
 function updatePercent(arr,val)
 {
  	if (!val) val = 0;
  	val = parseFloat(val);
  	points[arr] = val/5;
	updateTotal();
 }

function resetTotal()
 {
 	for (var i=0; i<points.length; i++) 
 	{points[i] = 0;} 
	updateTotal(); 
	document.getElementById("1").selectedIndex = 0;
	document.getElementById("2").selectedIndex = 0;
	document.getElementById("3").value = "";
	document.getElementById("4").selectedIndex = 0;
	document.getElementById("5").selectedIndex = 0;
	}

function setColor(total) { 
	if (total  > 0  && total <= 40) color = "green";
 	if (total > 40 && total <= 80) color = "yellow";
 	if (total > 80 && total <= 100) color = "orange";
	if (total > 100) color = "red";
 }

function defaultset () {
	document.getElementById('barbox').style.width = barWidth+'px';
}

// Copyright 2009 

function getPage (theForm) {
	
	$Zipcode = theForm.Zipcode.value;
	if ($Zipcode.length < 5) {
		alert("Please double check that you entered the correct zip code.  Your zip code should be in a 5 digit format.");
		return false;
	}
	else {
		return true;
	}
}