$(function() {

	$.getScript('scripts/core/personaldetails.js');

	//specific form handling for step 1
	
	//handling for number of named riders drop down
	
	$('#policy_who').change(function() {
		var numWho = $(this).val();
		if (numWho == 3) {
			$('#policy_numRiders').parent().show();
			updateSession('policy_numRiders',$('#policy_numRiders').val());
		} else {
			$('#policy_numRiders').parent().hide();
			updateSession('policy_numRiders',0);
		}
	}).change();

	$('#policy_totalMileage').keydown(function(e) {
		return checkChars(e,'1234567890','allow');
	});
	
	$('#policy_totalMileage').keyup(function(e) {
		checkCharsAfter($(this).attr('id'),'1234567890');
	});
	
	//If the licence has been changed then remove the link on the sitemap to the quote
	$('#proposer_bikeLicence_type').change(function() {
		var proposer_bikeLicence_type = $(this).val();
		var licence_type = $('#licence_type').attr('type');
		
		if ((proposer_bikeLicence_type == 'M' || proposer_bikeLicence_type == 'P') && proposer_bikeLicence_type != licence_type) {
			
		    // remove the link on the quote trail to step 4
			$('map>area[coords="291,0,393,62"]').remove();
			updateSession('stepcompletion_4',false);
		    updateSession('stepcompletion_3',false);
		    
		    //if they have had a quote change the breadcrumb image
			if ($('#licence_type').attr('step') == 'true'){
				mysrc = $('img[alt="Quote progression"]').attr('src');
				theend  = mysrc.length;
				thepart = mysrc.substr(0,(theend-5));
				thepart = thepart+'3.gif';
				//change image
				$('img[alt="Quote progression"]').attr('src',thepart);
			}
		}
	}).change();

});

