language="JavaScript"
		function checkString(myStr, myCard) {
			var tempStr = ""
			for (var i = 0; i < myStr.length; i++) {
				var oneChar = myStr.charAt(i)
				if (oneChar == " " || oneChar == "-") {
					continue
				}
				if (oneChar < "0" || oneChar > "9") {
					return false
				} else {
					tempStr += oneChar
				}
			}
			if (myCard == 0){					// The card is Visa
				if (tempStr.length  != 13 && myStr.length != 16) {
					return false   				// it doesn't have the right number of digits
				}
				if (tempStr.charAt(0) != "4"){
					return false   				// it doesn't begin with the correct digit
				}
			}
			if (myCard == 1) {					// The card is MasterCard
				if (tempStr.length  != 16) {
					return false   				// it doesn't have the right number of digits
				}
				if (tempStr.charAt(0) != "5"){
					return false   				// it doesn't begin with the correct digit
				}
			}	
			if (checkCreditNum(tempStr)){
				return true
			} else {	
				return false
			}
		}
		function sumDigits(myVar) {
			var mySum = 0
			for (i = 0; i < myVar.length; i++) {
				mySum += parseInt(myVar.charAt(i))
			}
			return mySum
		}
		function checkCreditNum(myNewStr) {
				var myFlag = false
				var tempStrOdd = ""
				var tempStrEven = ""
				for (i = myNewStr.length; i> 0; i--) {
					if (myFlag == false) {
						tempStrOdd = myNewStr.charAt(i-1) + tempStrOdd
						myFlag = true
					} else {
						tempStrEven = myNewStr.charAt(i-1) + tempStrEven
						myFlag = false
					}				
				}
				tempSum = sumDigits(tempStrOdd) + sumDigits("" + (2 * tempStrEven))
				if (tempSum % 10 == 0) {
					return true
				} else {
					return false
				}
		}
		function checkDigits(inputStr) {
			if (!checkEmpty(inputStr)) {
				return false
			}
			for (var i = 0; i < inputStr.length; i++) {
				var oneChar = inputStr.charAt(i)
				if (oneChar < "0" || oneChar > "9") {
					return false
				}
			}
			return true
		}
		function CreditCheck(form) {
			var inputStr = form.card_no.value
			var usrCardType = form.card.length
			var usrCardType = -1
			for (i=0; i<form.card.length; i++) {
				if (form.card[i].checked) {
					usrCardType = i
					break
				}
			}
			if (usrCardType == -1) {
				alert("Please choose Visa or MasterCard")
				return false
			}
			if (checkString(inputStr, usrCardType)) {
				return true
			} else {
				alert ("Please enter a valid credit card number before continuing.")
				form.card_no.focus()
				form.card_no.select()
				return false
			}
		}
		function checkMonth(myMonth) {
			if (!checkEmpty(myMonth)) {
				return false
			}
			var i = parseInt(myMonth)
			if (i >12 || i < 1) {
				return false
			}
			return true
			//checkDigits(myMonth)
		}
		function checkEmpty(myStr) {
			if (myStr == null || myStr == "") {
				return false
			} else {
				return true
			}
		}
		function validEmail(myEmail) {
			invalidChars = " /:,;"
			if (myEmail == "") {						// cannot be empty
				return false
			}
			for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
				badChar = invalidChars.charAt(i)
				if (myEmail.indexOf(badChar,0) > -1) {
					return false
				}
			}
			atPos = myEmail.indexOf("@",1)			// there must be one "@" symbol
			if (atPos == -1) {
				return false
			}
			if (myEmail.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
				return false
			}
			periodPos = myEmail.indexOf(".",atPos)
			if (periodPos == -1) {					// and at least one "." after the "@"
				return false
			}
			if (periodPos+3 > myEmail.length)	{		// must be at least 2 characters after the "."
				return false
			}
			return true
		}				
		function checkForm(form) {
			if (!checkEmpty(form.first_name.value)) {
				alert("Please enter your first name.")
				form.first_name.focus()
				form.first_name.select()
				return false
			}
			if (!checkEmpty(form.last_name.value)) {
				alert("Please enter your last name.")
				form.last_name.focus()
				form.last_name.select()
				return false
			}
			if (!checkEmpty(form.address.value)) {
				alert("Please enter your street address.")
				form.address.focus()
				form.address.select()
				return false
			}
			if (!checkEmpty(form.city.value)) {
				alert("Please enter your city.")
				form.city.focus()
				form.city.select()
				return false
			}
			if (!checkEmpty(form.zip.value)) {
				alert("Please enter your zip code.")
				form.zip.focus()
				form.zip.select()
				return false
			}
			// check to see if the email's valid
			if (!validEmail(form.email.value)) {
				alert("Invalid email address")
				form.email.focus()
				form.email.select()
				return false
			}
			if (!checkEmpty(form.area_code.value)) {
				alert("Please enter your area code.")
				form.area_code.focus()
				form.area_code.select()
				return false
			}
			if (!checkDigits(form.area_code.value)) {
				form.area_code.focus()
				form.area_code.select()
				return false
			}
			if (!checkEmpty(form.phone.value)) {
				alert("Please enter your phone number.")
				form.phone.focus()
				form.phone.select()
				return false
			}
			if (!CreditCheck(form)) {
				return false
			}
			if (!checkMonth(form.exp_month.value)) {
				alert("Please enter the expiration month of your credit card.")
				form.exp_month.focus()
				form.exp_month.select()
				return false
			}
			if (!checkDigits(form.exp_year.value)) {
				alert("Please enter the expiration year of your credit card.")
				form.exp_year.focus()
				form.exp_year.select()
				return false
			}
			return true
		}	

