//Init form on page load
$(function() {

	//We are using WorldNomads' JavaScript to keep the HW form behaviour integrated with their website
	initWN_QQ('wn_generic_lp');	//ID of the main HTML container for the form

	//Load details for the quote from our DB
	$('.submit button').click(function(){

		//Show Quote panel
		$('.result_block').html('<div class="loading">Calculating Quote</div>');
		$('.toggle_panel').slideDown();
		$('html, body').animate({
			scrollTop: $(".toggle_panel").offset().top
		}, 2000);

		$.ajax({
			url: '/travel-store/ajax/getWNQuote.php',
			type: 'GET',
			data: {
				country: $('select[name="country"]').val(),
				province: $('select[name="province"]').val(),
				coverage: $('select[name="coverage"]').val(),
				startday: $('select[name="startday"]').val(),
				startmonth: $('select[name="startmonth"]').val(),
				startyear: $('select[name="startyear"]').val(),
				duration: $('select[name="duration"]').val(),
				typeofpolicy: $('input[name="typeofpolicy"]:checked').val()
			},
			dataType: 'html',
			success: function (data) {
				$('.result_block').html(data);
			}
		});
	})
});

