
/**
 * Submits a form with Javascript.
 * @param form the form to submit
 * @return void
 */
function doSubmit(form) {
	form.submit();
}


// destination options
var lists = new Array();

//passengers for Alicante
lists['Alicante']    = new Array();
lists['Alicante'][0] = new Array(
	'1 - 4',
	'1 - 4 + wheelchair',
	'5 - 7',
	'5 - 8 (larger vehicle)',
	'9 - 11',
	'12 - 19',
	'20 - 55'
);
lists['Alicante'][1] = new Array(
	'Band1',
	'Band2',
	'Band3',
	'Band4',
	'Band5',
	'Band6',
	'Band7'
);

//passengers for Valencia
lists['Valencia']    = new Array();
lists['Valencia'][0] = new Array(
	'1 - 4',
	'5 - 7',
	'8 - 10',
	'11 - 15',
	'16 - 19',
	'20 - 55'
);
lists['Valencia'][1] = new Array(
	'Band1',
	'Band2',
	'Band3',
	'Band4',
	'Band5',
	'Band6',
	'Band7'
);

//passengers for Murcia
lists['Murcia']    = new Array();
lists['Murcia'][0] = new Array(
	'1 - 4'
);
lists['Murcia'][1] = new Array(
	'Band1'
);

// This function goes through the options for the given
// drop down box and removes them in preparation for
// a new set of values

function emptyList( box ) {
	// Set each option to null thus removing it
	while ( box.options.length ) box.options[0] = null;
}

// This function assigns new drop down options to the given
// drop down box from the list of lists specified

function fillList( box, arr ) {
	// arr[0] holds the display text
	// arr[1] are the values

	for ( i = 0; i < arr[0].length; i++ ) {

		// Create a new drop down option with the
		// display text and value from arr

		option = new Option( arr[0][i], arr[1][i] );

		// Add to the end of the existing options

		box.options[box.length] = option;
	}

	// Preselect option 0

	box.selectedIndex=0;
}

// This function performs a drop down list option change by first
// emptying the existing option list and then assigning a new set

function changeList( box ) {
	// Isolate the appropriate list by using the value
	// of the currently selected option

	list = lists[box.options[box.selectedIndex].value];

	// Next empty the slave list

	emptyList( box.form.passenger_group );

	// Then assign the new list values

	fillList( box.form.passenger_group, list );
}

//initialises forms and javascript variables
function init() {
	changeList(document.forms['quote_form'].destination);
}

//ajax function to integrate with MailChimp
function subscribeToNewsletter() {
	email = document.getElementById('newsletter_email').value;
	//some client side validation here
	if (email != '') {
		var url = "subscribe.php?ajax=subscribe&email="+email;
		http.onreadystatechange = function(){
			if (isReady(http)) {
		   		alert(http.responseText);
			}
			//updateElement('test'); 
			};
		sendGet(url);
	}
	else {
		alert("You did not provide an email address.");
	}
}





