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.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.message.value=='') {
		alert('Please tell us which items you\'re returning');
		theform.message.style.backgroundColor='yellow';
		theform.message.focus();
		return false;
	} else if (theform.whyreturn.selectedIndex==0) {
		alert('Please tell us why you are returning the item');
		theform.whyreturn.style.backgroundColor='yellow';
		theform.whyreturn.focus();
		return false;
	} else if (theform.whattodo.selectedIndex==0) {
		alert('Please tell us what you would like us to do');
		theform.whattodo.style.backgroundColor='yellow';
		theform.whattodo.focus();
		return false;
	} else if (theform.whattodo.selectedIndex==2 && theform.alternative_item.value=='') {
		alert('Please tell us which alternative item you would like');
		theform.alternative_item.style.backgroundColor='yellow';
		theform.alternative_item.focus();
		return false;
	} else if(theform.captchatext.value=='') {
		alert('Please answer the question at the bottom of the page');
		theform.captchatext.style.backgroundColor='yellow';
		theform.captchatext.focus();
		return false;
	} else {
		theform.doit.value='Please Wait...';
		theform.doit.disabled=true;
		return true;
	}
}
