//used in conjunction with genForm.js
var validationSet = {
		'gen': {
			'genError': "There is a problem with some of the details you've entered.<br/>Please double-check the information you've provided and re-enter it correctly"
		},
		'last_name': {
			'emptyError': 'Please enter a last name'
		},
		'location': {
			'emptyError': 'Please enter an address'
		},
		'postcode': {
			'emptyError': 'Please enter a postcode',
			'invalidError': 'Please enter a valid postcode'
		}
	};

//sets up pass variable. Do not remove.
var pass;

var grandTotal = 0;
function calculateGrandTotal(){
	grandTotal = 0;
	var numSelects = document.getElementById('statOrderDiv').getElementsByTagName("select");
	for (i=0;i<numSelects.length;i++) {
		dropDownValue = parseInt(numSelects[i].value);
		grandTotal += dropDownValue;
	}
	document.getElementById("totalOrder").innerHTML=grandTotal;
}

function checkForm(myform){
	//sets pass variable to true. Do not remove.
	pass = true;
	if(grandTotal == 0){
		
		pass = false;
		document.getElementById("totalOrderError").style.display = "block";
	}else{
		document.getElementById("totalOrderError").style.display = "none";
	}
	
	//Call a function for each field
	notEmpty('last_name');
	notEmpty('location');
	checkPostcode('postcode');
	
	if(!pass){
		failed();
		return false
	}
}