/* Product Management module */
function shoppingcart_checkPriceOption(option, form) {
	var price_checked = false;
	var loop = form.elements.length;
	
	for(i = 0; i < loop; i++) {		  
		if(form.elements[i].name == "priceid[]") {
			if(form.elements[i].type == "checkbox") {
				if(form.elements[i].checked == true) {
					price_checked = true;
				}
			} else if(form.elements[i].type == "select-one") {
				price_checked = true;
			}
		}
	}

	if(!price_checked) {
		if(option == 0) {
			alert("You must have at least one price option selected");
		} else {
			alert("There is no price option selected to add to your cart");
		}
		return false;
	} else {
		return true;
	}
}

/* Email a friend module */
function mailfriend_validate() {
	if (document.getElementById("mailfriend_email").value == '' || document.getElementById("mailfriend_email").value == 'Email') {
		alert("You must enter your friend's email address");
	} else {
		return true;
	}
	return false;
}

/* Mailing list module */
function mailinglist_subscribe_validate() {
	if (document.getElementById("mailinglist_name").value == '' || document.getElementById("mailinglist_name").value == 'Name') {
		alert('You must enter your name');
	} else if (document.getElementById("mailinglist_email").value == '' || document.getElementById("mailinglist_email").value == 'Email') {
		alert('You must enter your email address');
	} else {
		return true;
	}
	return false;
}

function mailinglist_unsubscribe_validate() {
	if (document.getElementById("mailinglist_email").value == '' || document.getElementById("mailinglist_email").value == 'Email') {
		alert('You must enter your email address');
	} else {
		return true;
	}
	return false;
}

function mailinglist_concat_name() {
	document.getElementById('mailinglist_name').value = document.getElementById('mailinglist_first_name').value + ' ' + document.getElementById('mailinglist_last_name').value;
}