// JavaScript Document


function process_postcode(pc)
	{
		$.ajax({
		  url: '/elv-application/includes/js/ajax/process-postcodes/',
		  data: {postcode: pc},
		  success: function(data) {
			$('#wbc_postcode_container').html(data);
			process_tips("pc");
		  }
		});
	};
	
function process_vrm(rn)
	{
		$.ajax({
		  url: '/elv-application/includes/js/ajax/process-vrm/',
		  data: {regno: rn},
		  success: function(data) {
			$('#wbc_regno_container').html(data);
			process_tips("vrm");
		  }
		});
	};
	
function process_tips(trigger)
	{
		var data = "<div class='tips_loading'><img src='/elv-application/images/tips_loading.gif' alt='Help is on the way' /></div>";
		$('#bottom_container').html(data);
		$.ajax({
		  url: '/elv-application/includes/js/ajax/process-tips/',
		  success: function(data) {
			$('#bottom_container').html(data);
		  }
		});
	};
	
function load_vrm_page(pc, rn)
	{
		$.ajax({
		  url: '/elv-application/includes/js/ajax/process-postcodes/',
		   data: {postcode: pc},
		  success: function(data) {
			$('#wbc_postcode_container').html(data);
		  }
		});
		$.ajax({
		  url: '/elv-application/includes/js/ajax/process-vrm/',
			data: {regno: rn},
		  success: function(data) {
			$('#wbc_regno_container').html(data);
		  }
		});
		$.ajax({
		  url: '/elv-application/includes/js/ajax/process-tips/',
		  data: {nodelay: "x"},
		  success: function(data) {
			$('#bottom_container').html(data);
		  }
		});
	}

function fillAddress(f) {
	if(f.addressYes.checked == true) {
		f.home_address1.value = f.collection_address1.value;
		f.home_address1.readOnly = true;
		f.home_address2.value = f.collection_address2.value;
		f.home_address2.readOnly = true;
		f.home_address3.value = f.collection_address3.value;
		f.home_address3.readOnly = true;
		f.home_postcode.value = f.collection_postcode.value;
		f.home_postcode.readOnly = true;
	}
	else
		{
			f.home_address1.value = "";
			f.home_address1.readOnly = false;
			f.home_address2.value = "";
			f.home_address2.readOnly = false;
			f.home_address3.value = "";
			f.home_address3.readOnly = false;
			f.home_postcode.value = "";
			f.home_postcode.readOnly = false;
		}
			
}

