function isStringInteger(strIn)
{
	var intI
	var strNumbers = "1234567890"
	
	if (strIn.length == 0)
		return false
	else
	{
		for (intI = 0; intI < strIn.length; intI++)
		{
			if (strNumbers.indexOf(strIn.charAt(intI)) == -1)
				return false
		}
		return true
	}
}

function validateInt(t)
{
	var intValue = ltrim(rtrim(t.value))

	if ((intValue != "") && (!(isStringInteger(intValue)) || (parseInt(intValue) < 0)))
	{
		alert("Please enter a valid number!")
		t.select()
		t.focus()
		return false
	}
	else
		return true
}

function validateZip(t)
{
	var intValue = ltrim(rtrim(t.value))
	var reZip = new RegExp(/(^\d{5}$)/)
	//	var reZip = new RegExp(/(^\d{5}$)|(^\d{5}-\d{4}$)/)

	if ((intValue != "") && (!reZip.test(intValue)))
	{
		alert("Please enter a valid zipcode!")
		t.select()
		t.focus()
		return false
	}

	return true
} 

function ltrim(strIn)
{
	var intI
	var strOut = ""

	if (strIn)
	{
		for (intI = 0; intI < strIn.length; intI++)
		{
			if (strIn.charAt(intI) != " ")
			{
				strOut = strIn.substring(intI)
				break
			}
		}

	}
	
	return strOut
}

function rtrim(strIn)
{
	var intI
	var strOut = ""
	
	if (strIn)
	{
		for (intI = strIn.length - 1; intI >= 0; intI--)
		{
			if (strIn.charAt(intI) != " ")
			{
				strOut = strIn.substring(0,intI + 1)
				break
			}
		}
	}
	
	return strOut
}

function checkCmb(t)
{
	if (t.options[t.selectedIndex].value == "")
	{
		alert("Please choose an option!")
		t.focus()
		return false
	}
	else
		return true
}

function checkTxt(bAlert) {
	var objNodes = document.getElementsByTagName("input")

	for (var k = 0; k < objNodes.length; k++) {
		var objNode = objNodes[k]

		if (objNode.type == "text") {
			if (objNode.id == "requiredTxt") {
				if (objNode.value == "") {
					if (bAlert) {
						alert("Please enter all the required fields!")
						objNode.focus()
					}
					return false
				}
			}
		}
	}

	return true
}

function popWindow(url)
{
	newWindow = window.open(url, "Window", "toolbar=no,width=600,height=400,directories=no,status=no,scrollbars=yes,resize=yes,menubar=no");
}

function submitZip(type)
{
	document.zipForm.action = "checkZip.asp?Type=" + type
	document.zipForm.submit();
}

