/*
 Hay Veterinary Group - Javascript
---------------------------------------------------------
  Copyright©2008 Red Cherry Solutions Ltd.
  http://www.RedCherrySolutions.co.uk

  Duplication of this script or any associated scripts
  in whole or in part is strictly forbidden.
---------------------------------------------------------
*/

/* Swap the active CSS */
function setActiveStyleSheet(title) {
	if (document.getElementsByTagName) {
		for (i=0; (a = document.getElementsByTagName("link")[i]); i++) {
			if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) a.disabled = true;
			if (a.getAttribute("title") == title) a.disabled = false;
		}
	}
}

/* validate the checkout form */
function validatePayment(oForm) {

	if (oForm.terms.checked == false) {
		alert('You must state that you accept the terms and conditions to make a payment.');
		return false;
	} else {
		var bValid = true;

		//shipping country
		if (oForm.cardType.options[oForm.cardType.selectedIndex].value == 'Please Select') {
			alert('Please specify the type of card you will be paying with.');
			return false;
		}

		//card input
		if (oForm.cardNo.value.length < 19) {
			alert('Please enter your full card number including hyphens: ####-####-####-####.');
			return false;
		}

		//check form
		if (oForm.invoiceRef.value == '' || 
			oForm.amount.value == '' || 
			oForm.cardNo.value == '' ||
			oForm.cardSec.value == '' ||
			oForm.cardExp.value == '' ||
			oForm.cardName.value == '' ||
			oForm.customerName.value == '' ||
			oForm.customerAddress1.value == '' ||
			oForm.customerPostcode.value == '' ||
			oForm.customerTelephone.value == '' ||
			oForm.customerEmail.value == '' ||
			oForm.code.value == '') {
			bValid = false;
		}

		//return correctly
		if (bValid == false) {
			alert('Please fill out all required fields *');
			return false;
		}
	}
}