// form.js  03/19-11

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function validate()
{
	a = document.getElementById("zip").value;
	if (a.match(/[0-9]{5}/) == null)
	{
		alert("Error. Please enter a valid zip code.");
		return false;
	}
}
		
function checkAll(field)
{
	for (i = 0; i < field.length; i++)
	{
		field[i].checked = true ;
	}
}
		
function uncheckAll(field)
{
	for (i = 0; i < field.length; i++)
	{
		field[i].checked = false ;
	}
}

function conditionize(num,url)
{
	var x;
	params = url.split('?');
	page = params[0];
	params = params[1];
	params = params.split('&');
 	newparams = '';
	for (x in params)
	{
		if("cond" in x)
		{
			continue;
		}
		else
		{
			newparams = x+"&";
		}
	}
	alert(newparams);
}

function total()
{
	tally = 0;
	var x = 0;
	for(x = 0;x < document.selecttowns.condList.length;x++)
	{
		if (document.selecttowns.condList[x].checked == true)
		{
			val = document.selecttowns.condList[x].value.split('|');
			tally += parseInt(val[1]);
		}
	}
	document.getElementById("runningtotal").innerHTML = tally;
	document.selecttowns.quantity.value = tally;
	return tally;
}

function isOneChecked(form)
{
	var string = '';
	var good = false;
	list = document.selecttowns.condList;
	for (var x in list)
	{
		if (list[x].checked == true)
		{
			string += "check ";
			good = true;
		}
		else {continue;}
	}
	alert(list);
	if (good == false) alert("Please check at least one box.");
	return good;
}

function switcher(value,ordid)
		{
			if(value == 'delete' || value == 'DupOrder') 
			{
				a = confirm('Are you sure?');
				if(a === false) 
				{
					document.getElementById("selector").selectedIndex = 0;
					return false;
				}
				else window.location = '../Includes/OrderOps/OrderOptions.cfm?id='+ordid+'&action=' + value;
			}
			
			else if (value.length < 2) return false;
			else window.location = '../Includes/OrderOps/OrderOptions.cfm?id='+ordid+'&action=' + value;
		}

