function toggleCatnav(id) {
	if(document.getElementById('catNav'+id).style.display == "block") {
		document.getElementById('catNav'+id).style.display = "none"
	} else {
		document.getElementById('catNav'+id).style.display = "block"
	}
}
function checkoutCheckState(shippingState) {
	if(shippingState.options[shippingState.selectedIndex].value == 'other') {
		document.getElementById('divStateOther').style.display = 'block';
	} else {
		document.getElementById('divStateOther').style.display = 'none';
	}
}	
re1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
re2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
function checkoutShippingInt(form) {
	if(!form.shippingFName.value) {
		form.shippingFName.focus();
		alert('First Name is a required field.');
		return false;
	}
	if(!form.shippingLName.value) {
		form.shippingLName.focus();
		alert('Last Name is a required field.');
		return false;
	}
	if(!form.shippingAddress.value) {
		form.shippingAddress.focus();
		alert('Address is a required field.');
		return false;
	}
	if(!form.shippingCity.value) {
		form.shippingCity.focus();
		alert('City is a required field.');
		return false;
	}
	if(!form.shippingState.options[form.shippingState.selectedIndex].value) {
		alert('Please select a State / Province.');
		return false;
	}
	if(!form.shippingState.options[form.shippingState.selectedIndex].value == 'other' && (!form.shippingStateOther.value)) {
		form.shippingStateOther.focus();
		alert('Please provide State or Province name in Other box.');
		return false;
	}
	if(!form.shippingPhone.value) {
		form.shippingPhone.focus();
		alert('Phone is a required field.');
		return false;
	}
	//if they are creating a new user lets validate the info
	if(document.getElementById('shippingNewUsername')) {
		if(document.getElementById('shippingNewUsername').value || document.getElementById('shippingNewPassword').value || document.getElementById('shippingNewEmail').value) {
			if(!document.getElementById('shippingNewUsername').value) {
				document.getElementById('shippingNewUsername').focus();
				alert('Username is required for a new account.');
				return false;
			}
			if(!document.getElementById('shippingNewPassword').value) {
				document.getElementById('shippingNewPassword').focus();
				alert('Password is required for a new account.');
				return false;
			}
			if(re1.test(document.getElementById('shippingNewEmail').value) || (!re2.test(document.getElementById('shippingNewEmail').value))) {
				alert('Valid Email is required for a new account.');
				document.getElementById('shippingNewEmail').focus();
				return false;
			}
		}
	}
	return true;
}
function checkoutBillingRebill(form) {
	if(!form.billingCardNumber.value) {
		form.billingCardNumber.focus();
		alert('Card Number is a required field.');
		return false;
	}
	if(!form.billingCardCVV.value) {
		form.billingCardCVV.focus();
		alert('Card CVV is a required field.');
		return false;
	}
	if(!form.tosAgreement.checked) {
		alert('Please review and agree to our Store Policy.');
		return false;
	}
	return true;
}
function checkoutBillingInt(form) {
	if(!form.billingFName.value) {
		form.billingFName.focus();
		alert('First Name is a required field.');
		return false;
	}
	if(!form.billingLName.value) {
		form.billingLName.focus();
		alert('Last Name is a required field.');
		return false;
	}
	if(!form.billingAddress.value) {
		form.billingAddress.focus();
		alert('Address is a required field.');
		return false;
	}
	if(!form.billingCity.value) {
		form.billingCity.focus();
		alert('City is a required field.');
		return false;
	}
	if(!form.billingState.options[form.billingState.selectedIndex].value) {
		alert('Please select a State / Province.');
		return false;
	}
	if(!form.billingState.options[form.billingState.selectedIndex].value == 'other' && (!form.billingStateOther.value)) {
		form.billingStateOther.focus();
		alert('Please provide State or Province name in Other box.');
		return false;
	}
	if(!form.billingPhone.value) {
		form.billingPhone.focus();
		alert('Phone is a required field.');
		return false;
	}
	if(re1.test(document.getElementById('email').value) || (!re2.test(document.getElementById('email').value))) {
		alert('Valid Email is required.');
		document.getElementById('email').focus();
		return false;
	}
	if(!form.billingCardNumber.value) {
		form.billingCardNumber.focus();
		alert('Card Number is a required field.');
		return false;
	}
	if(!form.billingCardCVV.value) {
		form.billingCardCVV.focus();
		alert('Card CVV is a required field.');
		return false;
	}
	if(!form.tosAgreement.checked) {
		alert('Please review and agree to our Store Policy.');
		return false;
	}
	form.checkoutOrderProcess.value = 'Processing Order';
	form.checkoutOrderProcess.disabled = true;
	return true;
}
