/*
	Used for formatting ZipCodes to 12345-1234 
	Designed by Rob Reynolds (BCS) Copyright 2004 by KDOT.
	
	TO USE: Include below in your textbox or in a span element surrounding your asp:TextBox.	
	onkeyup="formatZip('fieldID');"
*/

var lastZipLength;

function formatZip(field) {
	strZipField = document.getElementById(field).value;
	strZip = "";

	if (strZipField.length > lastZipLength) {
		for (x = 0; x < strZipField.length; x++) {
			strZipInt = strZipField.charCodeAt(x);
			if ((strZipInt > 47) && (strZipInt < 58)) {
				strZip += strZipField.substr(x, 1);
			}
		}

		if ((strZip.length > 5) && (strZip.substr(5, 1) != "-")) {
			strZip = strZip.substr(0, 5) + "-" + strZip.substr(5, (strZip.length - 5));
		}
	} else {
		strZip = strZipField;
	}

	if (strZip.length > 10) {
	strZip = strZip.substr(0, 10);
	}
	document.getElementById(field).value = strZip;
	lastZipLength = strZip.length;
}	