function checkUpdatePass() {

	if (document.getElementById('pass1').value == document.getElementById('pass2').value) {
		if (document.getElementById('pass1').value.length < 3) {
			alert("Password must be at least 3 characters.");
		} else { 
			document.getElementById('changepass').submit();
		}

	} else {
		alert('Passwords don\'t match');
	}
}
function checkUserInfo() {
	if (document.getElementById("fullname").value.length < 1) {
		alert("Name is required");
	return false; 
	}
	// build a reg exp string to test the email
	myreg = /.*@.*\..*/;
	mymatch = myreg.exec(document.getElementById("email").value)
	if (mymatch) {
		return true;
	} else {
		alert("The email address does not appear to be valid.  Please check your entry and try again.");
	return false;
	}	
}
// this makes sure that an option group is selected and a description is entered
function checkOptionInfo() {
	if (document.getElementById("description").value.length < 1) {
		alert("Description is required");
	return false;
	}
	if (document.getElementById("option_group_id").value == "NONE") {
		alert("You must select a GROUP");
	return false;
	}
}
// this makes sure that the reg form is filled out properly
function checkRegistration() {
	if (document.getElementById("firstname").value.length < 1) {
		alert("First Name is required");
	return false;
	}
	if (document.getElementById("lastname").value.length < 1) {
		alert("Last Name is required");
	return false;
	}
	if (document.getElementById("company").value.length < 1) {
		alert("Company is required");
	return false;
	}
	if (document.getElementById("address").value.length < 1) {
		alert("Address is required");
	return false;
	}
	if (document.getElementById("city_state_zip").value.length < 1) {
		alert("City, State, and ZIP are required");
	return false;
	}
	if (document.getElementById("phone").value.length < 1) {
		alert("Phone is required");
	return false;
	}
	if (document.getElementById("reg_email").value.length < 1) {
		alert("E-Mail is required");
	return false;
	}
	return true;
}
// verify required fields in Product Group
function checkProductGroupInfo() {
	if (document.getElementById("group_name").value.length < 1) {
		alert("Group Name is required");
	return false;
	}
	if (document.getElementById("description").value.length < 1) {
		alert("Description is required");
	return false;
	}
	if (document.getElementById("size").value.length < 1) {
		alert("Default Size is required");
	return false;
	}		
}
// verify required fields in Product Group
function checkProductInfo() {
	if (document.getElementById("product_group_id").value == "NONE") {
		alert("You must select a product group.");
	return false;
	}
	if (document.getElementById("description").value.length < 1) {
		alert("Description is required");
	return false;
	}	
}

// verify required fields in References
function checkRef() {
	if (document.getElementById("customer_type").value == "NONE") {
		alert("You must select a customer type.");
	return false;
	}
	if (document.getElementById("customer").value.length < 1) {
		alert("Customer is required");
	return false;
	}	
}

// verify required fields in FAQ
function checkFAQ() {
	if (document.getElementById("question").value.length < 1) {
		alert("You must enter a question.");
	return false;
	}
	if (document.getElementById("answer").value.length < 1) {
		alert("You must enter an answer.");
	return false;
	}	
}

// verify required fields in tech info
function checkFile() {
	if (document.getElementById("title").value.length < 1) {
		alert("You must enter a title.");
	return false;
	}
		if (document.getElementById("file_type").value == "NONE") {
		alert("You must choose a file type.");
	return false;
	}		

}

// verify required fields in News Items
function checkNews() {
	if (document.getElementById("month").value.length < 1) {
		alert("You must enter a month.");
	return false;
	}
	if (document.getElementById("day").value.length < 1) {
		alert("You must enter a day.");
	return false;
	}
	if (document.getElementById("year").value.length < 1) {
		alert("You must enter a year.");
	return false;
	}	
	if (document.getElementById("title").value.length < 1) {
		alert("You must enter a title.");
	return false;
	}
	if (document.getElementById("description").value.length < 1) {
		alert("DNews text is required");
	return false;
	}	
}

function changePass(email) {
	thebool = confirm("Are you sure you'd like to reset the password for " + email + "?");
	if(thebool) {
		document.location = "resetpass.php?email=" + email;
	}
}

function deleteUser(email) {
	thebool = confirm("Are you sure you'd like to delete the user " + email + "?");
	if(thebool) {
		document.location = "user_delete.php?email=" + email;
	}
}
function deleteOption(id) {
	thebool = confirm("Are you sure you'd like to delete this option?");
	if(thebool) {
		document.location = "option_delete.php?id=" + id;
	}
}
function deleteOptionGroup(id) {
	thebool = confirm("Are you sure you'd like to delete this option group?  Doing so will also delete all options that are members of this group.");
	if(thebool) {
		document.location = "option_group_delete.php?id=" + id;
	}
}
function deleteProductGroup(id) {
	thebool = confirm("Are you sure you'd like to delete this product group?");
	if(thebool) {
		document.location = "product_group_delete.php?id=" + id;
	}
}
function deleteProduct(id) {
	thebool = confirm("Are you sure you'd like to delete this product?");
	if(thebool) {
		document.location = "product_delete.php?id=" + id;
	}
}
function deleteNews(id) {
	thebool = confirm("Are you sure you'd like to delete this news item?");
	if(thebool) {
		document.location = "news_delete.php?id=" + id;
	}
}
function deleteRef(id) {
	thebool = confirm("Are you sure you'd like to delete this reference?");
	if(thebool) {
		document.location = "ref_delete.php?id=" + id;
	}
}
function deleteFAQ(id) {
	thebool = confirm("Are you sure you'd like to delete this FAQ?");
	if(thebool) {
		document.location = "faq_delete.php?id=" + id;
	}
}
function deleteFile(id,filename) {
	thebool = confirm("Are you sure you'd like to delete this file?");
	if(thebool) {
		document.location = "file_delete.php?filename="+filename+"&id=" + id;
	}
}
function unconfirm(theuser) {
thebool = confirm("Are you sure you'd like to un-confirm " + theuser + "?");
if(thebool)  {
	document.location = "unconfirm.php?email=" + theuser;
} else {
	document.getElementById(theuser).checked = true;
}
}

function confirmVerify(theuser) {
thebool = confirm("Are you sure you'd like to confirm " + theuser + "?");
if(thebool)  {
	document.location = "confirm.php?email=" + theuser;
} else {
	document.getElementById(theuser).checked = false;
}
}

function addToCart(product_id) {
	if(document.getElementById("option_id")) {
		document.location= "/dbadmin/cart/add_to_cart.php?product_id=" + product_id + "&option_id=" + document.getElementById("option_id").value;
	} else {
		document.location= "/dbadmin/cart/add_to_cart.php?product_id=" + product_id;
	}
}

