
// item.php:	begin
function add_to_cart() {
	doc = document.theForm
	numbersOnly_no_decimal(doc.qty.name,doc.qty.value,doc.name)
	doc.submit()
	
}


// cart.php
function changeQty() {
	//numbersOnly(this.name,this.value,form.name)
	for (var i=0; i<document.theForm.length; i++) {
		var thisLine = document.theForm.elements[i]
		if (thisLine.type == "text") {
			numbersOnly(thisLine.name,thisLine.value,document.theForm.name)
		}
	}
	
	document.theForm.submit()
}

// cart.php
function removeItem(getSKU)	{
	if(confirm("Are you certain that you want to remove this item?"))	{
		document.theCart.whichLineItem.value = getSKU
		document.theCart.formType.value = "remove"
		document.theCart.submit()
	}
}


// cart.php
function changeCart() {
	document.theCart.submit()
}

// cart.php
function goToCheckOut() {
	// don't submit the form, since we don't allow changing quantities anymore (except to remove)
	
	document.theCart.goto_orderform.value = "yes"
	document.theCart.submit()
}

// customize.php
function signupForm() {
	alert("test mode")
}

// orderform.php
function submitOrder() {
	
		var warningText = "Please complete the following information:\n"
		var warningTrack = 0
		selectWhichField = ""
		if (document.theForm.fname.value == "")	{
			warningText += "First Name\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.fname	}
		}
		if (document.theForm.lname.value == "")	{
			warningText += "Last Name\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.lname	}
		}
		if (document.theForm.street.value == "")	{
			warningText += "Street\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.street	}
		}
		if (document.theForm.city.value == "")	{
			warningText += "City\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.city	}
		}
		if (document.theForm.state.selectedIndex == 0)	{
			warningText += "State\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.state	}
		}
		if (document.theForm.zip.value == "")	{
			warningText += "ZIP Code\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.zip	}
		}
		if (document.theForm.phone.value == "")	{
			warningText += "Phone number\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.phone	}
		}

		if (document.theForm.email.value == "")	{
			warningText += "Email Address\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.email	}
		}
		
		if (document.theForm.ship_city.value == "") {
			document.theForm.ship_state.selectedIndex = 0
		}
	


		if (warningTrack>0)	{
			alert(warningText)
			
			// it will only be "" if How did you hear about us? was not checked
			if (selectWhichField != "") {
				selectWhichField.focus()
			}
				
		}	else	{
			//now, submit the form
			document.theForm.submit()
		}
		return true	// needed to make it not display an error in Netscape
}

// customize.php
function customizeForm() {
		var warningText = "Please complete the following information:\n"
		var warningTrack = 0
		selectWhichField = ""
		if (document.theForm.fname.value == "")	{
			warningText += "First Name\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.fname	}
		}
		if (document.theForm.lname.value == "")	{
			warningText += "Last Name\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.lname	}
		}
		/*
			if (document.theForm.street.value == "")	{
				warningText += "Street\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.street	}
			}
			if (document.theForm.city.value == "")	{
				warningText += "City\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.city	}
			}
			if (document.theForm.state.selectedIndex == "0")	{
				warningText += "State\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.state	}
			}
			if (document.theForm.zip.value == "")	{
				warningText += "ZIP Code\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.zip	}
			}
			if (document.theForm.phone.value == "")	{
				warningText += "Phone number\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.phone	}
			}
		*/
		
		if (document.theForm.email.value == "")	{
			warningText += "Email Address\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.email	}
		}	else	{
			var validateEmail = checkEmail(document.theForm.email.value)
			
			if (validateEmail > 0) {
				warningText += "Email Address\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.email	}
			}
		}
		
		if (document.theForm.secret_question.value == "")	{
			warningText += "Secret Question\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.secret_question	}
		}
		
		if (document.theForm.secret_answer.value == "")	{
			warningText += "Secret Answer\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.secret_answer	}
		}
	

		if (document.theForm.pass.value == "") {
				warningText += "Password\n"
				warningTrack++
				if (selectWhichField == "") {	selectWhichField = document.theForm.pass	}
		}	else	{
			if (document.theForm.pass.value != document.theForm.verify_pass.value) {
				warningText += "Password and Verify Password do not match\n"
				warningTrack++
				document.theForm.verify_pass.value = ""
				document.theForm.pass.value = ""
				if (selectWhichField == "") {	selectWhichField = document.theForm.pass	}
			}
		
		}
		
		

		if (warningTrack>0)	{
			alert(warningText)
			
			// it will only be "" if How did you hear about us? was not checked
			if (selectWhichField != "") {
				selectWhichField.select()
			}
				
		}	else	{
			//now, submit the form
			document.theForm.submit()
		}
		return true	// needed to make it not display an error in Netscape
		
}

// cust_repeat.php
function addRepeats() {
	document.theCart.action = "cust_repeat-add.php"
	document.theCart.submit()
}



// payment.php
function submitPayment() {
		
		// remove dashes from the credit card number 
		numbersOnly_no_decimal(document.theForm.card_accountNumber.name,document.theForm.card_accountNumber.value,document.theForm.name)
		
		var warningText = "Please complete the following information:\n"
		var warningTrack = 0
		selectWhichField = ""
		if (document.theForm.card_accountNumber.value == "")	{
			warningText += "Credit Card Number\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.card_accountNumber	}
		}
		if (document.theForm.card_cvNumber.value == "")	{
			warningText += "Security Code\n"
			warningTrack++
			if (selectWhichField == "") {	selectWhichField = document.theForm.card_cvNumber	}
		}


		if (warningTrack>0)	{
			alert(warningText)
			
			// it will only be "" if How did you hear about us? was not checked
			if (selectWhichField != "") {
				selectWhichField.select()
			}
				
		}	else	{
			//now, submit the form
			document.theForm.submit()
		}
		return true	// needed to make it not display an error in Netscape
		
}


