function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
		for(i=0; i < e.length ;i++){
			if(ok.indexOf(e.charAt(i))<0){ 
				return (false);
			}
		} 
		if (document.images) {
			re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
			re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
			if (!e.match(re) && e.match(re_two)) {
				return (-1);		
			} 
		}
	}

function IsInteger(sText) {
	var ValidChars = "0123456789";
	var IsNumber=true;
	var Char;
	for (i = 0; i < sText.length && IsNumber == true; i++) {
		Char = sText.charAt(i);
		if (ValidChars.indexOf(Char) == -1) {
			IsNumber = false;
		}
	}
	return IsNumber;
}

function checkoutform(theform) {
	if (theform.fullname.value=='') {
		alert('Please enter your name');
		theform.fullname.style.backgroundColor='yellow';
		theform.fullname.focus();
		return false;
	} else {
		if(theform.email.value!='' && !check_email(theform.email.value)) {
			alert('Please enter a valid email address or a phone number so we can contact you');
			theform.email.style.backgroundColor='yellow';
			theform.email.focus();
			return false;
		} else {
			if(theform.contact[0].checked && (theform.email.value=='' || !check_email(theform.email.value))) {
				alert('If you wish to be contacted by email, you must enter an address');
				theform.email.style.backgroundColor='yellow';
				theform.email.focus();
				return false;
			} else {
				if (theform.contact[1].checked && theform.phone.value=='') {
					alert('If you wish to be contacted by phone, you must enter a number');
					theform.phone.style.backgroundColor='yellow';
					theform.phone.focus();
					return false;
				} else {
					if (theform.subject.value=='0') {
						alert('Please choose a subject for your message');
						theform.subject.style.backgroundColor='yellow';
						theform.subject.focus();
						return false;
					} else {
						if (!theform.frn_order_id.value=='' && (!IsInteger(theform.frn_order_id.value) || theform.frn_order_id.value.length < 5)) {
							alert('If you are entering an order number, it must be numeric, and at least 5 digits');
							theform.frn_order_id.style.backgroundColor='yellow';
							theform.frn_order_id.focus();
							return false;
						} else {
							if(theform.captchatext.value=='') {
								alert('Please answer the question');
								theform.captchatext.style.backgroundColor='yellow';
								theform.captchatext.focus();
								return false;
							} else {
								theform.doit.value='Please Wait...';
								theform.doit.disabled=true;
								return true;
							}
						}
					}
				}
			}
		}
	}
}
